Slim 2, slim.flash, Mustache templates and PHPUnit

Working on a project which used Slim 2 and Mustache templates.

To unit test flash messages (we used an intermediary class, to inject data into the Mustache templates)

$this->app = new \Slim\Slim();
$this->app->environment['slim.flash'] = new \Slim\Middleware\Flash();


public function testFlashMessagesAreReturnedWhenOneAdded()
    $this->app->flashNow('info', ['type' => 'info', 'message' => __FUNCTION__]);
    $dataBuilder = new DataBuilder($this->app, 'Test');
    $data = $dataBuilder->getData();
    $this->assertNotEmpty($data->flash, 'Flash messages were not returned from databuilder get data though one was added');
Show Comments