mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-10 03:23:19 +00:00
Fix unit tests
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user