# Writing PHPT tests

- Thread: https://externals.io/message/35094
- Original archive: https://news-web.php.net/php.internals/35094
- Started by zoe.slattery@googlemail.com on 2008-02-02T10:37:36+00:00
- Messages: 5
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #35094 — zoe.slattery@googlemail.com — 2008-02-02T10:37:36+00:00

URL: https://externals.io/message/35094#35094

Hi - for any of you that are writing PHPT tests for existing extensions 
- I put a PHP script called generate_phpt.php into PHP 5.3 yesterday 
which might help a little.

It's quite a simple command line script (Raghu and I wrote it last 
year), it works by looking at the {{{proto line for a function in PHP 
source code and construct a test case frame from it. It can be used to 
construct very simple tests cases - or to turn an existing PHP file into 
PHPT format. It doesn't try and guess what the results of a test should 
be :-). I will document it properly on qa.php.net later. In the meantime:

php generate_phpt.php --help

tells you what it's supposed to do.

Zoe

PS - It doesn't work for PHP6 right now because the {{{proto line is 
different.

---

## #35100 — Rob Nicholson — 2008-02-02T11:56:22+00:00

URL: https://externals.io/message/35094#35100 · In reply to: #35094

Hi Zoe,

I notice also that the testcase generator and the testcases we have been 
committing differ slightly from the conventions listed at: 
http://qa.php.net/write-test.php . This was based on feedback we received 
so I think that http://qa.php.net/write-test.php should be updated. 
Specifically the  convention of writing multiple small tests to cover 
basic, variation  and error cases separately differs from the naming 
convention suggested on the QA pages.  We have also been following a 
convention w.r.t comments in the testcase which I think is helpful so I'd 
suggest we cover this too. Since the testcase generator adds these 
comments its  worth documenting them.

I'll produce a patch to the documentation for review if you like.


Rob Nicholson



From:
zoe <zoe.slattery@googlemail.com>
To:
internals@lists.php.net
Date:
02/02/2008 11:21
Subject:
[PHP-DEV] Writing PHPT tests



Hi - for any of you that are writing PHPT tests for existing extensions 
- I put a PHP script called generate_phpt.php into PHP 5.3 yesterday 
which might help a little.

It's quite a simple command line script (Raghu and I wrote it last 
year), it works by looking at the {{{proto line for a function in PHP 
source code and construct a test case frame from it. It can be used to 
construct very simple tests cases - or to turn an existing PHP file into 
PHPT format. It doesn't try and guess what the results of a test should 
be :-). I will document it properly on qa.php.net later. In the meantime:

php generate_phpt.php --help

tells you what it's supposed to do.

Zoe

PS - It doesn't work for PHP6 right now because the {{{proto line is 
different.

-- 










Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 
741598. 
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU

---

## #35110 — Jani Taskinen — 2008-02-02T19:57:12+00:00

URL: https://externals.io/message/35094#35110 · In reply to: #35094

You simply ignored my email or never got it? The correct place for such scripts 
is not in the "root" but in scripts/dev/

--Jani


zoe kirjoitti:
> Hi - for any of you that are writing PHPT tests for existing extensions 
> - I put a PHP script called generate_phpt.php into PHP 5.3 yesterday 
> which might help a little.
> 
> It's quite a simple command line script (Raghu and I wrote it last 
> year), it works by looking at the {{{proto line for a function in PHP 
> source code and construct a test case frame from it. It can be used to 
> construct very simple tests cases - or to turn an existing PHP file into 
> PHPT format. It doesn't try and guess what the results of a test should 
> be :-). I will document it properly on qa.php.net later. In the meantime:
> 
> php generate_phpt.php --help
> 
> tells you what it's supposed to do.
> 
> Zoe
> 
> PS - It doesn't work for PHP6 right now because the {{{proto line is 
> different.

---

## #35126 — zoe.slattery@googlemail.com — 2008-02-03T09:18:53+00:00

URL: https://externals.io/message/35094#35126 · In reply to: #35110

Jani Taskinen wrote:
> You simply ignored my email or never got it? The correct place for 
> such scripts is not in the "root" but in scripts/dev/
>
> --Jani
>
Jani - of course I wouldn't ignore a mail from you :-) - I didn't see 
it. I talked a bit to Johannes on IRC about where to put it and in the 
end said I'd put it in the top level and move or remove it if anyone 
disagreed. I'll move it.

Thanks, Zoe
>
> zoe kirjoitti:
> > […]

---

## #35128 — zoe.slattery@googlemail.com — 2008-02-03T09:27:27+00:00

URL: https://externals.io/message/35094#35128 · In reply to: #35100

Rob Nicholson wrote:
>
> Hi Zoe,
>
> I notice also that the testcase generator and the testcases we have 
> been committing differ slightly from the conventions listed at: 
> http://qa.php.net/write-test.php . This was based on feedback we 
> received so I think that http://qa.php.net/write-test.php should be 
> updated. Specifically the  convention of writing multiple small tests 
> to cover basic, variation  and error cases separately differs from the 
> naming convention suggested on the QA pages.
Rob - you are right - I think the most important thing we learned is 
that size matters - the smaller the better.
>  We have also been following a convention w.r.t comments in the 
> testcase which I think is helpful so I'd suggest we cover this too. 
> Since the testcase generator adds these comments its  worth 
> documenting them.
>
> I'll produce a patch to the documentation for review if you like.
>
Please do :-) I admit I have been meaning to do this for ages and it's 
bad that I haven't got around to it.
>
> Rob Nicholson
>
>
> From: 	zoe <zoe.slattery@googlemail.com>
> To: 	internals@lists.php.net
> Date: 	02/02/2008 11:21
> Subject: 	[PHP-DEV] Writing PHPT tests
>
>
> ------------------------------------------------------------------------
>
>
>
> Hi - for any of you that are writing PHPT tests for existing extensions
> - I put a PHP script called generate_phpt.php into PHP 5.3 yesterday
> which might help a little.
>
> It's quite a simple command line script (Raghu and I wrote it last
> year), it works by looking at the {{{proto line for a function in PHP
> source code and construct a test case frame from it. It can be used to
> construct very simple tests cases - or to turn an existing PHP file into
> PHPT format. It doesn't try and guess what the results of a test should
> be :-). I will document it properly on qa.php.net later. In the meantime:
>
> php generate_phpt.php --help
>
> tells you what it's supposed to do.
>
> Zoe
>
> PS - It doesn't work for PHP6 right now because the {{{proto line is
> different.
>
> -- 
> 
> 
>
>
>
>
>
> ------------------------------------------------------------------------
>
> /
> /
>
> /Unless stated otherwise above:
> IBM United Kingdom Limited - Registered in England and Wales with 
> number 741598.
> Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 
> 3AU/
