Automatically rerun PHPUnit tests when source code changes with phpunit-watcher

Nice new package by Freek from Spatie.be. Think of it like Jest, but for PHP: Wouldn’t it be great if your PHPUnit tests would be automatically rerun whenever you change some code? This package can do exactly that. By default it will watch all files in the src, app and tests subdirectories in the directory …

Snapshot testing with PHPUnit

use Spatie\Snapshots\MatchesSnapshots; class OrderTest { use MatchesSnapshot; class test_it_casts_to_json() { $orderId = new Order(1); $this->assertMatchesJsonSnapshot($order->toJson()); } } Again great work by the folks at Spatie: The difference between a classic assertEquals and an assertMatchesSnapshot is that you don’t write the expectation yourself when snapshot testing. When a snapshot assertion happens for the first time, it …

Jest – Painless JavaScript Testing

I’ve been hearing great things about Jest lately. It’s worth checking it out: Jest is a JavaScript testing framework, used by Facebook to test all JavaScript code including React applications. Install Jest using npm (along with some extra Babel presets if you’re writing ES2015 – Don’t forget to configure Babel using .babelrc to use the …

Extract Till You Drop

Under the pressure of deadlines and endless change requests, under the weight of years of legacy, code becomes unmaintainable. With the right tools, techniques, and mindset, any codebase can be brought under test, and be refactored towards a better architecture. Let’s skip the theory and dive straight into the spaghetti code. In a live coding …

phpspec

phpspec is a development tool, designed to help you achieve clean and working PHP code by using a technique derived from test-first development called (spec) behaviour driven development, or SpecBDD. Example spec file: <?php namespace spec; use PhpSpec\ObjectBehavior; class MarkdownSpec extends ObjectBehavior { function it_converts_plain_text_to_html_paragraphs() { $this->toHtml("Hi, there")->shouldReturn("<p>Hi, there</p>"); } } Running it is easy: …

Huxley – Catching visual regressions in Web applications.

This content is quite old. You might want to check out this modern way of visual diffing, using Puppeteer instead Watches you browse, takes screenshots, tells you when they change. First you record a basic flow and take screenshots in between. Afterwards, when you’ve done some changes, you can let the flow play back again, …

Wraith – A responsive screenshot comparison tool

This content is quite old. You might want to check out this modern way of visual diffing, using Puppeteer instead Wraith uses either PhantomJS, CasperJS or SlimerJS to create screen-shots of webpages on different environments and then creates a diff of the two images, the affected areas are highlighted in blue By the folks over …

DummyJS – Smart Functional Testing extension for PhantomJS

open http://my.test.site type :text John click “Say hi!” assertText .greeting Hi, John! $ dummyjs mytest.dummy ✓ open http://my.test.site ✓ type :text John ✓ click “Say hi!” ✓ assertText .greeting Hi, John! PASS: Executed 4 actions in 1s. DummyJS makes writing and running automated functional tests for websites and webapps incredibly easy. Tests can be run …

PHP and Continuous Integration with Travis CI

Travis CI automatically sets up a CI environment and makes it simple for anyone to test and deploy their app. Their build system supports many different languages, you just have to define which language this project is and Travis CI will take care of the rest Good article by Sitepoint on getting started with Travis …

bramus/router Updates

It’s been 4 months since I released bramus/router, the lightweight and object oriented PHP Router I wrote. Since then a few new features worth mentioning were added. Subrouting Support It’s now possible to mount several routes onto a base route. Think of creating a /movies route on which you attach a callable which in its …