diff --git a/lib/classes/setup.class.php b/lib/classes/setup.class.php index f84f62e523..162b0d5af3 100644 --- a/lib/classes/setup.class.php +++ b/lib/classes/setup.class.php @@ -43,6 +43,8 @@ class setup , "xml" , "zip" , "zlib" + , "intl" + , "twig" ); protected static $PHP_CONF = array( 'output_buffering' => '4096' //INI_ALL @@ -570,10 +572,18 @@ class setup { if (extension_loaded($ext) !== true) { - $constraints[] = new Setup_Constraint(sprintf('Extension %s', $ext), false, sprintf('%s missing', $ext), true); + $blocker = true; + if("twig" === $ext) + { + $blocker = false; + } + + $constraints[] = new Setup_Constraint(sprintf('Extension %s', $ext), false, sprintf('%s missing', $ext), $blocker); } else - $constraints[] = new Setup_Constraint(sprintf('Extension %s', $ext), true, sprintf('%s loaded', $ext), true); + { + $constraints[] = new Setup_Constraint(sprintf('Extension %s', $ext), true, sprintf('%s loaded', $ext)); + } } return new Setup_ConstraintsIterator($constraints); diff --git a/lib/unitTest/Alchemy/Phrasea/Controller/Admin/DescriptionTest.php b/lib/unitTest/Alchemy/Phrasea/Controller/Admin/DescriptionTest.php index 46f666b578..e558a25265 100644 --- a/lib/unitTest/Alchemy/Phrasea/Controller/Admin/DescriptionTest.php +++ b/lib/unitTest/Alchemy/Phrasea/Controller/Admin/DescriptionTest.php @@ -42,22 +42,247 @@ class DescriptionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract /** * Default route test */ - public function testRouteSlash() + public function testRouteDescription() { - $this->markTestIncomplete(); - $appbox = appbox::get_instance(); $databox = array_shift($appbox->get_databoxes()); - $fields = $databox->get_meta_structure(); + $name = "testtest" . uniqid(); + $field = \databox_field::create($databox, $name); + $id = $field->get_id(); + $this->client->request("POST", "/description/" . $databox->get_sbas_id() . "/", array( + 'field_ids' => array($id) + , 'name_' . $id => $name + , 'multi_' . $id => 1 + , 'indexable_' . $id => 1 + , 'src_' . $id => '/rdf:RDF/rdf:Description/IPTC:SupplementalCategories' + , 'required_' . $id => 0 + , 'readonly_' . $id => 0 + , 'type_' . $id => 'string' + , 'vocabulary_' . $id => 'User' + , 'regname' => $id + , 'regdate' => $id + , 'regdesc' => $id + )); - $fieldIds = array(); - - foreach($fields as $field) - { - $fieldIds[] = $field->get_id(); - } - - $this->client->request("POST", "/description/" . $databox->get_sbas_id()); + $this->assertTrue($this->client->getResponse()->isRedirect()); + $field->delete(); } + public function testPostDelete() + { + $appbox = appbox::get_instance(); + $databox = array_shift($appbox->get_databoxes()); + $name = "test" . uniqid(); + $field = \databox_field::create($databox, $name); + $id = $field->get_id(); + + $this->client->request("POST", "/description/" . $databox->get_sbas_id() . "/", array( + 'todelete_ids' => array($id) + )); + + $this->assertTrue($this->client->getResponse()->isRedirect()); + + try + { + $field = \databox_field::get_instance($databox, $id); + $field->delete(); + $this->fail("should raise an exception"); + } + catch (\Exception $e) + { + + } + } + + public function testPostCreate() + { + $appbox = appbox::get_instance(); + $databox = array_shift($appbox->get_databoxes()); + + $name = 'test' . uniqid(); + + $this->client->request("POST", "/description/" . $databox->get_sbas_id() . "/", array( + 'newfield' => $name + )); + + $this->assertTrue($this->client->getResponse()->isRedirect()); + + $fields = $databox->get_meta_structure(); + $find = false; + + foreach ($fields as $field) + { + if ($field->get_name() === databox_field::generateName($name)) + { + $field->delete(); + $find = true; + } + } + + if (!$find) + { + $this->fail("should have create a new field"); + } + } + + public function testPostDescriptionException() + { + $appbox = appbox::get_instance(); + $databox = array_shift($appbox->get_databoxes()); + + $this->client->request("POST", "/description/" . $databox->get_sbas_id() . "/", array( + 'todelete_ids' => array('unknow_id') + )); + + $this->assertTrue($this->client->getResponse()->isRedirect()); + + $name = "test" . uniqid(); + $field = \databox_field::create($databox, $name); + $id = $field->get_id(); + $this->client->request("POST", "/description/" . $databox->get_sbas_id() . "/", array( + 'field_ids' => array($id) + , 'name_' . $id => $name + , 'multi_' . $id => 1 + , 'indexable_' . $id => 1 + , 'src_' . $id => '/rdf:RDF/rdf:Description/IPTC:SupplementalCategories' + , 'required_' . $id => 0 + , 'readonly_' . $id => 0 + , 'type_' . $id => 'string' + , 'vocabulary_' . $id => 'Unknow_Vocabulary' + , 'regname' => $id + , 'regdate' => $id + , 'regdesc' => $id + )); + + $this->assertTrue($this->client->getResponse()->isRedirect()); + $field->delete(); + + $name = "test" . uniqid(); + $field = \databox_field::create($databox, $name); + $id = $field->get_id(); + $this->client->request("POST", "/description/" . $databox->get_sbas_id() . "/", array( + 'field_ids' => array($id) + , 'multi_' . $id => 1 + , 'indexable_' . $id => 1 + , 'src_' . $id => '/rdf:RDF/rdf:Description/IPTC:SupplementalCategories' + , 'required_' . $id => 0 + , 'readonly_' . $id => 0 + , 'type_' . $id => 'string' + , 'vocabulary_' . $id => 'Unknow_Vocabulary' + , 'regname' => $id + , 'regdate' => $id + , 'regdesc' => $id + )); + + $this->assertTrue($this->client->getResponse()->isRedirect()); + $field->delete(); + + $name = "test" . uniqid(); + $field = \databox_field::create($databox, $name); + $field->set_multi(false); + $field->set_indexable(false); + $field->set_required(true); + $field->set_readonly(true); + $id = $field->get_id(); + $this->client->request("POST", "/description/" . $databox->get_sbas_id() . "/", array( + 'field_ids' => array($id) + , 'name_' . $id => $name + , 'multi_' . $id => 1 + , 'indexable_' . $id => 1 + , 'src_' . $id => 'unknow_Source' + , 'required_' . $id => 0 + , 'readonly_' . $id => 0 + , 'type_' . $id => 'string' + , 'vocabulary_' . $id => 'Unknow_Vocabulary' + , 'regname' => $id + , 'regdate' => $id + , 'regdesc' => $id + )); + + $this->assertTrue($this->client->getResponse()->isRedirect()); + $this->assertTrue($field->is_readonly()); + $this->assertTrue($field->is_required()); + $this->assertFalse($field->is_multi()); + $this->assertFalse($field->is_indexable()); + $field->delete(); + + + $name = "test" . uniqid(); + $field = \databox_field::create($databox, $name); + $id = $field->get_id(); + $this->client->request("POST", "/description/" . $databox->get_sbas_id() . "/", array( + 'field_ids' => array('unknow_id') + , 'name_' . $id => $name + , 'multi_' . $id => 1 + , 'indexable_' . $id => 1 + , 'src_' . $id => '/rdf:RDF/rdf:Description/IPTC:SupplementalCategories' + , 'required_' . $id => 0 + , 'readonly_' . $id => 0 + , 'type_' . $id => 'string' + , 'vocabulary_' . $id => 'Unknow_Vocabulary' + , 'regname' => $id + , 'regdate' => $id + , 'regdesc' => $id + )); + + $this->assertTrue($this->client->getResponse()->isRedirect()); + $field->delete(); + } + + public function testPostDescriptionRights() + { + $appbox = appbox::get_instance(); + + $session = $appbox->get_session(); + $auth = new Session_Authentication_None(self::$user_alt1); + $session->authenticate($auth); + + $databox = array_shift($appbox->get_databoxes()); + $name = "test" . uniqid(); + $field = \databox_field::create($databox, $name); + $id = $field->get_id(); + $this->client->request("POST", "/description/" . $databox->get_sbas_id() . "/", array( + 'field_ids' => array($id) + , 'name_' . $id => $name + , 'multi_' . $id => 1 + , 'indexable_' . $id => 1 + , 'src_' . $id => '/rdf:RDF/rdf:Description/IPTC:SupplementalCategories' + , 'required_' . $id => 0 + , 'readonly_' . $id => 0 + , 'type_' . $id => 'string' + , 'vocabulary_' . $id => 'User' + , 'regname' => $id + , 'regdate' => $id + , 'regdesc' => $id + )); + $this->assertTrue($this->client->getResponse()->isOk()); + $this->assertEquals("You are not allowed to access this zone", $this->client->getResponse()->getContent()); + $field->delete(); + } + + public function testGetDescriptionException() + { + $appbox = appbox::get_instance(); + + $session = $appbox->get_session(); + $auth = new Session_Authentication_None(self::$user_alt1); + $session->authenticate($auth); + + $databox = array_shift($appbox->get_databoxes()); + + $this->client->request("GET", "/description/" . $databox->get_sbas_id() . "/"); + $this->assertTrue($this->client->getResponse()->isOk()); + $this->assertEquals("You are not allowed to access this zone", $this->client->getResponse()->getContent()); + } + + public function testGetDescription() + { + $appbox = appbox::get_instance(); + $databox = array_shift($appbox->get_databoxes()); + + $this->client->request("GET", "/description/" . $databox->get_sbas_id() . "/"); + $this->assertTrue($this->client->getResponse()->isOk()); + } + + } diff --git a/lib/unitTest/Alchemy/Phrasea/Controller/Admin/SubdefsTest.php b/lib/unitTest/Alchemy/Phrasea/Controller/Admin/SubdefsTest.php index 40f60d1796..fb6976442d 100644 --- a/lib/unitTest/Alchemy/Phrasea/Controller/Admin/SubdefsTest.php +++ b/lib/unitTest/Alchemy/Phrasea/Controller/Admin/SubdefsTest.php @@ -9,11 +9,11 @@ require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract. class ControllerSubdefsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract { - /** * As controllers use WebTestCase, it requires a client */ protected $client; + /** * If the controller tests require some records, specify it her * @@ -42,11 +42,77 @@ class ControllerSubdefsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract /** * Default route test */ - public function testRouteSlash() + public function testRouteGetSubdef() { - $this->markTestIncomplete( - 'This test has not been implemented yet.' + $appbox = appbox::get_instance(); + $databox = array_shift($appbox->get_databoxes()); + $this->client->request("GET", "/subdefs/" . $databox->get_sbas_id() . "/"); + $this->assertTrue($this->client->getResponse()->isOk()); + } + + public function testPostRouteAddSubdef() + { + $appbox = appbox::get_instance(); + $databox = array_shift($appbox->get_databoxes()); + $this->client->request("POST", "/subdefs/" . $databox->get_sbas_id() . "/", array('add_subdef' => array( + 'class' => 'a_class', + 'name' => 'a_name', + 'group' => 'image' + ))); + $this->assertTrue($this->client->getResponse()->isRedirect()); + $subdefs = $databox->get_subdef_structure(); + $subdefs->get_subdef("image", "a_name"); + $subdefs->delete_subdef('image', 'a_name'); + } + + public function testPostRouteDeleteSubdef() + { + $appbox = appbox::get_instance(); + $databox = array_shift($appbox->get_databoxes()); + $subdefs = $databox->get_subdef_structure(); + $subdefs->add_subdef("image", "name", "class"); + $this->client->request("POST", "/subdefs/" . $databox->get_sbas_id() . "/", array('delete_subdef' => 'group_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() + { + $appbox = appbox::get_instance(); + $databox = array_shift($appbox->get_databoxes()); + $subdefs = $databox->get_subdef_structure(); + $subdefs->add_subdef("image", "name", "class"); + $this->client->request("POST", "/subdefs/" . $databox->get_sbas_id() . "/", array('subdefs' => array( + 'image_name' + ) + , 'image_name_class' => 'class' + , '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()); + $subdef = $subdefs->get_subdef("image", "name"); + /* @var $subdef \databox_subdefAbstract */ + $this->assertFalse($subdef->is_downloadable()); + $options = $subdef->get_options(); + $this->assertEquals(400, $options["size"]); + $this->assertEquals(83, $options["resolution"]); + $this->assertEquals(90, $options["quality"]); + $this->assertFalse($options["strip"]); + $subdefs->delete_subdef("image", "name"); } } diff --git a/lib/unitTest/Alchemy/Phrasea/Controller/Prod/FeedTest.php b/lib/unitTest/Alchemy/Phrasea/Controller/Prod/FeedTest.php index 0ed450a957..a294771f3d 100644 --- a/lib/unitTest/Alchemy/Phrasea/Controller/Prod/FeedTest.php +++ b/lib/unitTest/Alchemy/Phrasea/Controller/Prod/FeedTest.php @@ -247,7 +247,7 @@ class ControllerFeedApp extends \PhraseanetWebTestCaseAuthenticatedAbstract , 'lst' => self::$record_1->get_serialize_key() ); - $crawler = $this->client->request('POST', '/feeds/entry/UNKNOW/update/', $params); + $crawler = $this->client->request('POST', '/feeds/entry/99999999/update/', $params); $response = $this->client->getResponse(); @@ -351,7 +351,7 @@ class ControllerFeedApp extends \PhraseanetWebTestCaseAuthenticatedAbstract { $appbox = appbox::get_instance(); - $crawler = $this->client->request('POST', '/feeds/entry/UNKNOW/delete/'); + $crawler = $this->client->request('POST', '/feeds/entry/9999999/delete/'); $response = $this->client->getResponse(); diff --git a/lib/unitTest/Alchemy/Phrasea/Controller/Prod/LanguageTest.php b/lib/unitTest/Alchemy/Phrasea/Controller/Prod/LanguageTest.php new file mode 100644 index 0000000000..222432c2e1 --- /dev/null +++ b/lib/unitTest/Alchemy/Phrasea/Controller/Prod/LanguageTest.php @@ -0,0 +1,47 @@ +client = $this->createClient(); + } + + public function createApplication() + { + return require __DIR__ . '/../../../../../Alchemy/Phrasea/Application/Prod.php'; + } + + public function testRootPost() + { + $route = '/language/'; + + $this->client->request("GET", $route); + $this->assertTrue($this->client->getResponse()->isOk()); + $this->assertEquals("application/json", $this->client->getResponse()->headers->get("content-type")); + $pageContent = json_decode($this->client->getResponse()->getContent()); + $this->assertTrue(is_object($pageContent)); + } + +} diff --git a/lib/unitTest/Alchemy/Phrasea/Controller/Root/RSSFeedTest.php b/lib/unitTest/Alchemy/Phrasea/Controller/Root/RSSFeedTest.php index d06d678d7a..f16236db4c 100644 --- a/lib/unitTest/Alchemy/Phrasea/Controller/Root/RSSFeedTest.php +++ b/lib/unitTest/Alchemy/Phrasea/Controller/Root/RSSFeedTest.php @@ -24,8 +24,56 @@ class ControllerRssFeedTest extends \PhraseanetWebTestCaseAbstract */ public static $entry; public static $publisher; - public static $need_records = 2; - public static $need_subdefs = true; + + /** + * + * @var Feed_Collection + */ + protected static $public_feeds; + + /** + * + * @var Feed_Collection + */ + protected static $private_feeds; + + /** + * + * @var Feed_Adapter + */ + protected static $feed_1_private; + protected static $feed_1_private_title = 'Feed 1 title'; + protected static $feed_1_private_subtitle = 'Feed 1 subtitle'; + protected static $feed_1_entries = array(); + protected static $feed_2_entries = array(); + protected static $feed_3_entries = array(); + protected static $feed_4_entries = array(); + + /** + * + * @var Feed_Adapter + */ + protected static $feed_2_private; + protected static $feed_2_private_title = 'Feed 2 title'; + protected static $feed_2_private_subtitle = 'Feed 2 subtitle'; + + /** + * + * @var Feed_Adapter + */ + protected static $feed_3_public; + protected static $feed_3_public_title = 'Feed 3 title'; + protected static $feed_3_public_subtitle = 'Feed 3 subtitle'; + + /** + * + * @var Feed_Adapter + */ + protected static $feed_4_public; + protected static $feed_4_public_title = 'Feed 4 title'; + protected static $feed_4_public_subtitle = 'Feed 4 subtitle'; + protected static $need_records = true; + protected static $need_subdefs = true; protected $client; public function setUp() @@ -42,22 +90,105 @@ class ControllerRssFeedTest extends \PhraseanetWebTestCaseAbstract public function tearDown() { - if(self::$publisher instanceof Feed_Publisher_Adapter) + if (self::$publisher instanceof Feed_Publisher_Adapter) + { self::$publisher->delete(); - if(self::$entry instanceof Feed_Entry_Adapter) + } + if (self::$entry instanceof Feed_Entry_Adapter) + { self::$entry->delete(); - if(self::$feed instanceof Feed_Adapter) + } + if (self::$feed instanceof Feed_Adapter) + { self::$feed->delete(); + } parent::tearDown(); } public static function setUpBeforeClass() { parent::setUpBeforeClass(); + + $appbox = appbox::get_instance(); + $auth = new Session_Authentication_None(self::$user); + $appbox->get_session()->authenticate($auth); + + self::$feed_1_private = Feed_Adapter::create($appbox, self::$user, self::$feed_1_private_title, self::$feed_1_private_subtitle); + self::$feed_1_private->set_public(false); + self::$feed_1_private->set_icon(new system_file(__DIR__ . '/../../../../testfiles/logocoll.gif')); + + self::$feed_2_private = Feed_Adapter::create($appbox, self::$user, self::$feed_2_private_title, self::$feed_2_private_subtitle); + self::$feed_2_private->set_public(false); + + self::$feed_3_public = Feed_Adapter::create($appbox, self::$user, self::$feed_3_public_title, self::$feed_3_public_subtitle); + self::$feed_3_public->set_public(true); + self::$feed_3_public->set_icon(new system_file(__DIR__ . '/../../../../testfiles/logocoll.gif')); + + self::$feed_4_public = Feed_Adapter::create($appbox, self::$user, self::$feed_4_public_title, self::$feed_4_public_subtitle); + self::$feed_4_public->set_public(true); + + $publisher = array_shift(self::$feed_4_public->get_publishers()); + + for ($i = 1; $i != 15; $i++) + { + $entry = Feed_Entry_Adapter::create($appbox, self::$feed_4_public, $publisher, 'titre entry', 'soustitre entry', 'Jean-Marie Biggaro', 'author@example.com'); + $item = Feed_Entry_Item::create($appbox, $entry, self::$record_1); + $item = Feed_Entry_Item::create($appbox, $entry, self::$record_2); + $item = Feed_Entry_Item::create($appbox, $entry, self::$record_3); + $item = Feed_Entry_Item::create($appbox, $entry, self::$record_4); + $item = Feed_Entry_Item::create($appbox, $entry, self::$record_5); + $item = Feed_Entry_Item::create($appbox, $entry, self::$record_6); + $item = Feed_Entry_Item::create($appbox, $entry, self::$record_7); + $item = Feed_Entry_Item::create($appbox, $entry, self::$record_8); + $item = Feed_Entry_Item::create($appbox, $entry, self::$record_9); + $item = Feed_Entry_Item::create($appbox, $entry, self::$record_10); + $item = Feed_Entry_Item::create($appbox, $entry, self::$record_11); + $item = Feed_Entry_Item::create($appbox, $entry, self::$record_12); + $item = Feed_Entry_Item::create($appbox, $entry, self::$record_13); + $item = Feed_Entry_Item::create($appbox, $entry, self::$record_14); + $item = Feed_Entry_Item::create($appbox, $entry, self::$record_15); + $item = Feed_Entry_Item::create($appbox, $entry, self::$record_16); + $item = Feed_Entry_Item::create($appbox, $entry, self::$record_17); + $item = Feed_Entry_Item::create($appbox, $entry, self::$record_18); + $item = Feed_Entry_Item::create($appbox, $entry, self::$record_19); + $item = Feed_Entry_Item::create($appbox, $entry, self::$record_20); + $entry = Feed_Entry_Adapter::create($appbox, self::$feed_1_private, $publisher, 'titre entry', 'soustitre entry', 'Jean-Marie Biggaro', 'author@example.com'); + $item = Feed_Entry_Item::create($appbox, $entry, self::$record_1); + $item = Feed_Entry_Item::create($appbox, $entry, self::$record_2); + $item = Feed_Entry_Item::create($appbox, $entry, self::$record_3); + $item = Feed_Entry_Item::create($appbox, $entry, self::$record_4); + $item = Feed_Entry_Item::create($appbox, $entry, self::$record_5); + $item = Feed_Entry_Item::create($appbox, $entry, self::$record_6); + $item = Feed_Entry_Item::create($appbox, $entry, self::$record_7); + $item = Feed_Entry_Item::create($appbox, $entry, self::$record_8); + $item = Feed_Entry_Item::create($appbox, $entry, self::$record_9); + $item = Feed_Entry_Item::create($appbox, $entry, self::$record_10); + $item = Feed_Entry_Item::create($appbox, $entry, self::$record_11); + $item = Feed_Entry_Item::create($appbox, $entry, self::$record_12); + $item = Feed_Entry_Item::create($appbox, $entry, self::$record_13); + $item = Feed_Entry_Item::create($appbox, $entry, self::$record_14); + $item = Feed_Entry_Item::create($appbox, $entry, self::$record_15); + $item = Feed_Entry_Item::create($appbox, $entry, self::$record_16); + $item = Feed_Entry_Item::create($appbox, $entry, self::$record_17); + $item = Feed_Entry_Item::create($appbox, $entry, self::$record_18); + $item = Feed_Entry_Item::create($appbox, $entry, self::$record_19); + $item = Feed_Entry_Item::create($appbox, $entry, self::$record_20); + + self::$feed_4_entries[] = $entry; + } + + + self::$public_feeds = Feed_Collection::load_public_feeds($appbox); + self::$private_feeds = Feed_Collection::load_all($appbox, self::$user); + $appbox->get_session()->logout(); } public static function tearDownAfterClass() { + self::$feed_1_private->delete(); + self::$feed_2_private->delete(); + self::$feed_3_public->delete(); + self::$feed_4_public->delete(); parent::tearDownAfterClass(); } @@ -67,6 +198,112 @@ class ControllerRssFeedTest extends \PhraseanetWebTestCaseAbstract return require __DIR__ . '/../../../../../Alchemy/Phrasea/Application/Root.php'; } + public function testPublicFeedAggregated() + { + self::$public_feeds->get_aggregate(); + $this->client->request('GET', '/feeds/aggregated/atom/'); + $response = $this->client->getResponse(); + + $this->evaluateResponse200($response); + $this->evaluateGoodXML($response); + + $this->evaluateAtom($response); + } + + protected function evaluateAtom(Response $response) + { + $dom_doc = new DOMDocument(); + $doc->preserveWhiteSpace = false; + $dom_doc->loadXML($response->getContent()); + + $xpath = new DOMXPath($dom_doc); + $xpath->registerNamespace('atom', 'http://www.w3.org/2005/Atom'); + + $this->assertEquals(1, $xpath->query('/atom:feed/atom:title')->length); + $this->assertEquals(1, $xpath->query('/atom:feed/atom:updated')->length); + $this->assertEquals(1, $xpath->query('/atom:feed/atom:link[@rel="self"]')->length); + $this->assertEquals(1, $xpath->query('/atom:feed/atom:id')->length); + $this->assertEquals(1, $xpath->query('/atom:feed/atom:generator')->length); + $this->assertEquals(1, $xpath->query('/atom:feed/atom:subtitle')->length); + } + + protected function evaluateGoodXML(Response $response) + { + $dom_doc = new DOMDocument(); + $dom_doc->loadXML($response->getContent()); + $this->assertInstanceOf('DOMDocument', $dom_doc); + $this->assertEquals($dom_doc->saveXML(), $response->getContent()); + } + + protected function evaluateResponse200(Response $response) + { + $this->assertEquals(200, $response->getStatusCode(), 'Test status code '); + $this->assertEquals('UTF-8', $response->getCharset(), 'Test charset response'); + } + +//$app->get('/feeds/feed/{id}/{format}/', function($id, $format) use ($app, $appbox, $display_feed) + public function testPublicFeed() + { + $appbox = appbox::get_instance(); + $auth = new Session_Authentication_None(self::$user); + $appbox->get_session()->authenticate($auth); + + $link = self::$feed_3_public->get_user_link($appbox->get_registry(), self::$user, Feed_Adapter::FORMAT_ATOM)->get_href(); + $link = str_replace($appbox->get_registry()->get('GV_ServerName') . 'feeds/', '/', $link); + + $appbox->get_session()->logout(); + + $this->client->request('GET', "/feeds" . $link); + $response = $this->client->getResponse(); + + $this->evaluateResponse200($response); + $this->evaluateGoodXML($response); + + $this->evaluateAtom($response); + } + +//$app->get('/feeds/userfeed/aggregated/{token}/{format}/', function($token, $format) use ($app, $appbox, $display_feed) + public function testUserFeedAggregated() + { + $appbox = appbox::get_instance(); + $auth = new Session_Authentication_None(self::$user); + $appbox->get_session()->authenticate($auth); + + $link = self::$private_feeds->get_aggregate()->get_user_link($appbox->get_registry(), self::$user, Feed_Adapter::FORMAT_ATOM)->get_href(); + $link = str_replace($appbox->get_registry()->get('GV_ServerName') . 'feeds/', '/', $link); + + $appbox->get_session()->logout(); + + $this->client->request('GET', "/feeds" . $link); + $response = $this->client->getResponse(); + + $this->evaluateResponse200($response); + $this->evaluateGoodXML($response); + + $this->evaluateAtom($response); + } + +//$app->get('/feeds/userfeed/{token}/{id}/{format}/', function($token, $id, $format) use ($app, $appbox, $display_feed) + public function testUserFeed() + { + $appbox = appbox::get_instance(); + $auth = new Session_Authentication_None(self::$user); + $appbox->get_session()->authenticate($auth); + + $link = self::$feed_1_private->get_user_link($appbox->get_registry(), self::$user, Feed_Adapter::FORMAT_ATOM)->get_href(); + $link = str_replace($appbox->get_registry()->get('GV_ServerName') . 'feeds/', '/', $link); + + $appbox->get_session()->logout(); + + $this->client->request('GET', "/feeds" . $link); + $response = $this->client->getResponse(); + + $this->evaluateResponse200($response); + $this->evaluateGoodXML($response); + + $this->evaluateAtom($response); + } + public function testGetFeedFormat() { $feeds = Feed_Collection::load_public_feeds(appbox::get_instance()); @@ -489,8 +726,8 @@ class ControllerRssFeedTest extends \PhraseanetWebTestCaseAbstract { foreach ($node->attributes as $attribute) { - $this->assertTrue(array_key_exists($attribute->name, $field["media_field"]["attributes"]), "Checkin attribute ".$attribute->name." for " . $field['media_field']['name']); - $this->assertEquals($attribute->value, $field["media_field"]["attributes"][$attribute->name], "Checkin attribute ".$attribute->name." for " . $field['media_field']['name']); + $this->assertTrue(array_key_exists($attribute->name, $field["media_field"]["attributes"]), "Checkin attribute " . $attribute->name . " for " . $field['media_field']['name']); + $this->assertEquals($attribute->value, $field["media_field"]["attributes"][$attribute->name], "Checkin attribute " . $attribute->name . " for " . $field['media_field']['name']); } } } diff --git a/lib/unitTest/Alchemy/Phrasea/Controller/Root/RSSFeedToMergeTest.php b/lib/unitTest/Alchemy/Phrasea/Controller/Root/RSSFeedToMergeTest.php deleted file mode 100644 index 698959f19c..0000000000 --- a/lib/unitTest/Alchemy/Phrasea/Controller/Root/RSSFeedToMergeTest.php +++ /dev/null @@ -1,266 +0,0 @@ -client = $this->createClient(); - } - - public static function setUpBeforeClass() - { - parent::setUpBeforeClass(); - - $appbox = appbox::get_instance(); - $auth = new Session_Authentication_None(self::$user); - $appbox->get_session()->authenticate($auth); - - self::$feed_1_private = Feed_Adapter::create($appbox, self::$user, self::$feed_1_private_title, self::$feed_1_private_subtitle); - self::$feed_1_private->set_public(false); - self::$feed_1_private->set_icon(new system_file(__DIR__ . '/../../../../testfiles/logocoll.gif')); - - self::$feed_2_private = Feed_Adapter::create($appbox, self::$user, self::$feed_2_private_title, self::$feed_2_private_subtitle); - self::$feed_2_private->set_public(false); - - self::$feed_3_public = Feed_Adapter::create($appbox, self::$user, self::$feed_3_public_title, self::$feed_3_public_subtitle); - self::$feed_3_public->set_public(true); - self::$feed_3_public->set_icon(new system_file(__DIR__ . '/../../../../testfiles/logocoll.gif')); - - self::$feed_4_public = Feed_Adapter::create($appbox, self::$user, self::$feed_4_public_title, self::$feed_4_public_subtitle); - self::$feed_4_public->set_public(true); - - $publisher = array_shift(self::$feed_4_public->get_publishers()); - - for($i = 1; $i != 15; $i++) - { - $entry = Feed_Entry_Adapter::create($appbox, self::$feed_4_public, $publisher, 'titre entry', 'soustitre entry', 'Jean-Marie Biggaro', 'author@example.com'); - $item = Feed_Entry_Item::create($appbox, $entry, self::$record_1); - $item = Feed_Entry_Item::create($appbox, $entry, self::$record_2); - $item = Feed_Entry_Item::create($appbox, $entry, self::$record_3); - $item = Feed_Entry_Item::create($appbox, $entry, self::$record_4); - $item = Feed_Entry_Item::create($appbox, $entry, self::$record_5); - $item = Feed_Entry_Item::create($appbox, $entry, self::$record_6); - $item = Feed_Entry_Item::create($appbox, $entry, self::$record_7); - $item = Feed_Entry_Item::create($appbox, $entry, self::$record_8); - $item = Feed_Entry_Item::create($appbox, $entry, self::$record_9); - $item = Feed_Entry_Item::create($appbox, $entry, self::$record_10); - $item = Feed_Entry_Item::create($appbox, $entry, self::$record_11); - $item = Feed_Entry_Item::create($appbox, $entry, self::$record_12); - $item = Feed_Entry_Item::create($appbox, $entry, self::$record_13); - $item = Feed_Entry_Item::create($appbox, $entry, self::$record_14); - $item = Feed_Entry_Item::create($appbox, $entry, self::$record_15); - $item = Feed_Entry_Item::create($appbox, $entry, self::$record_16); - $item = Feed_Entry_Item::create($appbox, $entry, self::$record_17); - $item = Feed_Entry_Item::create($appbox, $entry, self::$record_18); - $item = Feed_Entry_Item::create($appbox, $entry, self::$record_19); - $item = Feed_Entry_Item::create($appbox, $entry, self::$record_20); - $entry = Feed_Entry_Adapter::create($appbox, self::$feed_1_private, $publisher, 'titre entry', 'soustitre entry', 'Jean-Marie Biggaro', 'author@example.com'); - $item = Feed_Entry_Item::create($appbox, $entry, self::$record_1); - $item = Feed_Entry_Item::create($appbox, $entry, self::$record_2); - $item = Feed_Entry_Item::create($appbox, $entry, self::$record_3); - $item = Feed_Entry_Item::create($appbox, $entry, self::$record_4); - $item = Feed_Entry_Item::create($appbox, $entry, self::$record_5); - $item = Feed_Entry_Item::create($appbox, $entry, self::$record_6); - $item = Feed_Entry_Item::create($appbox, $entry, self::$record_7); - $item = Feed_Entry_Item::create($appbox, $entry, self::$record_8); - $item = Feed_Entry_Item::create($appbox, $entry, self::$record_9); - $item = Feed_Entry_Item::create($appbox, $entry, self::$record_10); - $item = Feed_Entry_Item::create($appbox, $entry, self::$record_11); - $item = Feed_Entry_Item::create($appbox, $entry, self::$record_12); - $item = Feed_Entry_Item::create($appbox, $entry, self::$record_13); - $item = Feed_Entry_Item::create($appbox, $entry, self::$record_14); - $item = Feed_Entry_Item::create($appbox, $entry, self::$record_15); - $item = Feed_Entry_Item::create($appbox, $entry, self::$record_16); - $item = Feed_Entry_Item::create($appbox, $entry, self::$record_17); - $item = Feed_Entry_Item::create($appbox, $entry, self::$record_18); - $item = Feed_Entry_Item::create($appbox, $entry, self::$record_19); - $item = Feed_Entry_Item::create($appbox, $entry, self::$record_20); - - self::$feed_4_entries[] = $entry; - } - - - self::$public_feeds = Feed_Collection::load_public_feeds($appbox); - self::$private_feeds = Feed_Collection::load_all($appbox, self::$user); - $appbox->get_session()->logout(); - } - - public static function tearDownAfterClass() - { - self::$feed_1_private->delete(); - self::$feed_2_private->delete(); - self::$feed_3_public->delete(); - self::$feed_4_public->delete(); - parent::tearDownAfterClass(); - } - - public function createApplication() - { - return require __DIR__ . '/../../../../../Alchemy/Phrasea/Application/Root.php'; - } - -//$app->get('/feeds/aggregated/{format}/', function($format) use ($app, $appbox, $display_feed) - public function testPublicFeedAggregated() - { - $aggregate = self::$public_feeds->get_aggregate(); - $crawler = $this->client->request('GET', '/feeds/aggregated/atom/'); - $response = $this->client->getResponse(); - - $this->evaluateResponse200($response); - $this->evaluateGoodXML($response); - - $this->evaluateAtom($response); - } - - protected function evaluateAtom(Response $response) - { - $dom_doc = new DOMDocument(); - $doc->preserveWhiteSpace = false; - $dom_doc->loadXML($response->getContent()); - - $xpath = new DOMXPath($dom_doc); - $xpath->registerNamespace('atom', 'http://www.w3.org/2005/Atom'); - - $this->assertEquals(1, $xpath->query('/atom:feed/atom:title')->length); - $this->assertEquals(1, $xpath->query('/atom:feed/atom:updated')->length); - $this->assertEquals(1, $xpath->query('/atom:feed/atom:link[@rel="self"]')->length); - $this->assertEquals(1, $xpath->query('/atom:feed/atom:id')->length); - $this->assertEquals(1, $xpath->query('/atom:feed/atom:generator')->length); - $this->assertEquals(1, $xpath->query('/atom:feed/atom:subtitle')->length); - } - - protected function evaluateGoodXML(Response $response) - { - $dom_doc = new DOMDocument(); - $dom_doc->loadXML($response->getContent()); - $this->assertInstanceOf('DOMDocument', $dom_doc); - $this->assertEquals($dom_doc->saveXML(), $response->getContent()); - } - - protected function evaluateResponse200(Response $response) - { - $this->assertEquals(200, $response->getStatusCode(), 'Test status code '); - $this->assertEquals('UTF-8', $response->getCharset(), 'Test charset response'); - } - -//$app->get('/feeds/feed/{id}/{format}/', function($id, $format) use ($app, $appbox, $display_feed) - public function testPublicFeed() - { - $appbox = appbox::get_instance(); - $auth = new Session_Authentication_None(self::$user); - $appbox->get_session()->authenticate($auth); - - $link = self::$feed_3_public->get_user_link($appbox->get_registry(), self::$user, Feed_Adapter::FORMAT_ATOM)->get_href(); - $link = str_replace($appbox->get_registry()->get('GV_ServerName').'feeds/', '/', $link); - - $appbox->get_session()->logout(); - - $crawler = $this->client->request('GET', "/feeds".$link); - $response = $this->client->getResponse(); - - $this->evaluateResponse200($response); - $this->evaluateGoodXML($response); - - $this->evaluateAtom($response); - } - -//$app->get('/feeds/userfeed/aggregated/{token}/{format}/', function($token, $format) use ($app, $appbox, $display_feed) - public function testUserFeedAggregated() - { - $appbox = appbox::get_instance(); - $auth = new Session_Authentication_None(self::$user); - $appbox->get_session()->authenticate($auth); - - $link = self::$private_feeds->get_aggregate()->get_user_link($appbox->get_registry(), self::$user, Feed_Adapter::FORMAT_ATOM)->get_href(); - $link = str_replace($appbox->get_registry()->get('GV_ServerName').'feeds/', '/', $link); - - $appbox->get_session()->logout(); - - $crawler = $this->client->request('GET', "/feeds".$link); - $response = $this->client->getResponse(); - - $this->evaluateResponse200($response); - $this->evaluateGoodXML($response); - - $this->evaluateAtom($response); - } - -//$app->get('/feeds/userfeed/{token}/{id}/{format}/', function($token, $id, $format) use ($app, $appbox, $display_feed) - public function testUserFeed() - { - $appbox = appbox::get_instance(); - $auth = new Session_Authentication_None(self::$user); - $appbox->get_session()->authenticate($auth); - - $link = self::$feed_1_private->get_user_link($appbox->get_registry(), self::$user, Feed_Adapter::FORMAT_ATOM)->get_href(); - $link = str_replace($appbox->get_registry()->get('GV_ServerName').'feeds/', '/', $link); - - $appbox->get_session()->logout(); - - $crawler = $this->client->request('GET', "/feeds".$link); - $response = $this->client->getResponse(); - - $this->evaluateResponse200($response); - $this->evaluateGoodXML($response); - - $this->evaluateAtom($response); - } - -} diff --git a/lib/unitTest/tests.sqlite b/lib/unitTest/tests.sqlite new file mode 100644 index 0000000000..ea383c793c Binary files /dev/null and b/lib/unitTest/tests.sqlite differ