Labelize collections

This commit is contained in:
Romain Neutron
2013-05-30 20:00:14 +02:00
parent 55a6469aa4
commit c084f20f85
37 changed files with 301 additions and 61 deletions

View File

@@ -353,6 +353,26 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->assertTrue(self::$DI['client']->getResponse()->isRedirect());
}
/**
* @covers Alchemy\Phrasea\Controller\Admin\Bas::labels
*/
public function testPostLabelsNotJson()
{
$this->setAdmin(true);
$collection = $this->createOneCollection();
self::$DI['client']->request('POST', '/admin/collection/' . $collection->get_base_id() . '/labels/', array(
'labels' => array(
'en' => 'english label',
'fr' => 'french label',
'ru' => 'russian label',
)
));
$this->assertTrue(self::$DI['client']->getResponse()->isRedirect());
}
/**
* @covers Alchemy\Phrasea\Controller\Admin\Bas::rename
*/
@@ -365,6 +385,18 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->assertForbiddenResponse(self::$DI['client']->getResponse());
}
/**
* @covers Alchemy\Phrasea\Controller\Admin\Bas::labels
*/
public function testPostLabelsUnauthorizedException()
{
$this->setAdmin(false);
self::$DI['client']->request('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/labels/');
$this->assertForbiddenResponse(self::$DI['client']->getResponse());
}
/**
* @covers Alchemy\Phrasea\Controller\Admin\Bas::rename
*/
@@ -376,6 +408,17 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->assertXMLHTTPBadJsonResponse(self::$DI['client']->getResponse());
}
/**
* @covers Alchemy\Phrasea\Controller\Admin\Bas::labels
*/
public function testPostLabelsBadRequestMissingArguments()
{
$this->setAdmin(true);
$this->XMLHTTPRequest('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/labels/');
$this->assertXMLHTTPBadJsonResponse(self::$DI['client']->getResponse());
}
/**
* @covers Alchemy\Phrasea\Controller\Admin\Bas::rename
*/
@@ -396,6 +439,35 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$collection->delete();
}
/**
* @covers Alchemy\Phrasea\Controller\Admin\Bas::labels
*/
public function testPostLabels()
{
$this->setAdmin(true);
$collection = $this->createOneCollection();
$this->XMLHTTPRequest('POST', '/admin/collection/' . $collection->get_base_id() . '/labels/', array(
'labels' => array(
'nl' => 'netherlands label',
'de' => 'german label',
'fr' => 'label français',
'en' => 'label à l\'anglaise',
'ru' => 'label à la russe',
)
));
$json = $this->getJson(self::$DI['client']->getResponse());
$this->assertTrue($json->success);
$this->assertEquals($collection->get_label('de'), 'german label');
$this->assertEquals($collection->get_label('nl'), 'netherlands label');
$this->assertEquals($collection->get_label('fr'), 'label français');
$this->assertEquals($collection->get_label('en'), 'label à l\'anglaise');
$collection->unmount_collection(self::$DI['app']);
$collection->delete();
}
/**
* @covers Alchemy\Phrasea\Controller\Admin\Bas::emptyCollection
*/