mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-24 10:23:17 +00:00
Refactor tests to use $this->getApplication().
Move LoginTest specific use case into LoginTest class
This commit is contained in:
@@ -1961,4 +1961,19 @@ class LoginTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
self::$DI['app']['registration.manager'] = $managerMock;
|
self::$DI['app']['registration.manager'] = $managerMock;
|
||||||
self::$DI['app']['registration.manager']->expects($this->any())->method('isRegistrationEnabled')->will($this->returnValue(false));
|
self::$DI['app']['registration.manager']->expects($this->any())->method('isRegistrationEnabled')->will($this->returnValue(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function mockNotificationsDeliverer(array &$expectedMails)
|
||||||
|
{
|
||||||
|
$app = $this->getApplication();
|
||||||
|
$app['notification.deliverer'] = $this->getMockBuilder('Alchemy\Phrasea\Notification\Deliverer')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
|
||||||
|
$app['notification.deliverer']->expects($this->any())
|
||||||
|
->method('deliver')
|
||||||
|
->will($this->returnCallback(function ($email, $receipt) use (&$expectedMails) {
|
||||||
|
$this->assertTrue(isset($expectedMails[get_class($email)]));
|
||||||
|
$expectedMails[get_class($email)]++;
|
||||||
|
}));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -686,38 +686,26 @@ abstract class PhraseanetTestCase extends WebTestCase
|
|||||||
|
|
||||||
protected function mockNotificationDeliverer($expectedMail, $qty = 1, $receipt = null)
|
protected function mockNotificationDeliverer($expectedMail, $qty = 1, $receipt = null)
|
||||||
{
|
{
|
||||||
self::$DI['app']['notification.deliverer'] = $this->getMockBuilder('Alchemy\Phrasea\Notification\Deliverer')
|
$app = $this->getApplication();
|
||||||
|
$app['notification.deliverer'] = $this->getMockBuilder('Alchemy\Phrasea\Notification\Deliverer')
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
|
|
||||||
self::$DI['app']['notification.deliverer']->expects($this->exactly($qty))
|
$app['notification.deliverer']->expects($this->exactly($qty))
|
||||||
->method('deliver')
|
->method('deliver')
|
||||||
->with($this->isInstanceOf($expectedMail), $this->equalTo($receipt));
|
->with($this->isInstanceOf($expectedMail), $this->equalTo($receipt));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function mockNotificationsDeliverer(array &$expectedMails)
|
|
||||||
{
|
|
||||||
self::$DI['app']['notification.deliverer'] = $this->getMockBuilder('Alchemy\Phrasea\Notification\Deliverer')
|
|
||||||
->disableOriginalConstructor()
|
|
||||||
->getMock();
|
|
||||||
|
|
||||||
self::$DI['app']['notification.deliverer']->expects($this->any())
|
|
||||||
->method('deliver')
|
|
||||||
->will($this->returnCallback(function ($email, $receipt) use (&$expectedMails) {
|
|
||||||
$this->assertTrue(isset($expectedMails[get_class($email)]));
|
|
||||||
$expectedMails[get_class($email)]++;
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function mockUserNotificationSettings($notificationName, $returnValue = true)
|
protected function mockUserNotificationSettings($notificationName, $returnValue = true)
|
||||||
{
|
{
|
||||||
if (false === self::$DI['app']['settings'] instanceof \PHPUnit_Framework_MockObject_MockObject) {
|
$app = $this->getApplication();
|
||||||
self::$DI['app']['settings'] = $this->getMockBuilder('Alchemy\Phrasea\Core\Configuration\DisplaySettingService')
|
if (false === $app['settings'] instanceof \PHPUnit_Framework_MockObject_MockObject) {
|
||||||
|
$app['settings'] = $this->getMockBuilder('Alchemy\Phrasea\Core\Configuration\DisplaySettingService')
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
}
|
}
|
||||||
|
|
||||||
self::$DI['app']['settings']
|
$app['settings']
|
||||||
->expects($this->any())
|
->expects($this->any())
|
||||||
->method('getUserNotificationSetting')
|
->method('getUserNotificationSetting')
|
||||||
->with(
|
->with(
|
||||||
@@ -726,7 +714,7 @@ abstract class PhraseanetTestCase extends WebTestCase
|
|||||||
)
|
)
|
||||||
->will($this->returnValue($returnValue));
|
->will($this->returnValue($returnValue));
|
||||||
|
|
||||||
self::$DI['app']['setting'] = 'toto';
|
$app['setting'] = 'toto';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createGeneratorMock()
|
public function createGeneratorMock()
|
||||||
|
|||||||
Reference in New Issue
Block a user