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

SitePoint PHP Blog:
Stress-test your PHP App with ApacheBench
June 27, 2014 @ 12:55:58

In this recent post to the SitePoint PHP blog Bruno Skvorc looks at using a popular tool from the Apache project, Apache Bench (or just "ab") to stress-test your application.

There's no telling when your app might attract a throng of visitors at once. [...] Regardless of the reason, massive influxes of visitors are a double-edged sword: they get you what you always wanted - a chance to prove your worth to a large chunk of the internet's population - but also often bring with them what you always feared: absolute downtime. [Some] platforms usually offer plugins that can optimize your application while it's up, so you can fine tune it as you go along, but why not try and predict issues while still developing locally and save yourself time, money and effort in the long run?

He bases the testing off of a Laravel Homestead virtual machine instance and tests a simple "hello world" PHP page to minimize any overhead from other processing. He includes the commands to make a simple ab request and mentions the kinds of request it provides on completion. He moves on from there to something a bit more complex - an actual Laravel-based application using the default "HomeController" and "showWelcome" action/view combination.

0 comments voice your opinion now!
apache bench ab tutorial laravel homestead stress test

Link: http://www.sitepoint.com/stress-test-php-app-apachebench/

PHP.net:
PHP 5.6.0RC1 is available
June 20, 2014 @ 09:09:28

On the PHP.net site a new announcement has been posted about the release of PHP 5.6.0RC1, the first release candidate in the PHP 5.6.0 series.

The PHP development team announces the immediate availability of the first release candidate of PHP 5.6. As we entered the feature freeze with beta1, this is a bugfix-only release. All users of PHP are encouraged to test this version carefully, and report any bugs in the bug tracking system.

As this is a release candidate, it is not valid for production use but any testing that can be done is appreciated. There's several new features coming in PHP 5.6 including constant scalar expressions, variadic functions, argument unpacking, "use const"/"use func" and many more. Check out this page in the manual for full details and code example of each. As always, you can download this preview release from the QA downloads page or here for the Windows binaries.

0 comments voice your opinion now!
php56rc1 language release candidate features download test

Link: http://www.php.net/archive/2014.php#id2014-06-19-1

Rami Alnawas:
How to unit test code with Phalcon MVC Models
April 29, 2014 @ 11:57:39

Rami Alnawas has posted an interesting tutorial for the Phalcon users out there showing one way you can unit test your models. It's based on his own experience with the framework in a current project.

My first contribution to the PHP community in general, and Phalcon folks in particular, was the introduction of MVC Functional Testing with PHPUnit, this meant that Applications developed using Phalcon Framework could be unit tested by requesting a url then asserting that the response is handled by a specific action within the controller. [...] To date, my latest addition is an example of how to unit test code that utilises Phalcon models, mainly the various static find methods. The code is available on github and the coverage report is coveralls.io.

He shows it at work, creating a simple "Popup" model and a facade to help with making instances for testing. He also includes the code to test this facade, checking the results of methods like "fetchall", "select" and "execute".

0 comments voice your opinion now!
phalcon framework unit test coverage mvc model tutorial

Link: http://www.rami.me.uk/how-to-unit-test-code-with-phalcon-mvc-models

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


Community Events





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


unittest language opinion code series threedevsandamaybe interview introduction release community wordpress laravel install developer podcast refactor list framework api testing

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