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

Imagine Easy Solutions Blog:
Testing Logging in Silex
November 12, 2014 @ 11:34:50

On the Imagine Easy Solutions blog Yitzchak Schaffer talks some about logging in Silex by making use of a MonologServiceProvider. You can find the end result of his setup in this GitHub repository.

Silex is a PHP microframework from the same family as Symfony. My shop, Imagine Easy Solutions, uses Silex for some of our most important applications. Modular setup is at the core of Silex's game, by means of Service Providers. The MonologServiceProvider makes it easy to add highly configurable logging to your application. But how to test your logging? It turns out that this Service Provider includes a DebugHandler which you can use to make log entries available in array form.

He walks you through the integration of the service provider via a "debug handler" and configuring it in the setup method. He also includes an "assertLogEntry" method to evaluate the current logs and check to ensure an entry was made. Finally, he puts it to use via a "notOk" method.

0 comments voice your opinion now!
test logging silex serviceprovider monolog tutorial

Link: http://dev.imagineeasy.com/post/102394035784/testing-logging-in-silex

Matthew Weier O'Phinney:
Testing Code That Emits Output
August 25, 2014 @ 09:45:08

In this latest post to his site Matthew Weier O'Phinney gives his suggestion on how to test (unit test) code that provides some kind of direct output. In his case, his script is outputting header information directly, not as a part of a response string.

Here's the scenario: you have code that will emit headers and content, for instance, a front controller. How do you test this? The answer is remarkably simple, but non-obvious: namespaces.

He talks some about the use of namespaces in PHP classes (and methods, and constants...) and how things can be importing using them. He gives an example of an object that outputs some header and body information (an "Output" abstract class). He shows how to use the class in a simple test, calling "reset" in the setup and teardown methods and asserting the contents of the headers and body for expected content.

0 comments voice your opinion now!
test unittest code phpunit output direct namespace tutorial

Link: http://mwop.net/blog/2014-08-11-testing-output-generating-code.html

PHP.net:
PHP 5.6.0RC4 is available
August 15, 2014 @ 10:58:13

The PHP development group has announced the release of the latest Release Candidate in the PHP 5.6.x series - PHP 5.6.0RC4. This is a not-for-production release of 5.6 prior to the stable version being released.

The PHP development team announces the immediate availability of the fourth and hopefully lates release candidate of PHP 5.6.0. 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.

This latest release candidate includes changes related to the Fileinfo handling, GD functionality, an OpenSSL socket issue and many more. You can download this latest release from the QA downloads page (or here for Windows users).

0 comments voice your opinion now!
language release releasecandidate php56 test bugfix

Link: http://php.net/index.php#id2014-08-14-2

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


Community Events





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


interview install version community library podcast tool composer release laravel package opinion language symfony framework security introduction voicesoftheelephpant series update

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