delete();
parent::tearDownAfterClass();
}
public function testGet_icon_url()
{
$this->assertEquals('/skins/icons/rss32.gif', self::$object->get_icon_url());
}
public function testSet_icon()
{
$this->assertEquals('/skins/icons/rss32.gif', self::$object->get_icon_url());
$file = __DIR__ . '/../../files/p4logo.jpg';
self::$object->set_icon($file);
$this->assertEquals('/custom/feed_' . self::$object->get_id() . '.jpg', self::$object->get_icon_url());
}
/**
* @expectedException \Alchemy\Phrasea\Exception\InvalidArgumentException
*/
public function testSet_iconFail()
{
$file = __DIR__ . '/../../files/unknown.jpg';
self::$object->set_icon($file);
}
public function testIs_aggregated()
{
$this->assertFalse(self::$object->is_aggregated());
}
public function testIs_owner()
{
$this->assertTrue(self::$object->is_owner(self::$DI['user']));
}
public function testIs_publisher()
{
$this->assertTrue(self::$object->is_publisher(self::$DI['user']));
}
public function testIs_public()
{
$this->assertFalse(self::$object->is_public());
self::$object->set_public(true);
$this->assertTrue(self::$object->is_public());
$coll = null;
foreach (self::$DI['app']['phraseanet.appbox']->get_databoxes() as $databox) {
foreach ($databox->get_collections() as $collection) {
$coll = $collection;
break;
}
if ($coll instanceof collection)
break;
}
self::$object->set_collection($coll);
$this->assertFalse(self::$object->is_public());
self::$object->set_collection(null);
$this->assertTrue(self::$object->is_public());
self::$object->set_public(false);
$this->assertFalse(self::$object->is_public());
}
public function testGet_publishers()
{
$publishers = self::$object->get_publishers();
$this->assertEquals(1, count($publishers));
}
public function testGet_collection()
{
$this->assertNull(self::$object->get_collection());
}
public function testAdd_publisher()
{
self::$object->add_publisher(self::$DI['user']);
$publishers = self::$object->get_publishers();
$this->assertEquals(1, count($publishers));
}
public function testGet_id()
{
$this->assertTrue(is_int(self::$object->get_id()));
$this->assertTrue(self::$object->get_id() > 0);
}
public function testSet_collection()
{
$coll = null;
foreach (self::$DI['app']['phraseanet.appbox']->get_databoxes() as $databox) {
foreach ($databox->get_collections() as $collection) {
$coll = $collection;
break;
}
if ($coll instanceof collection)
break;
}
self::$object->set_collection($coll);
$this->assertInstanceOf('collection', self::$object->get_collection());
self::$object->set_collection(null);
$this->assertNull(self::$object->get_collection());
}
public function testSet_public()
{
self::$object->set_collection(null);
self::$object->set_public(true);
$this->assertTrue(self::$object->is_public());
self::$object->set_public(false);
$this->assertFalse(self::$object->is_public());
}
public function testSet_title()
{
$this->assertEquals(self::$title, self::$object->get_title());
$title = 'GROS NIchONS';
self::$object->set_title($title);
$this->assertEquals($title, self::$object->get_title());
$title = 'GROS NIchONS';
self::$object->set_title($title);
$this->assertNotEquals($title, self::$object->get_title());
$this->assertEquals(strip_tags($title), self::$object->get_title());
try {
self::$object->set_title(' ');
$this->fail();
} catch (Exception $e) {
}
try {
self::$object->set_title(' ');
$this->fail();
} catch (Exception $e) {
}
try {
self::$object->set_title('');
$this->fail();
} catch (Exception $e) {
}
self::$object->set_title(self::$title);
}
public function testSet_subtitle()
{
$this->assertEquals(self::$subtitle, self::$object->get_subtitle());
self::$object->set_subtitle('');
$this->assertEquals('', self::$object->get_subtitle());
self::$object->set_subtitle(' un sous titre ');
$this->assertEquals(' un sous titre ', self::$object->get_subtitle());
self::$object->set_subtitle(self::$subtitle);
$this->assertEquals(self::$subtitle, self::$object->get_subtitle());
}
public function testLoad_with_user()
{
$this->assertEquals(Feed_Adapter::load_with_user(self::$DI['app'], self::$DI['user'], self::$object->get_id())->get_id(), self::$object->get_id());
}
public function testGet_count_total_entries()
{
$n = self::$object->get_count_total_entries();
$this->assertTrue($n === 0);
}
public function testGet_entries()
{
$entries_coll = self::$object->get_entries(0, 5);
$this->assertInstanceOf('Feed_Entry_Collection', $entries_coll);
$this->assertEquals(0, count($entries_coll->get_entries()));
}
public function testGet_homepage_link()
{
self::$object->set_public(false);
$link = self::$object->get_homepage_link(self::$DI['app']['phraseanet.registry'], Feed_Adapter::FORMAT_ATOM);
$this->assertNull($link);
self::$object->set_public(true);
$link = self::$object->get_homepage_link(self::$DI['app']['phraseanet.registry'], Feed_Adapter::FORMAT_ATOM);
$this->assertInstanceOf('Feed_Link', $link);
}
public function testGet_user_link()
{
$link = self::$object->get_user_link(self::$DI['app']['phraseanet.registry'], self::$DI['user'], Feed_Adapter::FORMAT_ATOM);
$supposed = '/feeds\/userfeed\/([a-zA-Z0-9]{12})\/' . self::$object->get_id() . '\/atom\//';
$atom = $link->get_href();
$this->assertRegExp($supposed, str_replace(self::$DI['app']['phraseanet.registry']->get('GV_ServerName'), '', $atom));
$this->assertEquals($atom, self::$object->get_user_link(self::$DI['app']['phraseanet.registry'], self::$DI['user'], Feed_Adapter::FORMAT_ATOM)->get_href());
$this->assertEquals($atom, self::$object->get_user_link(self::$DI['app']['phraseanet.registry'], self::$DI['user'], Feed_Adapter::FORMAT_ATOM)->get_href());
$this->assertNotEquals($atom, self::$object->get_user_link(self::$DI['app']['phraseanet.registry'], self::$DI['user'], Feed_Adapter::FORMAT_ATOM, null, true)->get_href());
$link = self::$object->get_user_link(self::$DI['app']['phraseanet.registry'], self::$DI['user'], Feed_Adapter::FORMAT_RSS);
$supposed = '/feeds\/userfeed\/([a-zA-Z0-9]{12})\/' . self::$object->get_id() . '\/rss\//';
$this->assertRegExp($supposed, str_replace(self::$DI['app']['phraseanet.registry']->get('GV_ServerName'), '', $link->get_href()));
}
public function testGet_title()
{
$this->assertEquals(self::$object->get_title(), self::$title);
try {
self::$object->set_title('');
$this->fail();
} catch (Exception $e) {
}
}
public function testGet_subtitle()
{
$this->assertEquals(self::$object->get_subtitle(), self::$subtitle);
self::$object->set_subtitle('');
$this->assertEquals(self::$object->get_subtitle(), '');
self::$object->set_subtitle(self::$subtitle);
}
public function testGet_created_on()
{
$this->assertInstanceOf('DateTime', self::$object->get_created_on());
}
public function testGet_updated_on()
{
$this->assertInstanceOf('DateTime', self::$object->get_updated_on());
}
}