News Feed
Jobs Feed
Sections




News Archive
feed this:

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

Federico Cargnelutti:
TDD Checking the return value of a Stub
April 16, 2014 @ 10:25:15

Federico Cargnelutti has a helpful post to his site today for the unit testing/TDD crowd about checking the retuned value from a stub of an object in your tests. He's using the built-in mocking framework here, not something like Mockery.

State verification is used to ensure that after a method is run, the returned value of the SUT is as expected. Of course, you may need to use Stubs on a test double or a real object to tell the object to return a value in response to a given message. [...] In PHP, for example, you dynamically type the return value within the body of the method. This means that PHP mocking libraries cannot check the type of the return value and provide guarantees about what is being verified. This leads to the awkward situation where a refactoring may change the SUT behaviour and leave a stub broken but with passing tests.

He gives an example of a few classes - a Presenter and Collaborator - and a test that mocks out the Collaborator instance, calling a "getStories" method on it. He shows a situation where all tests pass in the initial version, but after some changes to the return type, a test that should fail doesn't. His solution for the issue revolves around DocBlock annotations and the Return Value instead of the built-in mock object return method.

0 comments voice your opinion now!
tdd unittest return value stub passing test returnvalue mock

Link: http://blog.fedecarg.com/2014/04/15/checking-the-return-value-of-a-stub/

The PHP.cc Blog:
PHPUnit 4.0 Test Proxies
March 12, 2014 @ 10:13:08

On thePHP.cc blog today there's another post looking at an improvement in the latest release of the popular PHP unit testing tool, PHPUnit 4.0.0. In the post Sebastian Bergmann looks at test proxies.

One of the highlights of PHPUnit 4.0, which was released last week, is improved support for integration testing through so-called test proxies. [...] PHPUnit has had built-in support for stubs and mocks for quite some time. These stubs and mocks can be used in every context where an object of the original class is expected. As it should be, the code of the original class is not executed when a method is called on the stub or mock. [...] PHPUnit 4.0 introduces the concept of test proxies [...] to have an object that provides the same API for expectations as a mock object while at the same time proxying method calls to the original class.

He includes some code examples to help illustrate. He creates a "SimpleWorkflow" class and shows how to test the execution of its "doWork" function to return the correct kind of "Result".

0 comments voice your opinion now!
phpunit test proxy unittest introduction release

Link: http://thephp.cc/viewpoints/blog/2014/03/phpunit-4-0-test-proxies

VG Tech:
Generating Code Coverage of Behat Tests
January 22, 2014 @ 10:52:57

On the VGTech blog today Christer Edvartsen looks at a method of generating the code coverage of Behat tests using a special bit of code and the $_SERVER superglobal to detect what parts of the code is being executed.

Yes, I know, it sounds silly, but bear with me. The nature of acceptance tests is not really to tests units of code, but to assure that the behavior of your application meets a certain set of criteria (Behat Scenarios). When your applications grow over time, code coverage can be a nice tool to help you pinpoint where you need to add more tests. In a perfect world tests are added while implementing new features so that your applications are always fully tested, but that isn't always as easy as it sounds.

The first chunk of code is something that would go in the router of your application, capturing the "collect coverage" and "enable coverage" input variables. The other part of the code creates a unique ID in the set up and uses it in a call (via Guzzle) to the server to start the tracking. In the tear down method, it sends the call to get the coverage results and process them through the PHP_CodeCoverage tool from Sebastian Bergmann.

0 comments voice your opinion now!
code coverage behat test tutorial functional

Link: http://tech.vg.no/2014/01/21/generating-code-coverage-of-behat-tests

Lorna Mitchell:
Zend Certified PHP Developer 5.5
January 08, 2014 @ 09:23:45

If you're thinking about taking the Zend Certified PHP Developer (5.5) test but aren't sure exactly where to start, Lorna Mitchell has provided a list of some good resources to help you out.

Yesterday I updated my previous ZCE certificate to the Zend Certified PHP Developer qualification (the new ZCE for PHP 5.5 also got a new name). Since the ZCE 5.3 exam is no longer available and I work with various clients to prepare their teams for these certifications, it was important to me that I keep my own certification up to date. Now I've done that, I'd like to share some resources for others doing the same thing.

She points to a few things that could help you make the grade:

0 comments voice your opinion now!
zend certified developer test certification resource list

Link: http://www.lornajane.net/posts/2014/zend-certified-php-developer-5-5

NetTuts.com:
Acceptance Testing With Codeception
January 03, 2014 @ 11:45:39

On NetTuts.com today there's a new tutorial posted from Andrew Perkins about acceptance testing with Codeception, an alternative testing framework that's been gaining popularity in the PHP community.

Codeception is a multi-featured testing framework for PHP. It can handle unit, functional, and acceptance testing of web applications and it's powered by the already very popular PHPUnit testing framework.

Codeception allows us to test different kinds of user perspectives and site scenarios while they are visiting our app to ensure a pleasant user experience. By testing multiple scenarios, we can simulate a user's natural flow throughout our application to make sure the app is working as expecting.

