From f06ed9d8b1c6e863ea80146fa2aaccd26b42ceae Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Tue, 31 Jan 2012 12:10:48 +0100 Subject: [PATCH] Merge with master --- lib/classes/setup.class.php | 14 +- .../Controller/Admin/DescriptionTest.php | 249 +++++++++++++++- .../Phrasea/Controller/Admin/SubdefsTest.php | 74 ++++- .../Phrasea/Controller/Prod/FeedTest.php | 4 +- .../Phrasea/Controller/Prod/LanguageTest.php | 47 ++++ .../Phrasea/Controller/Root/RSSFeedTest.php | 251 ++++++++++++++++- .../Controller/Root/RSSFeedToMergeTest.php | 266 ------------------ lib/unitTest/tests.sqlite | Bin 0 -> 25600 bytes 8 files changed, 612 insertions(+), 293 deletions(-) create mode 100644 lib/unitTest/Alchemy/Phrasea/Controller/Prod/LanguageTest.php delete mode 100644 lib/unitTest/Alchemy/Phrasea/Controller/Root/RSSFeedToMergeTest.php create mode 100644 lib/unitTest/tests.sqlite 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 0000000000000000000000000000000000000000..ea383c793c7b896fb03cdf4e05bebbfcc34c3b12 GIT binary patch literal 25600 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