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

Jumpstart Your PHP Testing with Codeception
May 26, 2016 @ 12:41:35

The Toptal.com blog has posted a new tutorial that wants to help you make the most of your application via testing. They show you how to use Codeception to create a set of tests to ensure your application is working as expected.

Before moving on to Codeception and PHP, we should cover the basics and start by explaining why we need testing in applications in the first place. Perhaps we could complete a project without wasting time on tests, at least this time?

Sure, you don’t need tests for everything; for example, when you want to build yet another homepage. [...] However, you definitely do need testing when: your team uses BDD/TDD, your Git repo contains more than a couple commits, [and] you are a proper professional, working on a serious project.

They start with a look at the kinds of things testing solves in your development process and the different kinds of tests you can create. From there they introduce Codeception, an alternative testing tool to the widely used PHPUnit. The tutorial helps you get it installed and shows you how to make a simple, first test. It helps you execute the test, debug issues that might pop up and the different assertions you can use. With the fundamentals in place, they move on to more details on using it for functional and unit testing.

tagged: jumpstart testing codeception tutorial functional unit

Link: https://www.toptal.com/php/php-testing-with-codeception

Acceptance Testing a Laravel and Vue.js Application
May 20, 2016 @ 11:57:28

Mohamed Said has written up an article about acceptance testing a Laravel+Vue.js application with the help of the Selenium WebDriver functionality.

The good thing about writing tests at a mature stage of the project is that many of the basic parts of the application are settled down, major changes have slowed, so deciding the shape of tests can happen in a more solid way. Testing too early, in my opinion, leads to the need of changing tests whenever you change functionality, so it’s work * 2.

This post is about a single type of tests and I think it’s the most interesting one.

He starts with a brief description of what acceptance testing is for those not familiar with the concept. He then gets to the Selenium WebDriver, provides a summary on that as well and points out the main tool they use for their tests: the Javascript driver it provides. the syntax on the driver is a bit difficult to follow so they also suggest layering Nightwatch.js on top to make for simpler, cleaner and easier to read tests. There's also information and (acceptance) testing the backend of the application with various tools, ultimately deciding on the use of Codeception.

tagged: acceptance testing larvel vuejs selenium webdriver nightwatchjs codeception

Link: https://dotdev.co/acceptance-testing-a-laravel-and-vue-js-application-4160b8e96156#.vdxu8in7i

Paul Jones:
When Possible, Use File *Resources* Instead Of File *Names*
May 13, 2016 @ 10:37:38

In this new post to his site Paul Jones makes a recommendation to those working with files and other resources: pass around the resources themselves (the streams) not filenames.

In testing the Aura.Http package, I have realized that it’s much more flexible, testing wise, to pass around file resources (a.k.a. handles, pointers, or streams) than it is to pass around file names. When you do that, you can use a php://memory stream instead of attempting to touch the file system. [...] This places control of the file creation in your hands directly, not under the control of the system under test.

He gives examples based on some testing of one of his own packages where he needed to swap out the resource being tested and mock out a file system call. It's a simple trick but could help reduce some complexity in your overall code in the right situations.

tagged: file resource name unittest testing aurahttp

Link: http://paul-m-jones.com/archives/2487

Free the Geek:
Episode 16 - Talking Testing and Building YOUR Dream with Chris Hartjes
Apr 20, 2016 @ 09:13:51