The tutorial guides you through the process of getting Codeception up and running and creating a first test. The example test hits a basic PHP-enhanced HTML page to uppercase a given string. They show how to create the test skeleton and flesh it out with a test for the page load as well as the form submission.

0 comments voice your opinion now!
acceptance test testing tutorial codeception

Link: http://net.tutsplus.com/tutorials/php/acceptance-testing-with-codeception-2

Codeception.com:
Testing Emails in PHP. Part 1 PHPUnit
December 18, 2013 @ 13:04:05

On Codeception.com an tutorial has been posted showing you how to use PHPUnit to test emails - verifying that your application emails are being sent with the help of a third-party service.

So how do you check that your applications sends email correctly? It looks like dealing with emails is always a challenge. How would you verify that email message is formatted and delivered correctly, without actually sending them to your clients? That's the first question. And the second question is: how can we automate testing of emails? For both questions we have an answer.

To answer the first, they recommend using a service like Mailtrap or Mailcatcher (the one they use for the post) to receive the emails for evaluation. They help you get both PHPUnit and the popular Guzzle HTTP library installed to help with resting against Mailcatcher's REST API. The example test is also included, showing a few methods that connect to the API, get the most recent messages and clear the list when it's complete. Assertions like assertEmailIsSent, assertEmailHtmlContains and assertEmailSenderEquals show how to test the message results that come back for validity.

0 comments voice your opinion now!
test unittest phpunit email send mailcatcher rest api

Link: http://codeception.com/12-15-2013/testing-emails-in-php.html

Federico Cargnelutti:
API Development Tips
July 17, 2013 @ 13:50:45

Federico Cargnelutti has a quick post to his site today sharing some general API tips you could follow when creating your backend application.

Organizations who are paying attention already know they need to have an open web API, and many already have under development or in the wild. Make sure you haven't been caught by the pitfalls of many early API releases.

He briefly mentions the idea of having multiple points of failure and includes five more general tips based on information from this video:

  • Test it all
  • Plan for future versions
  • Embrace standards
  • Monitor everything & be honest
  • Fail well
0 comments voice your opinion now!
api development tips list video test version standards monitoring fail

Link: http://blog.fedecarg.com/2013/07/17/api-development-tips

VG Tech Blog:
Selenium Tests
June 21, 2013 @ 11:26:30

On the VG Tech blog today there's a new post introducing Selenium testing to those that might not have heard of it before for functional testing. It's a powerful tool that can even be used from inside PHPUnit tests to automate evaluation of your frontend application.

When we develop code at VG we have started to use Selenium tests for continuous integration. This allows us to easy write tests that programmatically checks that last commit didn't break anything.

He describes some of the types of tests Selenium can do and mentions the IDE that can hook into Firefox and record your actions and translate them into tests. This includes the ability to export them to PHPUnit tests (sample code provided) that extend the "PHPUnit_Extensions_SeleniumTestCase." An example screenshot of what the IDE running looks like is also included.

0 comments voice your opinion now!
selenium test introduction phpunit export ide firefox

Link: http://tech.vg.no/2013/06/14/selenium-tests

PHP.net:
PHP 5.5.0RC2 is available
May 24, 2013 @ 09:55:27

On PHP.net today they've announced the release of the latest Release Candidate in the PHP 5.5.x series - PHP 5.5.0RC2.

The PHP development team announces the availability of the second release candidate of PHP 5.5. This release fixes some bugs against RC1 and improves overall stability. [...] Please help us to identify bugs in order to ensure that the release is solid and all things behave as expected. Please test this release candidate against your code base and report any problems that you encounter to the QA mailing list and/or the PHP bug tracker.

Issues corrected include a segfault when memory was used up, an issue with mbstring in PHPT tests in Windows x64 and a problem with custom exceptions. You can find the full list of changes in the NEWS file. Please download this latest release candidate (Windows here) and test it out on your systems.

0 comments voice your opinion now!
release candidate php55 download test bugfix

Link: http://php.net/index.php#id2013-05-23-1

Systems Architect:
Performance benchmark of popular PHP frameworks
April 24, 2013 @ 12:04:31

On his site today Lukasz Kujawa has a post that compares some performance benchmarks of several popular PHP frameworks including Slim, CodeIgniter, Laravel, Symfony2 and Zend Framework 2.

There are many assumptions around performance of different PHP frameworks. I frequently hear strong opinions about superiority X over Y in this context. There are companies writing new PHP frameworks from scratch because available solutions are too slow for them. What does it really mean? Does the framework performance matters? Before answering this questions lets check how slow is your framework!

He took the "quick start" projects provided for each of the examples and ran some tests with the Apache Benchmark (ab) tool against EC2 instances, all configured the same way. The results weren't overly surprising with Slim beating the others hands down (it's a micro-framework after all) and Kohana and CodeIgniter coming in second and third. The frameworks with more overhead like Zend Framework and Symfony ranked some of the slowest.

0 comments voice your opinion now!
benchmark framework test apachebenchmark ab results

Link: http://systemsarchitect.net/performance-benchmark-of-popular-php-frameworks


Community Events











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


overview language opinion introduction application release framework symfony2 security package composer hack podcast install component unittest hhvm code example facebook

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