News Feed
Sections




News Archive
feed this:

Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Freek Lijten:
Testing PHP extensions - what makes a good test
March 23, 2015 @ 09:52:58

Freek Lijten has a new post today continuing his look at the world of PHP extensions and focusing in on testing this time. He hopes to answer the question of what makes a good, effective set of tests to help increase the stability and quality of the extensions you write.

In my previous blog I took you through the process of getting PHP and extensions compiled, generating code coverage and running tests. What I did not talk about was what makes a good test. I hope to correct on this by adding this post and going into more detail on the actual writing of tests itself.

Using the same extension as before (enchant) he goes through the addition of a test for the enchant_dict_add_to_session function. He start by showing how much the function is currently tested (hint: none) and code coverage. He points out that 100% coverage is just one metric in a set that should be considered and not the final goal. He shares a simple test for the function that checks to see if a certain word exists in a dictionary. The coverage report shows all lines being executed, but there's a lot not tested, at least conceptually. He shows how to test "the spirit" of the function with additional tests for non-existent words, spell checking and if a word is not in the dictionary at all. PHP example code shows these tests kinds of tests to illustrate the steps he's talking about.

0 comments voice your opinion now!
test extension phpt spirit codecoverage metric goal

Link: http://www.freeklijten.nl/home/2015/03/22/Testing-PHP-extensions-what-makes-a-good-test

Freek Lijten:
Testing and improving PHP extensions for PHP 7
March 13, 2015 @ 10:02:47

In his latest post Freek Lijten talks about PHP extensions, the upcoming PHP version - well, PHP7 - and the things that can be (and are being) done to help improve and prepare the extension ecosystem. In his post he walks you through the process of getting a PHP7 install set up, a sample extension set up and writing some tests to help improve it.

