databox = array_shift(self::$application['phraseanet.appbox']->get_databoxes()); } public function getSubdefName() { return 'testname' . time() . mt_rand(10000, 99999); } /** * Default route test */ public function testRouteGetSubdef() { $this->client->request("GET", "/admin/subdefs/" . $this->databox->get_sbas_id() . "/"); $this->assertTrue($this->client->getResponse()->isOk()); } public function testPostRouteAddSubdef() { $name = $this->getSubdefName(); $this->client->request("POST", "/admin/subdefs/" . $this->databox->get_sbas_id() . "/", array('add_subdef' => array( 'class' => 'thumbnail', 'name' => $name, 'group' => 'image' ))); $this->assertTrue($this->client->getResponse()->isRedirect()); $subdefs = new databox_subdefsStructure(new databox(self::$application, $this->databox->get_sbas_id())); $subdef = $subdefs->get_subdef("image", $name); $subdefs->delete_subdef('image', $name); } public function testPostRouteDeleteSubdef() { $subdefs = $this->databox->get_subdef_structure(); $name = $this->getSubdefName(); $subdefs->add_subdef("image", $name, "thumbnail"); $this->client->request("POST", "/admin/subdefs/" . $this->databox->get_sbas_id() . "/", array('delete_subdef' => 'image_' . $name)); $this->assertTrue($this->client->getResponse()->isRedirect()); try { $subdefs->get_subdef("image", $name); $this->fail("should raise an exception"); } catch (\Exception $e) { } } public function testPostRouteAddSubdefWithNoParams() { $subdefs = $this->databox->get_subdef_structure(); $name = $this->getSubdefName(); $subdefs->add_subdef("image", $name, "thumbnail"); $this->client->request("POST", "/admin/subdefs/" . $this->databox->get_sbas_id() . "/" , array('subdefs' => array( 'image_' . $name ) , 'image_' . $name . '_class' => 'thumbnail' , 'image_' . $name . '_downloadable' => 0 , 'image_' . $name . '_mediatype' => 'image' , 'image_' . $name . '_image' => array( 'size' => 400, 'resolution' => 83, 'strip' => 0, 'quality' => 90, )) ); $this->assertTrue($this->client->getResponse()->isRedirect()); $subdefs = new databox_subdefsStructure(new databox(self::$application, $this->databox->get_sbas_id())); $subdef = $subdefs->get_subdef("image", $name); /* @var $subdef \databox_subdef */ $this->assertFalse($subdef->is_downloadable()); $options = $subdef->getOptions(); $this->assertTrue(is_array($options)); $this->assertEquals(400, $options[\Alchemy\Phrasea\Media\Subdef\Image::OPTION_SIZE]->getValue()); $this->assertEquals(83, $options[\Alchemy\Phrasea\Media\Subdef\Image::OPTION_RESOLUTION]->getValue()); $this->assertEquals(90, $options[\Alchemy\Phrasea\Media\Subdef\Image::OPTION_QUALITY]->getValue()); $this->assertFalse($options[\Alchemy\Phrasea\Media\Subdef\Image::OPTION_STRIP]->getValue()); $subdefs->delete_subdef("image", $name); } }