mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-24 10:23:17 +00:00
Refactor && Typo && Use plain objects as function parameters instead of ids
This commit is contained in:
@@ -11,29 +11,11 @@ class PreferencesTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
*/
|
||||
public function testSaveUserPref()
|
||||
{
|
||||
self::$DI['app']['authentication']->setUser($this->getMockBuilder('Alchemy\Phrasea\Model\Entities\User')
|
||||
->setMethods(['addSetting'])
|
||||
->disableOriginalConstructor()
|
||||
->getMock());
|
||||
|
||||
self::$DI['app']['manipulator.user'] = $this->getMockBuilder('Alchemy\Phrasea\Model\Manipulator\User')
|
||||
->setMethods(['setUserSetting'])
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
self::$DI['app']['manipulator.user']->expects($this->once())
|
||||
->method('setUserSetting')
|
||||
->with($this->isInstanceOf('Alchemy\Phrasea\Model\Entities\User'), $this->equalTo('prop_test'), $this->equalTo('val_test'))
|
||||
->will($this->returnValue(null));
|
||||
|
||||
$this->XMLHTTPRequest('POST', '/user/preferences/', ['prop' => 'prop_test', 'value' => 'val_test']);
|
||||
$response = self::$DI['client']->getResponse();
|
||||
$this->assertTrue($response->isOk());
|
||||
$datas = (array) json_decode($response->getContent());
|
||||
$this->assertArrayHasKey('success', $datas);
|
||||
$this->assertTrue($datas['success']);
|
||||
$this->assertArrayHasKey('message', $datas);
|
||||
unset($response, $datas);
|
||||
$this->assertTrue(json_decode($response->getContent())->success);
|
||||
$this->assertEquals('val_test', self::$DI['app']['settings']->getUserSetting(self::$DI['user'], 'prop_test'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -64,11 +46,8 @@ class PreferencesTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
$this->XMLHTTPRequest('POST', "/user/preferences/temporary/", ['prop' => 'prop_test', 'value' => 'val_test']);
|
||||
$response = self::$DI['client']->getResponse();
|
||||
$this->assertTrue($response->isOk());
|
||||
$datas = (array) json_decode($response->getContent());
|
||||
$this->assertArrayHasKey('success', $datas);
|
||||
$this->assertTrue($datas['success']);
|
||||
$this->assertTrue(json_decode($response->getContent())->success);
|
||||
$this->assertEquals('val_test', self::$DI['app']['session']->get('phraseanet.prop_test'));
|
||||
unset($response, $datas);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user