Joseph Scott

PHP Testing With Pest


When I started work on Marmerine I was going to reach for PHPUnit for testing. Then I came across Pest. I really like the minimal approach to writing tests.

For example, here is one test for the Memcached set command:

test( 'set', function() {
$key = 'thing';
$value = 'abc';

$result = MC::$mc->set( $key, $value );
$this->assertEquals( true, $result );

$result = MC::$mc->get( $key );
$this->assertEquals( $value, $result );
} );

The MC class is included as part of the Pest setup.

Pest is built on top of PHPUnit, so a lot of this might feel like syntatic sugar on top of an existing solid base. That is fine with me.