Fix unit tests

This commit is contained in:
Romain Neutron
2013-01-28 19:31:26 +01:00
parent 2fb0c60157
commit aa18c48306
43 changed files with 582 additions and 256 deletions

View File

@@ -73,6 +73,8 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
self::generateRecords($application);
self::$DI['user']->set_email('valid@phraseanet.com');
self::$updated = true;
}
}
@@ -103,8 +105,9 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
\PHPUnit_Framework_Error_Warning::$enabled = true;
\PHPUnit_Framework_Error_Notice::$enabled = true;
$phpunit = $this;
self::$DI['app'] = self::$DI->share(function($DI) {
self::$DI['app'] = self::$DI->share(function($DI) use ($phpunit) {
$environment = 'test';
$app = require __DIR__ . '/../../lib/Alchemy/Phrasea/Application/Root.php';
@@ -124,6 +127,15 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
return $browser;
}));
$app['notification.deliverer'] = $this->getMockBuilder('Alchemy\Phrasea\Notification\Deliverer')
->disableOriginalConstructor()
->getMock();
$app['notification.deliverer']->expects($this->any())
->method('deliver')
->will($this->returnCallback(function() use ($phpunit){
$phpunit->fail('Notification deliverer must be mocked');
}));
return $app;
});
@@ -873,4 +885,15 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
$this->assertTrue(is_array($data));
$this->assertFalse($data['success']);
}
protected function mockNotificationDeliverer($expectedMail, $qty = 1, $receipt = null)
{
self::$DI['app']['notification.deliverer'] = $this->getMockBuilder('Alchemy\Phrasea\Notification\Deliverer')
->disableOriginalConstructor()
->getMock();
self::$DI['app']['notification.deliverer']->expects($this->exactly($qty))
->method('deliver')
->with($this->isInstanceOf($expectedMail), $this->equalTo($receipt));
}
}