PHP7 is coming. And it is coming to a neighbourhood near you :) A couple of people started an initiative to ensure extensions will be running out of the box once PHP7 hits the shelves. The fun part: You can help too! No C knowledge is necessary (although it is fun to dive into PHP's internals!). This piece is a short intro to help you help PHP! Help triaging extensions, write tests, add documentation and who knows when you'll be diving into C code.

He's encouraging this work as a part of the recently launched GoPHP7 - Extensions initiative launched a while back. He starts by helping you get PHP7 installed (from source, compiled). Once that's installed and working, he helps you get an extension up and running, in this case the enchant extension. He shows you how to run the tests for the extension and how to write some tests to contribute back to the project. He includes instructions for generating code coverage reports, walks you through some sample code and a link to a page with more information if you get stuck.

0 comments voice your opinion now!
testing improving extension php7 version phpt unittest coverage gophp7

Link: http://www.freeklijten.nl/home/2015/03/12/Testing-and-improving-PHP-extensions-for-PHP-7

Chris Jones:
Using the PHP CLI Webserver to Identify and Test Memory Issues in PHP
August 15, 2012 @ 08:35:07

Chris Jones has a new post today showing how you can use PHP 5.4's built-in web server to help test for memory issues in your application (and the language).

Rasmus mentioned on IRC how he ran the [command line] tests: simply renaming the ".phpt" test files as ".php", and invoking them through the CLI webserver. The SKIPIF sections get executed, but that doesn't affect the desired outcome of testing multiple HTTP requests with different input scripts. [Here] are some quick shell scripts I put together to automate testing the OCI8 extension with valgrind.

He uses the OCI8 extension as an example, showing how to set up these scripts to enable the execution of the tests, fire up the web server and execute Valgrind to help monitor the memory of the execution.

0 comments voice your opinion now!
builtin webserver cli test unittest phpt tutorial shell


QaFoo.com:
Testing file uploads with PHP
December 13, 2010 @ 13:53:24

On the QaFoo.com site Manuel Pichler has posted a new tutorial about using unit testing, specifically with PHPUnit (really ending up on phpt) to test and be sure that your file upload handling is working correctly.

A question I am asked on a regular basis is, how you can test a file upload with PHP. In this blog post, I take a precise look at this topic and show you how to test your file uploads from within your standard testing environment, using widely unknown testing framework for PHP.

He shows how to use a custom $_FILES superglobal to mimic the upload process noting, however, that this won't work due to possible file handling on the backend. His alternative is to use a phpt test to push a raw posted file to the application and then check the results. He then shows how to take these functioning tests and drop them back into PHPUnit via it's "PhpTestCase" handling. You can find full code examples here.

0 comments voice your opinion now!
testing unittest file upload phpunit phpt tutorial


Rafael Dohms' Blog:
PHPT Writing tests for PHP
August 25, 2009 @ 12:05:35

If you've ever wanted to give back to the PHP project, but weren't sure quite how, Rafael Dohms has written up a post to make one of the options much easier to get into - writing PHPT tests for the PHP language.

The beauty about PHPT is that you need to know very little other than writing PHP code. A little knowledge into the inner workings of PHP will of course help you in finding areas of code that need testing, and how best to test them, but just knowing PHP is enough to start.

He leads you through a five step process that'll have you up and writing tests in no time - setting up your environment, looking for something to test, writing and executing a test and submitting the results back to the PHP project. He sprinkles in a few code bits and screenshots to help point you in the right direction.

0 comments voice your opinion now!
phpt test tutorial introduction


Lorna Mitchell's Blog:
Testing PHP
May 04, 2009 @ 12:06:42

In this new post to her blog Lorna Mitchell talks a bit about the upcoming TestFest event happening in Manchester next weekend and what she's learned about testing PHP to make things flow a bit smoother for her while there (and you, should you want to write tests in the future).

In preparation I decided it was high time to sit down and figure out what testing PHP is all about. People kept telling me it was easy but I had no clear picture of how all the pieces went together - there are different ways of doing the same thing and although I have been keen to get involved with testing for some time, I haven't been able to get started until now.

She looks at the automated tests as a part of the build ("make test") and some of the screens from the lcov testing results. She also recommends reading up on the phpt documentation to help you get going.

1 comment voice your opinion now!
testing phpt testfest manchester learn maketest lcov


Stefan Koopmanschap's Blog:
TestFest is back!
April 28, 2009 @ 08:46:49

In a recent blog post Stefan Koopmanschap reminds the PHP development community that the PHP TestFest is back again this year!

Last year's TestFest was a huge success. The worldwide initiatives by usergroups and individuals gave a nice addition to the code coverage for PHP itself. This year, the TestFest period has been extended to 3 months, starting the beginning of this month and ending end of june. But a nice bunch of European usergroups including the Dutch usergroup are combining TestFest on may 9th!

TestFest events are happening all over the world - you can see if there's one near you on this page of the PHP.net wiki. For those attending php|tek this year, there'll also be a TestFest going on during the Hackathon event (read our interview about the event here).

0 comments voice your opinion now!
testfest09 testfest hackathon community phpt test usergroup


Greg Beaver's Blog:
Code Coverage Reporting using PEAR, PEAR2, phar, and sqlite3
April 14, 2009 @ 12:08:08

Greg Beaver has a new post reporting on his latest efforts to improve the Pyrus PEAR installer and to make it a more strong, stable and robust end result.

One of the problems I found when designing the new code for PEAR 1.4.0 (back in the day) was that it was very difficult to determine whether changes would break things. The main problem revolves around the colossal size of the test suite. [...] This is a real problem when trying to develop with any kind of flow. If, after every change, one needs to sit through 35 minutes of tests, one will never develop anything of substance.

What he wanted was an application that could detect only the files modified and tests those with the results put into the code coverage report. To fill the need, he created test-modified.php to run just the phpt tests needed.

0 comments voice your opinion now!
codecoverage report phpt unittest pear phar sqlite custom


Roy Ganor's Blog:
Welcome the PDTT - PHP 5.3 Code Assist Engine Tests
March 17, 2009 @ 08:44:22

As mentioned on the Zend Developer Zone today, the group working on the Eclipse PDT extension has been working hard to get the tool ready for PHP 5.3 when its released and are now looking to the community to help them with some testing.

Roy Ganor explains in his blog:

Since Michael has just finished implementing the second phase for PHP 5.3 support in PDT, we can now expose unit tests and ask users to add more cases to the code assist tests repository.

His post includes the basic format for the tests (as written in pdtt, a clone of the phpt format) and a clip from the PDT wiki page about why they need them. There's no automatic way to submit them but if you want more information on the project and testing, you can always send them an email to find out more.

0 comments voice your opinion now!
royganor pdt pdtt test contribute phpt eclipse php5


Greg Beaver's Blog:
Pyrus, PEAR2 and web code coverage report for phpt-based tests
February 17, 2009 @ 09:31:57

Greg Beaver has posted an update one some of the things he's been working on in the realm of his projects - Pyrus, PEAR2 and code coverage for phpt-based tests.

In any case, now that work on ext/phar has shifted primarily to maintenance mode, and namespaces are finally ancient history, I've shifted all of my coding energy to getting Pyrus, PEAR's next-generation installer, ready to ship.

Pyrus is the PEAR installer as rewritten for the next major PHP release (5.3) and uses a lot of the new features it offers (including full archive support, SQLite 3, combined configuration files and several new developer-centric additions). He also includes a sample bit of code that he worked up to run code coverage reports against the PEAR packages. He includes links to three different examples of the report's output.

0 comments voice your opinion now!
pyrus pear codecoverage unittest phpt test installer pear2



Community Events

Don't see your event here?
Let us know!


release application opinion configure example community framework conference interview library introduction laravel podcast performance install php7 symfony2 composer api series

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework