Refactor && Typo && Use plain objects as function parameters instead of ids

This commit is contained in:
Nicolas Le Goff
2014-02-06 12:42:47 +01:00
parent c98fe4c23d
commit 2ec4ffdbcc
39 changed files with 909 additions and 692 deletions

View File

@@ -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);
}
/**