Files
Phraseanet/tests/Alchemy/Phrasea/Controller/Admin/FieldsTest.php
Romain Neutron 7c9bc6f358 Update tests
2012-05-22 20:02:11 +02:00

68 lines
2.2 KiB
PHP

<?php
require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.class.inc';
class ControllerFieldsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
protected $client;
public function createApplication()
{
return require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Admin.php';
}
public function setUp()
{
parent::setUp();
$this->client = $this->createClient();
}
/**
* Default route test
*/
public function testCheckMulti()
{
$appbox = \appbox::get_instance(\bootstrap::getCore());
$databox = array_shift($appbox->get_databoxes());
$tag = new PHPExiftool\Driver\Tag\IPTC\ObjectName();
$field = \databox_field::create($databox, "test" . time());
$field->set_tag($tag)->save();
$this->client->request("GET", "/fields/checkmulti/", array(
'source' => $tag->getTagname(), 'multi' => 'false'));
$response = $this->client->getResponse();
$this->assertEquals("application/json", $response->headers->get("content-type"));
$datas = json_decode($response->getContent());
$this->assertTrue(is_object($datas));
$this->assertTrue($datas->result);
$this->assertEquals($field->is_multi(), $datas->is_multi);
$field->delete();
}
public function testCheckReadOnly()
{
$appbox = \appbox::get_instance(\bootstrap::getCore());
$databox = array_shift($appbox->get_databoxes());
$tag = new PHPExiftool\Driver\Tag\IPTC\ObjectName();
$field = \databox_field::create($databox, "test" . time());
$field->set_tag($tag)->save();
$this->client->request("GET", "/fields/checkreadonly/", array(
'source' => $tag->getTagname(), 'readonly' => 'false'));
$response = $this->client->getResponse();
$this->assertEquals("application/json", $response->headers->get("content-type"));
$datas = json_decode($response->getContent());
$this->assertTrue(is_object($datas));
$this->assertTrue($datas->result);
$this->assertEquals($field->is_readonly(), $datas->is_readonly);
$field->delete();
}
}