The Free the Geek podcast, hosted by Matthew Setter, has posted their latest episode (#16), a chat with Chris Hartjes about testing and "building your dream" based on some of his own experiences.

In this episode I chat with Chris Hartjes, the Grumpy Programmer himself, about the ins and outs of testing and what it’s like to spend part of your working week building your dreams, instead of someone else’s.

Amongst the talk on testing, we cover a range of interesting points, such as monkey patching, mutation testing, and how TDD is more a design process than anything else. When it comes to building your dream, Chris shares some personal insights in to what prompted him to build grumpy learning, and who some of his greatest mentors have been.

You can listen to this latest episode either through the in-page audio player or by downloading the mp3 of the show for listening at your leisure. If you enjoy the show be sure to subscribe to their feed and follow them on Twitter for more updates when new shows are released.

tagged: freethegeekpodcast ep16 chrishartjes testing dream community interview

Link: http://freethegeek.fm/episode/episode-0016

Adam Culp:
Setting up step debugging in Zend Studio
Apr 11, 2016 @ 11:52:43

Adam Culp has posted a guide on his site showing you how to set up debugging in Zend Studio, the PHP IDE from Zend. In it he walks you through the setup on both the server and client side to get them working happily together.

Recently I was helping someone set up step debugging in Zend Studio, and had some difficulties. Therefore I decided to create a blog post to remind me later, and perhaps help others get it set up.

I was doing this on an Ubuntu laptop, so while menus may vary slightly the process should be very similar. Also, I did this using a local virtual machine in VirtualBox, but using Bridged networking mode to simulate a remote server. In Zend Studio I had a project created with the Zend Framework Skeleton Application, and created a virtualhost in the virtual environment that mirrored that.

He starts with the server, pointing out that the only thing really needed there is an installed and working version of Xdebug. He then goes through each step in the IDE, complete with screenshots:

  • Configuring the server in the Preferences
  • Testing the connection between the two
  • Enabling debugging on the project
  • Ensuring the server is configured correctly to use debugging when specified

While some of his instructions are more specific to a Zend Server installation, they can still be mostly applied to any kind of system. You can also check the Xdebug documentation for additional help.

tagged: debugging zendstudio guide zendserver configuration testing xdebug

Link: http://www.geekyboy.com/archives/1220

SitePoint PHP Blog:
Crash Course into Continuous Testing with Sismo
Mar 29, 2016 @ 12:03:54

On the SitePoint PHP blog there's a tutorial posted helping you get started with Sismo, a simple component that can help you with the continuous testing of your PHP applications. Sismo is a project from SensioLabs, the same group behind Symfony and Twig (and several other popular tools).

The PHP community started to adopt the testing culture relatively recently. Despite there being some debates on how to achieve this, nobody can argue the importance of having your code fully covered by tests. In this article, we’re going to explore a tool that will help you in a major part of the testing culture called continuous testing.

Sismo is a small component which you can easily integrate with your projects to make the process of continuous testing easier. Sismo's main focus is to run your tests and send you status notifications.

They help you get the tool installed (either from GitHub or directly) and configure your project with a simple PHP file. They also include instructions on how to execute the tests for the project and an example of the resulting output. The tutorial then shows how to set up a project using the remote repository handling, setting up notifiers for failures, storing the build information and using it in a git hook.

tagged: continuous testing sismo sensiolabs tutorial setup configuration phpunit test

Link: http://www.sitepoint.com/continuous-testing-with-sismo/

Jeff Geerling:
Yes, Drupal 8 is slower than Drupal 7 - here's why
Mar 25, 2016 @ 12:05:44

Jeff Geerling has an interesting post to his site showing the results of some of his own testing around the performance of Drupal 8 versus Drupal 7...and that 8 comes out to be slower than 7. He also includes some of the things that the Drupal project is doing to help the situation.

When some people see reports of Drupal 8 being 'dramatically' slower than Drupal 7, they wonder why, and they also use this performance change as ammunition against some of the major architectural changes that were made during Drupal 8's development cycle.

First, I wanted to give some more concrete data behind why Drupal 8 is slower (specifically, what kinds of things does Drupal 8 do that make it take longer per request than Drupal 7 on an otherwise-identical system), and also why this might or might not make any difference in your choice to upgrade to Drupal 8 sooner rather than later.

He shares the results of some of his own benchmarking on a cluster (bramble) of Raspberry Pis for the requests per second on the standard setup for each version. He includes the output from an XHProf profiling run too, showing the large call stack on both sides, not just Drupal 8. He then talks about some of the Drupal 8 updates that are included to help mitigate some of these issues: architecture changes, easier caching, authenticated user handing and slow loading content management.

tagged: drupal8 drupal7 performance raspberrypi cluster testing results benchmark

Link: http://www.jeffgeerling.com/blog/2016/yes-drupal-8-slower-drupal-7-heres-why

Marcel Pociot:
Laravel TestTools (Chrome Extension)
Mar 22, 2016 @ 10:48:10

Marcel Pociot has a new post on his site introducing a new tool he's created allowing for the easier creation of tests for your Laravel application: the TestTools Chrome extension.

Testing a Laravel application really is an easy task - the "Integrated" package from Jeffrey Way, that later got merged into the core framework is fantastic and helps you with the otherwise cumbersome task of testing and interacting with your application. But still - are you actually using tests?

A lot of times people really love the idea of tests, but simply don't get their asses up to start using them in their own projects. That's why I created a chrome extension that hopefully saves you some time when you need to test your app

He also includes an animation or two of the Chrome extension in action, showing you what kind of results you can expect. He does point out that there's some limitations of the tool including the fact that you can't really test a single-page application with it as it relies on the normal browser interaction points, not Javascript events.

tagged: laravel testing unittest chrome extension browser

Link: http://marcelpociot.com/blog/2016-03-21-laravel-testtools

Rob Allen:
Testing Slim Framework actions
Mar 14, 2016 @ 10:45:52

Rob Allen has a quick post to his site showing you how to test Slim actions using PHPUnit and some simple pieces of the Slim framework itself to set up the needed environment.

To test a Slim Framework action, you need a request and a response object and mock whatever is in the action. This is one way to do this.

He gives an example of a simple endpoint that just returns a JSON string. He shows the code for this endpoint and how it registers with the application for an /echo route. He then gets in to the testing on the route's matching class, making an instance of the Request class and an Environment for it to work in. He ends the post by sharing teh code to pull all of these pieces together in a simple PHPUnit test that uses the assertSame assertion to verify the JSON response output.

tagged: slimframework action unittest phpunit testing tutorial request environment

Link: https://akrabat.com/testing-slim-framework-actions/

Full Stack Radio:
37: Chris Hartjes - Getting Started with Testing
Mar 09, 2016 @ 13:22:10

The Full Stack Radio podcast has posted their latest episode, Episode #37, featuring an interview with Chris Hartjes, most well known for his promotion and teaching about writing tests (unit, functional, integration, etc) for your applications.

n this episode, Adam talks to the Grumpy Programmer himself about getting started with testing PHP applications.

Topics include: recommended testing tools, PHPUnit vs. phpspec, Mockery vs. Prophecy, the benefits of defensive programming and how to convince your manager to let you write tests.

They also mention Chris' new book "Minimum Viable Tests" and the Patchwork monkey patching library. You can listen to this latest episode either using the in-page audio player or by downloading the mp3 of the episode directly. Be sure to subscribe to their feed or follow them on Twitter for more information as new episodes are released.

tagged: fullstackradio chrishartjes testing gettingstarted tools defensive programming manager

Link: http://www.fullstackradio.com/37