diff --git a/tests/ACLTest.php b/tests/ACLTest.php
index 2f0ced2def..068cd72c14 100644
--- a/tests/ACLTest.php
+++ b/tests/ACLTest.php
@@ -4,7 +4,6 @@ require_once __DIR__ . '/PhraseanetPHPUnitAuthenticatedAbstract.class.inc';
class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract
{
-
/**
* @var ACL
*/
@@ -22,25 +21,19 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract
* In case first test fails
*/
$usr_id = User_Adapter::get_usr_id_from_login('test_phpunit2');
- try
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
+ try {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$template = User_Adapter::getInstance($usr_id, $appbox);
$template->delete();
- }
- catch (Exception $e)
- {
+ } catch (Exception $e) {
}
$usr_id = User_Adapter::get_usr_id_from_login('test_phpunit3');
- try
- {
+ try {
$appbox = appbox::get_instance(\bootstrap::getCore());
$cobaye = User_Adapter::getInstance($usr_id, $appbox);
$cobaye->delete();
- }
- catch (Exception $e)
- {
+ } catch (Exception $e) {
}
parent::tearDownAfterClass();
@@ -48,16 +41,14 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract
public function testApply_model()
{
- $appbox = appbox::get_instance(\bootstrap::getCore());
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$template = User_Adapter::create($appbox, 'test_phpunit2', 'blabla2', 'test2@example.com', false);
$template->set_template(self::$user);
$base_ids = array();
- foreach ($appbox->get_databoxes() as $databox)
- {
- foreach ($databox->get_collections() as $collection)
- {
- $base_id = $collection->get_base_id();
+ foreach ($appbox->get_databoxes() as $databox) {
+ foreach ($databox->get_collections() as $collection) {
+ $base_id = $collection->get_base_id();
$base_ids[] = $base_id;
}
}
@@ -65,10 +56,8 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract
$cobaye = User_Adapter::create($appbox, 'test_phpunit3', 'blabla3', 'test3@example.com', false);
$cobaye->ACL()->apply_model($template, $base_ids);
- foreach ($appbox->get_databoxes() as $databox)
- {
- foreach ($databox->get_collections() as $collection)
- {
+ foreach ($appbox->get_databoxes() as $databox) {
+ foreach ($databox->get_collections() as $collection) {
$base_id = $collection->get_base_id();
$this->assertTrue($cobaye->ACL()->has_access_to_base($base_id));
}
@@ -83,10 +72,8 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract
$appbox = appbox::get_instance(\bootstrap::getCore());
$base_ids = array();
- foreach ($appbox->get_databoxes() as $databox)
- {
- foreach ($databox->get_collections() as $collection)
- {
+ foreach ($appbox->get_databoxes() as $databox) {
+ foreach ($databox->get_collections() as $collection) {
$base_id = $collection->get_base_id();
self::$user->ACL()->revoke_access_from_bases(array($base_id));
$this->assertFalse(self::$user->ACL()->has_access_to_base($base_id));
@@ -97,8 +84,7 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract
}
self::$user->ACL()->revoke_access_from_bases($base_ids);
- foreach ($base_ids as $base_id)
- {
+ foreach ($base_ids as $base_id) {
$this->assertFalse(self::$user->ACL()->has_access_to_base($base_id));
}
}
@@ -107,10 +93,8 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract
{
$appbox = appbox::get_instance(\bootstrap::getCore());
- foreach ($appbox->get_databoxes() as $databox)
- {
- foreach ($databox->get_collections() as $collection)
- {
+ foreach ($appbox->get_databoxes() as $databox) {
+ foreach ($databox->get_collections() as $collection) {
$base_id = $collection->get_base_id();
$this->assertFalse(self::$user->ACL()->has_access_to_base($base_id));
self::$user->ACL()->give_access_to_base(array($base_id));
@@ -123,12 +107,10 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract
{
$appbox = appbox::get_instance(\bootstrap::getCore());
- foreach ($appbox->get_databoxes() as $databox)
- {
- $sbas_id = $databox->get_sbas_id();
+ foreach ($appbox->get_databoxes() as $databox) {
+ $sbas_id = $databox->get_sbas_id();
$base_ids = array();
- foreach ($databox->get_collections() as $collection)
- {
+ foreach ($databox->get_collections() as $collection) {
$base_ids[] = $collection->get_base_id();
}
@@ -143,12 +125,10 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract
public function testRevoke_unused_sbas_rights()
{
$appbox = appbox::get_instance(\bootstrap::getCore());
- foreach ($appbox->get_databoxes() as $databox)
- {
- $sbas_id = $databox->get_sbas_id();
+ foreach ($appbox->get_databoxes() as $databox) {
+ $sbas_id = $databox->get_sbas_id();
$base_ids = array();
- foreach ($databox->get_collections() as $collection)
- {
+ foreach ($databox->get_collections() as $collection) {
$base_ids[] = $collection->get_base_id();
}
@@ -168,13 +148,11 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract
public function testSet_quotas_on_base()
{
$appbox = appbox::get_instance(\bootstrap::getCore());
- foreach ($appbox->get_databoxes() as $databox)
- {
- foreach ($databox->get_collections() as $collection)
- {
+ foreach ($appbox->get_databoxes() as $databox) {
+ foreach ($databox->get_collections() as $collection) {
$base_id = $collection->get_base_id();
- $droits = 50;
- $restes = 40;
+ $droits = 50;
+ $restes = 40;
self::$user->ACL()->give_access_to_base(array($base_id));
self::$user->ACL()->set_quotas_on_base($base_id, $droits, $restes);
@@ -192,24 +170,19 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract
{
$appbox = appbox::get_instance(\bootstrap::getCore());
- $first = true;
+ $first = true;
$base_ref = null;
- foreach ($appbox->get_databoxes() as $databox)
- {
- foreach ($databox->get_collections() as $collection)
- {
+ foreach ($appbox->get_databoxes() as $databox) {
+ foreach ($databox->get_collections() as $collection) {
$base_id = $collection->get_base_id();
self::$user->ACL()->give_access_to_base(array($base_id));
- if ($first)
- {
+ if ($first) {
self::$user->ACL()->update_rights_to_base($base_id, array('imgtools' => true, 'chgstatus' => true, 'canaddrecord' => true, 'canputinalbum' => true));
- $base_ref = $base_id;
- }
- else
- {
+ $base_ref = $base_id;
+ } else {
self::$user->ACL()->duplicate_right_from_bas($base_ref, $base_id);
}
@@ -227,7 +200,7 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
- 'This test has not been implemented yet.'
+ 'This test has not been implemented yet.'
);
}
@@ -236,23 +209,21 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract
$appbox = appbox::get_instance(\bootstrap::getCore());
$rights_false = array(
- 'imgtools' => false
- , 'chgstatus' => false
- , 'canaddrecord' => false
- , 'canputinalbum' => false
+ 'imgtools' => false
+ , 'chgstatus' => false
+ , 'canaddrecord' => false
+ , 'canputinalbum' => false
);
$rights_true = array(
- 'imgtools' => true
- , 'chgstatus' => true
- , 'canaddrecord' => true
+ 'imgtools' => true
+ , 'chgstatus' => true
+ , 'canaddrecord' => true
);
- foreach ($appbox->get_databoxes() as $databox)
- {
- foreach ($databox->get_collections() as $collection)
- {
+ foreach ($appbox->get_databoxes() as $databox) {
+ foreach ($databox->get_collections() as $collection) {
$base_id = $collection->get_base_id();
self::$user->ACL()->give_access_to_base(array($base_id));
self::$user->ACL()->update_rights_to_base($base_id, $rights_false);
@@ -283,13 +254,11 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract
{
$appbox = appbox::get_instance(\bootstrap::getCore());
- foreach ($appbox->get_databoxes() as $databox)
- {
- foreach ($databox->get_collections() as $collection)
- {
+ foreach ($appbox->get_databoxes() as $databox) {
+ foreach ($databox->get_collections() as $collection) {
$base_id = $collection->get_base_id();
- $droits = 50;
- $restes = 40;
+ $droits = 50;
+ $restes = 40;
self::$user->ACL()->give_access_to_base(array($base_id));
self::$user->ACL()->set_quotas_on_base($base_id, $droits, $restes);
@@ -306,13 +275,11 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract
public function testRemove_remaining()
{
$appbox = appbox::get_instance(\bootstrap::getCore());
- foreach ($appbox->get_databoxes() as $databox)
- {
- foreach ($databox->get_collections() as $collection)
- {
+ foreach ($appbox->get_databoxes() as $databox) {
+ foreach ($databox->get_collections() as $collection) {
$base_id = $collection->get_base_id();
- $droits = 50;
- $restes = 40;
+ $droits = 50;
+ $restes = 40;
self::$user->ACL()->give_access_to_base(array($base_id));
self::$user->ACL()->set_quotas_on_base($base_id, $droits, $restes);
@@ -338,15 +305,14 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract
$rights = array(
- 'bas_modify_struct' => true
+ 'bas_modify_struct' => true
);
$this->assertFalse(self::$user->ACL()->has_right('bas_modify_struct'));
$this->assertFalse(self::$user->ACL()->has_right('bas_modif_th'));
- foreach ($appbox->get_databoxes() as $databox)
- {
+ foreach ($appbox->get_databoxes() as $databox) {
self::$user->ACL()->give_access_to_sbas(array($databox->get_sbas_id()));
self::$user->ACL()->update_rights_to_sbas($databox->get_sbas_id(), $rights);
break;
@@ -361,22 +327,21 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract
$appbox = appbox::get_instance(\bootstrap::getCore());
$rights_false = array(
- 'bas_modify_struct' => false
- , 'bas_manage' => false
- , 'bas_chupub' => false
- , 'bas_modif_th' => false
+ 'bas_modify_struct' => false
+ , 'bas_manage' => false
+ , 'bas_chupub' => false
+ , 'bas_modif_th' => false
);
$rights_true = array(
- 'bas_modify_struct' => true
- , 'bas_manage' => true
- , 'bas_chupub' => true
- , 'bas_modif_th' => true
+ 'bas_modify_struct' => true
+ , 'bas_manage' => true
+ , 'bas_chupub' => true
+ , 'bas_modif_th' => true
);
- foreach ($appbox->get_databoxes() as $databox)
- {
+ foreach ($appbox->get_databoxes() as $databox) {
self::$user->ACL()->give_access_to_sbas(array($databox->get_sbas_id()));
self::$user->ACL()->update_rights_to_sbas($databox->get_sbas_id(), $rights_false);
$this->assertFalse(self::$user->ACL()->has_right_on_sbas($databox->get_sbas_id(), 'bas_modify_struct'));
@@ -399,10 +364,8 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract
public function testGet_mask_and()
{
$appbox = appbox::get_instance(\bootstrap::getCore());
- foreach ($appbox->get_databoxes() as $databox)
- {
- foreach ($databox->get_collections() as $collection)
- {
+ foreach ($appbox->get_databoxes() as $databox) {
+ foreach ($databox->get_collections() as $collection) {
$base_id = $collection->get_base_id();
self::$user->ACL()->give_access_to_base(array($base_id));
@@ -423,10 +386,8 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract
public function testGet_mask_xor()
{
$appbox = appbox::get_instance(\bootstrap::getCore());
- foreach ($appbox->get_databoxes() as $databox)
- {
- foreach ($databox->get_collections() as $collection)
- {
+ foreach ($appbox->get_databoxes() as $databox) {
+ foreach ($databox->get_collections() as $collection) {
$base_id = $collection->get_base_id();
self::$user->ACL()->give_access_to_base(array($base_id));
@@ -446,13 +407,11 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract
public function testHas_access_to_base()
{
- $appbox = appbox::get_instance(\bootstrap::getCore());
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$base_ids = array();
$n = 0;
- foreach ($appbox->get_databoxes() as $databox)
- {
- foreach ($databox->get_collections() as $collection)
- {
+ foreach ($appbox->get_databoxes() as $databox) {
+ foreach ($databox->get_collections() as $collection) {
$base_ids[] = $collection->get_base_id();
$n ++;
}
@@ -468,27 +427,26 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract
$this->assertEquals(count($base_ids), count($bases));
- $sql = 'SELECT actif FROM basusr WHERE usr_id = :usr_id AND base_id = :base_id';
+ $sql = 'SELECT actif FROM basusr WHERE usr_id = :usr_id AND base_id = :base_id';
$stmt = $appbox->get_connection()->prepare($sql);
- foreach ($bases as $base_id)
- {
+ foreach ($bases as $base_id) {
$stmt->execute(array(':usr_id' => $appbox->get_session()->get_usr_id(), ':base_id' => $base_id));
- $row = $stmt->fetch(PDO::FETCH_ASSOC);
+ $row = $stmt->fetch(PDO::FETCH_ASSOC);
$this->assertEquals(1, $row['actif']);
$this->assertTrue(self::$user->ACL()->has_access_to_base($base_id));
self::$user->ACL()->update_rights_to_base($base_id, array('actif' => false));
$stmt->execute(array(':usr_id' => $appbox->get_session()->get_usr_id(), ':base_id' => $base_id));
- $row = $stmt->fetch(PDO::FETCH_ASSOC);
+ $row = $stmt->fetch(PDO::FETCH_ASSOC);
$this->assertEquals(0, $row['actif']);
$this->assertFalse(self::$user->ACL()->has_access_to_base($base_id));
self::$user->ACL()->update_rights_to_base($base_id, array('actif' => true));
$stmt->execute(array(':usr_id' => $appbox->get_session()->get_usr_id(), ':base_id' => $base_id));
- $row = $stmt->fetch(PDO::FETCH_ASSOC);
+ $row = $stmt->fetch(PDO::FETCH_ASSOC);
$this->assertEquals(1, $row['actif']);
$this->assertTrue(self::$user->ACL()->has_access_to_base($base_id));
@@ -497,8 +455,7 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract
}
self::$user->ACL()->give_access_to_base($base_ids);
- foreach ($bases as $base_id)
- {
+ foreach ($bases as $base_id) {
$this->assertTrue(self::$user->ACL()->has_access_to_base($base_id));
}
$stmt->closeCursor();
@@ -507,13 +464,11 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract
public function testGet_granted_base()
{
- $appbox = appbox::get_instance(\bootstrap::getCore());
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$base_ids = array();
$n = 0;
- foreach ($appbox->get_databoxes() as $databox)
- {
- foreach ($databox->get_collections() as $collection)
- {
+ foreach ($appbox->get_databoxes() as $databox) {
+ foreach ($databox->get_collections() as $collection) {
$base_ids[] = $collection->get_base_id();
$n ++;
}
@@ -528,17 +483,13 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract
$this->assertEquals(count($bases), count($base_ids));
$this->assertEquals($n, count($base_ids));
- foreach ($bases as $base_id)
- {
- try
- {
+ foreach ($bases as $base_id) {
+ try {
$collection = collection::get_from_base_id($base_id);
$this->assertTrue($collection instanceof collection);
$this->assertEquals($base_id, $collection->get_base_id());
unset($collection);
- }
- catch (Exception $e)
- {
+ } catch (Exception $e) {
$this->fail('get granted base should returned OK collection');
}
}
@@ -546,11 +497,10 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract
public function testGet_granted_sbas()
{
- $appbox = appbox::get_instance(\bootstrap::getCore());
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$sbas_ids = array();
$n = 0;
- foreach ($appbox->get_databoxes() as $databox)
- {
+ foreach ($appbox->get_databoxes() as $databox) {
$sbas_ids[] = $databox->get_sbas_id();
$n ++;
}
@@ -561,16 +511,12 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract
$this->assertEquals(count($sbas), count($sbas_ids));
$this->assertEquals($n, count($sbas_ids));
- foreach ($sbas as $sbas_id => $databox)
- {
- try
- {
+ foreach ($sbas as $sbas_id => $databox) {
+ try {
$this->assertTrue($databox instanceof databox);
$this->assertEquals($sbas_id, $databox->get_sbas_id());
unset($databox);
- }
- catch (Exception $e)
- {
+ } catch (Exception $e) {
$this->fail('get granted sbas should returned OK collection');
}
}
@@ -580,12 +526,10 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract
{
$appbox = appbox::get_instance(\bootstrap::getCore());
- foreach ($appbox->get_databoxes() as $databox)
- {
+ foreach ($appbox->get_databoxes() as $databox) {
$base_ids = array();
- foreach ($databox->get_collections() as $collection)
- {
- $base_id = $collection->get_base_id();
+ foreach ($databox->get_collections() as $collection) {
+ $base_id = $collection->get_base_id();
$base_ids[] = $base_id;
}
self::$user->ACL()->revoke_access_from_bases($base_ids);
@@ -601,14 +545,12 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract
$this->assertFalse(self::$user->ACL()->has_access_to_module('report'));
$found = false;
- foreach ($appbox->get_databoxes() as $databox)
- {
- foreach ($databox->get_collections() as $collection)
- {
- $base_id = $collection->get_base_id();
+ foreach ($appbox->get_databoxes() as $databox) {
+ foreach ($databox->get_collections() as $collection) {
+ $base_id = $collection->get_base_id();
$base_ids[] = $base_id;
self::$user->ACL()->update_rights_to_base($base_id, array('canreport' => true));
- $found = true;
+ $found = true;
break;
}
if ($found)
@@ -618,10 +560,9 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract
$this->assertFalse(self::$user->ACL()->has_access_to_module('thesaurus'));
$this->assertFalse(self::$user->ACL()->has_access_to_module('upload'));
- foreach ($appbox->get_databoxes() as $databox)
- {
+ foreach ($appbox->get_databoxes() as $databox) {
self::$user->ACL()->update_rights_to_sbas($databox->get_sbas_id(), array('bas_modif_th' => true));
- $found = true;
+ $found = true;
}
$this->assertTrue(self::$user->ACL()->has_access_to_module('report'));
$this->assertTrue(self::$user->ACL()->has_access_to_module('thesaurus'));
@@ -629,14 +570,12 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract
$found = false;
- foreach ($appbox->get_databoxes() as $databox)
- {
- foreach ($databox->get_collections() as $collection)
- {
- $base_id = $collection->get_base_id();
+ foreach ($appbox->get_databoxes() as $databox) {
+ foreach ($databox->get_collections() as $collection) {
+ $base_id = $collection->get_base_id();
$base_ids[] = $base_id;
self::$user->ACL()->update_rights_to_base($base_id, array('canaddrecord' => true));
- $found = true;
+ $found = true;
break;
}
if ($found)
@@ -653,10 +592,8 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract
$found = false;
- foreach ($appbox->get_databoxes() as $databox)
- {
- foreach ($databox->get_collections() as $collection)
- {
+ foreach ($appbox->get_databoxes() as $databox) {
+ foreach ($databox->get_collections() as $collection) {
$base_id = $collection->get_base_id();
if ( ! self::$user->ACL()->has_access_to_base($base_id))
@@ -702,10 +639,8 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract
$found = false;
- foreach ($appbox->get_databoxes() as $databox)
- {
- foreach ($databox->get_collections() as $collection)
- {
+ foreach ($appbox->get_databoxes() as $databox) {
+ foreach ($databox->get_collections() as $collection) {
$base_id = $collection->get_base_id();
if ( ! self::$user->ACL()->has_access_to_base($base_id))
@@ -751,5 +686,4 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract
{
$this->testget_limits();
}
-
}
diff --git a/tests/Alchemy/Phrasea/Application/ApiJsonTest.php b/tests/Alchemy/Phrasea/Application/ApiJsonTest.php
index aa34115b3c..1b5ff2bc00 100644
--- a/tests/Alchemy/Phrasea/Application/ApiJsonTest.php
+++ b/tests/Alchemy/Phrasea/Application/ApiJsonTest.php
@@ -55,6 +55,7 @@ class ApiJsonApplication extends PhraseanetWebTestCaseAbstract
public function tearDown()
{
$this->unsetToken();
+ parent::tearDown();
}
public static function setUpBeforeClass()
@@ -91,6 +92,7 @@ class ApiJsonApplication extends PhraseanetWebTestCaseAbstract
self::$adminAccount->delete();
self::$adminApplication->delete();
}
+ parent::tearDownAfterClass();
}
public function createApplication()
@@ -1429,8 +1431,8 @@ class ApiJsonApplication extends PhraseanetWebTestCaseAbstract
$this->assertTrue(is_object($record->technical_informations));
foreach ($record->technical_informations as $key => $value) {
- if(is_string($value))
- $this->assertFalse(ctype_digit ($value));
+ if (is_string($value))
+ $this->assertFalse(ctype_digit($value));
else
$this->assertTrue(is_int($value));
}
diff --git a/tests/Alchemy/Phrasea/Application/ApiYamlTest.php b/tests/Alchemy/Phrasea/Application/ApiYamlTest.php
index 77b6310234..6221e1a145 100644
--- a/tests/Alchemy/Phrasea/Application/ApiYamlTest.php
+++ b/tests/Alchemy/Phrasea/Application/ApiYamlTest.php
@@ -61,6 +61,7 @@ class ApiYamlApplication extends PhraseanetWebTestCaseAbstract
public function tearDown()
{
$this->unsetToken();
+ parent::tearDown();
}
public static function setUpBeforeClass()
@@ -96,6 +97,7 @@ class ApiYamlApplication extends PhraseanetWebTestCaseAbstract
self::$adminAccount->delete();
self::$adminApplication->delete();
}
+ parent::tearDownAfterClass();
}
public function createApplication()
diff --git a/tests/Alchemy/Phrasea/Application/LightboxTest.php b/tests/Alchemy/Phrasea/Application/LightboxTest.php
index ab8fb72bb8..cf82eb3f38 100644
--- a/tests/Alchemy/Phrasea/Application/LightboxTest.php
+++ b/tests/Alchemy/Phrasea/Application/LightboxTest.php
@@ -7,321 +7,317 @@ use Symfony\Component\HttpFoundation\Response;
class ApplicationLightboxTest extends PhraseanetWebTestCaseAuthenticatedAbstract
{
+ protected $client;
+ protected $feed;
+ protected $entry;
+ protected $item;
+ protected $validation_basket;
+ protected static $need_records = 1;
- protected $client;
- protected $feed;
- protected $entry;
- protected $item;
- protected $validation_basket;
- protected static $need_records = 1;
+ public function setUp()
+ {
+ parent::setUp();
+ $this->client = $this->createClient();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $this->feed = Feed_Adapter::create($appbox, self::$user, "salut", 'coucou');
+ $publisher = array_shift($this->feed->get_publishers());
+ $this->entry = Feed_Entry_Adapter::create($appbox, $this->feed, $publisher, 'title', "sub Titkle", " jean pierre", "jp@test.com");
+ $this->item = Feed_Entry_Item::create($appbox, $this->entry, self::$record_1);
+ }
-// protected static $need_subdefs = true;
+ public function tearDown()
+ {
+ if ($this->feed instanceof Feed_Adapter)
+ $this->feed->delete();
+ parent::tearDown();
+ }
- public function setUp()
- {
- parent::setUp();
- $this->client = $this->createClient();
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $this->feed = Feed_Adapter::create($appbox, self::$user, "salut", 'coucou');
- $publisher = array_shift($this->feed->get_publishers());
- $this->entry = Feed_Entry_Adapter::create($appbox, $this->feed, $publisher, 'title', "sub Titkle", " jean pierre", "jp@test.com");
- $this->item = Feed_Entry_Item::create($appbox, $this->entry, self::$record_1);
- }
+ public function createApplication()
+ {
+ return require __DIR__ . '/../../../../lib/Alchemy/Phrasea/Application/Lightbox.php';
+ }
- public function tearDown()
- {
- if($this->feed instanceof Feed_Adapter)
- $this->feed->delete();
- parent::tearDown();
- }
+ public function testRouteSlash()
+ {
+ $baskets = $this->insertFiveBasket();
- public function createApplication()
- {
- return require __DIR__ . '/../../../../lib/Alchemy/Phrasea/Application/Lightbox.php';
- }
+ $this->set_user_agent(self::USER_AGENT_FIREFOX8MAC);
- public function testRouteSlash()
- {
- $baskets = $this->insertFiveBasket();
+ $crawler = $this->client->request('GET', '/');
+ $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->assertEquals('UTF-8', $this->client->getResponse()->getCharset());
+ $this->assertEquals(5, $crawler->filter('div.basket_wrapper')->count());
- $this->set_user_agent(self::USER_AGENT_FIREFOX8MAC);
+ $this->set_user_agent(self::USER_AGENT_IE6);
- $crawler = $this->client->request('GET', '/');
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
- $this->assertEquals('UTF-8', $this->client->getResponse()->getCharset());
- $this->assertEquals(5, $crawler->filter('div.basket_wrapper')->count());
+ $crawler = $this->client->request('GET', '/');
+ $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->assertEquals('UTF-8', $this->client->getResponse()->getCharset());
+ $this->assertEquals($crawler->filter('div.basket_wrapper')->count(), count($baskets));
- $this->set_user_agent(self::USER_AGENT_IE6);
+ $this->set_user_agent(self::USER_AGENT_IPHONE);
- $crawler = $this->client->request('GET', '/');
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
- $this->assertEquals('UTF-8', $this->client->getResponse()->getCharset());
- $this->assertEquals($crawler->filter('div.basket_wrapper')->count(), count($baskets));
+ $crawler = $this->client->request('GET', '/');
+ $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->assertEquals('UTF-8', $this->client->getResponse()->getCharset());
+ }
- $this->set_user_agent(self::USER_AGENT_IPHONE);
+ public function testAjaxNoteForm()
+ {
+ $basket = $this->insertOneValidationBasket();
+ $basket_element = $basket->getELements()->first();
- $crawler = $this->client->request('GET', '/');
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
- $this->assertEquals('UTF-8', $this->client->getResponse()->getCharset());
- }
+ $this->set_user_agent(self::USER_AGENT_FIREFOX8MAC);
- public function testAjaxNoteForm()
- {
- $basket = $this->insertOneValidationBasket();
- $basket_element = $basket->getELements()->first();
+ $crawler = $this->client->request('GET', '/ajax/NOTE_FORM/' . $basket_element->getId() . '/');
+ $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->assertEquals('', trim($this->client->getResponse()->getContent()));
- $this->set_user_agent(self::USER_AGENT_FIREFOX8MAC);
+ $this->set_user_agent(self::USER_AGENT_IE6);
- $crawler = $this->client->request('GET', '/ajax/NOTE_FORM/' . $basket_element->getId() . '/');
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
- $this->assertEquals('', trim($this->client->getResponse()->getContent()));
+ $crawler = $this->client->request('GET', '/ajax/NOTE_FORM/' . $basket_element->getId() . '/');
+ $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->assertEquals('', trim($this->client->getResponse()->getContent()));
- $this->set_user_agent(self::USER_AGENT_IE6);
+ $this->set_user_agent(self::USER_AGENT_IPHONE);
- $crawler = $this->client->request('GET', '/ajax/NOTE_FORM/' . $basket_element->getId() . '/');
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
- $this->assertEquals('', trim($this->client->getResponse()->getContent()));
+ $crawler = $this->client->request('GET', '/ajax/NOTE_FORM/' . $basket_element->getId() . '/');
+ $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->assertNotEquals('', trim($this->client->getResponse()->getContent()));
+ }
- $this->set_user_agent(self::USER_AGENT_IPHONE);
+ public function testAjaxElement()
+ {
+ $basket_element = $this->insertOneBasketElement();
- $crawler = $this->client->request('GET', '/ajax/NOTE_FORM/' . $basket_element->getId() . '/');
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
- $this->assertNotEquals('', trim($this->client->getResponse()->getContent()));
- }
+ $this->set_user_agent(self::USER_AGENT_FIREFOX8MAC);
- public function testAjaxElement()
- {
- $basket_element = $this->insertOneBasketElement();
+ $crawler = $this->client->request('GET', '/ajax/LOAD_BASKET_ELEMENT/' . $basket_element->getId() . '/');
+ $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-type'));
+ $datas = json_decode($this->client->getResponse()->getContent());
- $this->set_user_agent(self::USER_AGENT_FIREFOX8MAC);
+ $this->assertObjectHasAttribute('number', $datas);
+ $this->assertObjectHasAttribute('title', $datas);
+ $this->assertObjectHasAttribute('preview', $datas);
+ $this->assertObjectHasAttribute('options_html', $datas);
+ $this->assertObjectHasAttribute('agreement_html', $datas);
+ $this->assertObjectHasAttribute('selector_html', $datas);
+ $this->assertObjectHasAttribute('note_html', $datas);
+ $this->assertObjectHasAttribute('caption', $datas);
- $crawler = $this->client->request('GET', '/ajax/LOAD_BASKET_ELEMENT/' . $basket_element->getId() . '/');
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
- $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-type'));
- $datas = json_decode($this->client->getResponse()->getContent());
+ $this->set_user_agent(self::USER_AGENT_IE6);
- $this->assertObjectHasAttribute('number', $datas);
- $this->assertObjectHasAttribute('title', $datas);
- $this->assertObjectHasAttribute('preview', $datas);
- $this->assertObjectHasAttribute('options_html', $datas);
- $this->assertObjectHasAttribute('agreement_html', $datas);
- $this->assertObjectHasAttribute('selector_html', $datas);
- $this->assertObjectHasAttribute('note_html', $datas);
- $this->assertObjectHasAttribute('caption', $datas);
+ $crawler = $this->client->request('GET', '/ajax/LOAD_BASKET_ELEMENT/' . $basket_element->getId() . '/');
+ $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-type'));
+ $datas = json_decode($this->client->getResponse()->getContent());
- $this->set_user_agent(self::USER_AGENT_IE6);
+ $this->assertObjectHasAttribute('number', $datas);
+ $this->assertObjectHasAttribute('title', $datas);
+ $this->assertObjectHasAttribute('preview', $datas);
+ $this->assertObjectHasAttribute('options_html', $datas);
+ $this->assertObjectHasAttribute('agreement_html', $datas);
+ $this->assertObjectHasAttribute('selector_html', $datas);
+ $this->assertObjectHasAttribute('note_html', $datas);
+ $this->assertObjectHasAttribute('caption', $datas);
- $crawler = $this->client->request('GET', '/ajax/LOAD_BASKET_ELEMENT/' . $basket_element->getId() . '/');
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
- $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-type'));
- $datas = json_decode($this->client->getResponse()->getContent());
+ $this->set_user_agent(self::USER_AGENT_IPHONE);
- $this->assertObjectHasAttribute('number', $datas);
- $this->assertObjectHasAttribute('title', $datas);
- $this->assertObjectHasAttribute('preview', $datas);
- $this->assertObjectHasAttribute('options_html', $datas);
- $this->assertObjectHasAttribute('agreement_html', $datas);
- $this->assertObjectHasAttribute('selector_html', $datas);
- $this->assertObjectHasAttribute('note_html', $datas);
- $this->assertObjectHasAttribute('caption', $datas);
+ $crawler = $this->client->request('GET', '/ajax/LOAD_BASKET_ELEMENT/' . $basket_element->getId() . '/');
+ $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->assertNotEquals('application/json', $this->client->getResponse()->headers->get('Content-type'));
+ }
- $this->set_user_agent(self::USER_AGENT_IPHONE);
+ public function testAjaxFeedItem()
+ {
+ $this->set_user_agent(self::USER_AGENT_FIREFOX8MAC);
- $crawler = $this->client->request('GET', '/ajax/LOAD_BASKET_ELEMENT/' . $basket_element->getId() . '/');
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
- $this->assertNotEquals('application/json', $this->client->getResponse()->headers->get('Content-type'));
- }
+ $crawler = $this->client->request('GET', '/ajax/LOAD_FEED_ITEM/' . $this->entry->get_id() . '/' . $this->item->get_id() . '/');
+ $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-type'));
+ $datas = json_decode($this->client->getResponse()->getContent());
- public function testAjaxFeedItem()
- {
- $this->set_user_agent(self::USER_AGENT_FIREFOX8MAC);
+ $this->assertObjectHasAttribute('number', $datas);
+ $this->assertObjectHasAttribute('title', $datas);
+ $this->assertObjectHasAttribute('preview', $datas);
+ $this->assertObjectHasAttribute('options_html', $datas);
+ $this->assertObjectHasAttribute('agreement_html', $datas);
+ $this->assertObjectHasAttribute('selector_html', $datas);
+ $this->assertObjectHasAttribute('note_html', $datas);
+ $this->assertObjectHasAttribute('caption', $datas);
- $crawler = $this->client->request('GET', '/ajax/LOAD_FEED_ITEM/' . $this->entry->get_id() . '/' . $this->item->get_id() . '/');
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
- $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-type'));
- $datas = json_decode($this->client->getResponse()->getContent());
+ $this->set_user_agent(self::USER_AGENT_IE6);
- $this->assertObjectHasAttribute('number', $datas);
- $this->assertObjectHasAttribute('title', $datas);
- $this->assertObjectHasAttribute('preview', $datas);
- $this->assertObjectHasAttribute('options_html', $datas);
- $this->assertObjectHasAttribute('agreement_html', $datas);
- $this->assertObjectHasAttribute('selector_html', $datas);
- $this->assertObjectHasAttribute('note_html', $datas);
- $this->assertObjectHasAttribute('caption', $datas);
+ $crawler = $this->client->request('GET', '/ajax/LOAD_FEED_ITEM/' . $this->entry->get_id() . '/' . $this->item->get_id() . '/');
+ $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-type'));
+ $datas = json_decode($this->client->getResponse()->getContent());
- $this->set_user_agent(self::USER_AGENT_IE6);
+ $this->assertObjectHasAttribute('number', $datas);
+ $this->assertObjectHasAttribute('title', $datas);
+ $this->assertObjectHasAttribute('preview', $datas);
+ $this->assertObjectHasAttribute('options_html', $datas);
+ $this->assertObjectHasAttribute('agreement_html', $datas);
+ $this->assertObjectHasAttribute('selector_html', $datas);
+ $this->assertObjectHasAttribute('note_html', $datas);
+ $this->assertObjectHasAttribute('caption', $datas);
- $crawler = $this->client->request('GET', '/ajax/LOAD_FEED_ITEM/' . $this->entry->get_id() . '/' . $this->item->get_id() . '/');
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
- $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-type'));
- $datas = json_decode($this->client->getResponse()->getContent());
+ $this->set_user_agent(self::USER_AGENT_IPHONE);
- $this->assertObjectHasAttribute('number', $datas);
- $this->assertObjectHasAttribute('title', $datas);
- $this->assertObjectHasAttribute('preview', $datas);
- $this->assertObjectHasAttribute('options_html', $datas);
- $this->assertObjectHasAttribute('agreement_html', $datas);
- $this->assertObjectHasAttribute('selector_html', $datas);
- $this->assertObjectHasAttribute('note_html', $datas);
- $this->assertObjectHasAttribute('caption', $datas);
+ $crawler = $this->client->request('GET', '/ajax/LOAD_FEED_ITEM/' . $this->entry->get_id() . '/' . $this->item->get_id() . '/');
+ $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->assertNotEquals('application/json', $this->client->getResponse()->headers->get('Content-type'));
+ }
- $this->set_user_agent(self::USER_AGENT_IPHONE);
+ public function testValidate()
+ {
- $crawler = $this->client->request('GET', '/ajax/LOAD_FEED_ITEM/' . $this->entry->get_id() . '/' . $this->item->get_id() . '/');
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
- $this->assertNotEquals('application/json', $this->client->getResponse()->headers->get('Content-type'));
- }
+ $basket = $this->insertOneValidationBasket();
- public function testValidate()
- {
+ $this->set_user_agent(self::USER_AGENT_FIREFOX8MAC);
- $basket = $this->insertOneValidationBasket();
+ $crawler = $this->client->request('GET', '/validate/' . $basket->getId() . '/');
+ $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->assertEquals('UTF-8', $this->client->getResponse()->getCharset());
- $this->set_user_agent(self::USER_AGENT_FIREFOX8MAC);
+ $this->set_user_agent(self::USER_AGENT_IE6);
- $crawler = $this->client->request('GET', '/validate/' . $basket->getId() . '/');
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
- $this->assertEquals('UTF-8', $this->client->getResponse()->getCharset());
+ $crawler = $this->client->request('GET', '/validate/' . $basket->getId() . '/');
+ $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->assertEquals('UTF-8', $this->client->getResponse()->getCharset());
- $this->set_user_agent(self::USER_AGENT_IE6);
+ $this->set_user_agent(self::USER_AGENT_IPHONE);
- $crawler = $this->client->request('GET', '/validate/' . $basket->getId() . '/');
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
- $this->assertEquals('UTF-8', $this->client->getResponse()->getCharset());
+ $crawler = $this->client->request('GET', '/validate/' . $basket->getId() . '/');
+ $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->assertEquals('UTF-8', $this->client->getResponse()->getCharset());
+ }
- $this->set_user_agent(self::USER_AGENT_IPHONE);
+ public function testCompare()
+ {
+ $basket = $this->insertOneBasket();
- $crawler = $this->client->request('GET', '/validate/' . $basket->getId() . '/');
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
- $this->assertEquals('UTF-8', $this->client->getResponse()->getCharset());
- }
+ $this->set_user_agent(self::USER_AGENT_FIREFOX8MAC);
- public function testCompare()
- {
- $basket = $this->insertOneBasket();
+ $crawler = $this->client->request('GET', '/compare/' . $basket->getId() . '/');
+ $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->assertEquals('UTF-8', $this->client->getResponse()->getCharset());
- $this->set_user_agent(self::USER_AGENT_FIREFOX8MAC);
+ $this->set_user_agent(self::USER_AGENT_IE6);
- $crawler = $this->client->request('GET', '/compare/' . $basket->getId() . '/');
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
- $this->assertEquals('UTF-8', $this->client->getResponse()->getCharset());
+ $crawler = $this->client->request('GET', '/compare/' . $basket->getId() . '/');
+ $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->assertEquals('UTF-8', $this->client->getResponse()->getCharset());
- $this->set_user_agent(self::USER_AGENT_IE6);
+ $this->set_user_agent(self::USER_AGENT_IPHONE);
- $crawler = $this->client->request('GET', '/compare/' . $basket->getId() . '/');
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
- $this->assertEquals('UTF-8', $this->client->getResponse()->getCharset());
+ $crawler = $this->client->request('GET', '/compare/' . $basket->getId() . '/');
+ $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->assertEquals('UTF-8', $this->client->getResponse()->getCharset());
+ }
- $this->set_user_agent(self::USER_AGENT_IPHONE);
+ public function testFeedEntry()
+ {
+ $this->set_user_agent(self::USER_AGENT_FIREFOX8MAC);
- $crawler = $this->client->request('GET', '/compare/' . $basket->getId() . '/');
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
- $this->assertEquals('UTF-8', $this->client->getResponse()->getCharset());
- }
+ $crawler = $this->client->request('GET', '/feeds/entry/' . $this->entry->get_id() . '/');
+ $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->assertEquals('UTF-8', $this->client->getResponse()->getCharset());
- public function testFeedEntry()
- {
- $this->set_user_agent(self::USER_AGENT_FIREFOX8MAC);
+ $this->set_user_agent(self::USER_AGENT_IE6);
- $crawler = $this->client->request('GET', '/feeds/entry/' . $this->entry->get_id() . '/');
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
- $this->assertEquals('UTF-8', $this->client->getResponse()->getCharset());
+ $crawler = $this->client->request('GET', '/feeds/entry/' . $this->entry->get_id() . '/');
+ $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->assertEquals('UTF-8', $this->client->getResponse()->getCharset());
- $this->set_user_agent(self::USER_AGENT_IE6);
+ $this->set_user_agent(self::USER_AGENT_IPHONE);
- $crawler = $this->client->request('GET', '/feeds/entry/' . $this->entry->get_id() . '/');
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
- $this->assertEquals('UTF-8', $this->client->getResponse()->getCharset());
+ $crawler = $this->client->request('GET', '/feeds/entry/' . $this->entry->get_id() . '/');
+ $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->assertEquals('UTF-8', $this->client->getResponse()->getCharset());
+ }
- $this->set_user_agent(self::USER_AGENT_IPHONE);
+ public function testAjaxReport()
+ {
+ $validationBasket = $this->insertOneValidationBasket();
- $crawler = $this->client->request('GET', '/feeds/entry/' . $this->entry->get_id() . '/');
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
- $this->assertEquals('UTF-8', $this->client->getResponse()->getCharset());
- }
+ $this->set_user_agent(self::USER_AGENT_FIREFOX8MAC);
+ $crawler = $this->client->request('GET', '/ajax/LOAD_REPORT/' . $validationBasket->getId() . '/');
+ $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->assertEquals('UTF-8', $this->client->getResponse()->getCharset());
+ }
- public function testAjaxReport()
- {
- $validationBasket = $this->insertOneValidationBasket();
+ public function testAjaxSetNote()
+ {
+ $validationBasket = $this->insertOneValidationBasket();
+ $validationBasketElement = $validationBasket->getElements()->first();
- $this->set_user_agent(self::USER_AGENT_FIREFOX8MAC);
- $crawler = $this->client->request('GET', '/ajax/LOAD_REPORT/' . $validationBasket->getId() . '/');
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
- $this->assertEquals('UTF-8', $this->client->getResponse()->getCharset());
- }
+ $crawler = $this->client->request('POST', '/ajax/SET_NOTE/' . $validationBasketElement->getId() . '/');
+ $this->assertEquals(400, $this->client->getResponse()->getStatusCode());
- public function testAjaxSetNote()
- {
- $validationBasket = $this->insertOneValidationBasket();
- $validationBasketElement = $validationBasket->getElements()->first();
-
- $crawler = $this->client->request('POST', '/ajax/SET_NOTE/' . $validationBasketElement->getId() . '/');
- $this->assertEquals(400, $this->client->getResponse()->getStatusCode());
-
- $crawler = $this->client->request(
+ $crawler = $this->client->request(
'POST'
, '/ajax/SET_NOTE/' . $validationBasketElement->getId() . '/'
, array('note' => 'une jolie note')
- );
+ );
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode(), sprintf('set note to element %s ', $validationBasketElement->getId()));
- $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-type'));
+ $this->assertEquals(200, $this->client->getResponse()->getStatusCode(), sprintf('set note to element %s ', $validationBasketElement->getId()));
+ $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-type'));
- $datas = json_decode($this->client->getResponse()->getContent());
- $this->assertTrue(is_object($datas), 'asserting good json datas');
- $this->assertObjectHasAttribute('datas', $datas);
- $this->assertObjectHasAttribute('error', $datas);
- }
+ $datas = json_decode($this->client->getResponse()->getContent());
+ $this->assertTrue(is_object($datas), 'asserting good json datas');
+ $this->assertObjectHasAttribute('datas', $datas);
+ $this->assertObjectHasAttribute('error', $datas);
+ }
- public function testAjaxSetAgreement()
- {
- $validationBasket = $this->insertOneValidationBasket();
- $validationBasketElement = $validationBasket->getElements()->first();
+ public function testAjaxSetAgreement()
+ {
+ $validationBasket = $this->insertOneValidationBasket();
+ $validationBasketElement = $validationBasket->getElements()->first();
- $crawler = $this->client->request(
+ $crawler = $this->client->request(
'POST'
, '/ajax/SET_ELEMENT_AGREEMENT/' . $validationBasketElement->getId() . '/'
- );
- $this->assertEquals(400, $this->client->getResponse()->getStatusCode());
+ );
+ $this->assertEquals(400, $this->client->getResponse()->getStatusCode());
- $crawler = $this->client->request(
+ $crawler = $this->client->request(
'POST'
, '/ajax/SET_ELEMENT_AGREEMENT/' . $validationBasketElement->getId() . '/'
, array('agreement' => 1)
- );
+ );
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode(), sprintf('set note to element %s ', $validationBasketElement->getId()));
- $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-type'));
+ $this->assertEquals(200, $this->client->getResponse()->getStatusCode(), sprintf('set note to element %s ', $validationBasketElement->getId()));
+ $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-type'));
- $datas = json_decode($this->client->getResponse()->getContent());
- $this->assertTrue(is_object($datas), 'asserting good json datas');
- $this->assertObjectHasAttribute('datas', $datas);
- $this->assertObjectHasAttribute('error', $datas);
- }
+ $datas = json_decode($this->client->getResponse()->getContent());
+ $this->assertTrue(is_object($datas), 'asserting good json datas');
+ $this->assertObjectHasAttribute('datas', $datas);
+ $this->assertObjectHasAttribute('error', $datas);
+ }
- public function testAjaxSetRelease()
- {
- $basket = $this->insertOneBasket();
+ public function testAjaxSetRelease()
+ {
+ $basket = $this->insertOneBasket();
- $crawler = $this->client->request('POST', '/ajax/SET_RELEASE/' . $basket->getId() . '/');
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
- $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-type'));
- $datas = json_decode($this->client->getResponse()->getContent());
- $this->assertTrue(is_object($datas), 'asserting good json datas');
- $this->assertTrue($datas->error);
+ $crawler = $this->client->request('POST', '/ajax/SET_RELEASE/' . $basket->getId() . '/');
+ $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-type'));
+ $datas = json_decode($this->client->getResponse()->getContent());
+ $this->assertTrue(is_object($datas), 'asserting good json datas');
+ $this->assertTrue($datas->error);
- $validationBasket = $this->insertOneValidationBasket();
+ $validationBasket = $this->insertOneValidationBasket();
- $crawler = $this->client->request('POST', '/ajax/SET_RELEASE/' . $validationBasket->getId() . '/');
+ $crawler = $this->client->request('POST', '/ajax/SET_RELEASE/' . $validationBasket->getId() . '/');
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode(), sprintf('set note to element %s ', $validationBasket->getId()));
- $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-type'));
-
- $datas = json_decode($this->client->getResponse()->getContent());
- $this->assertTrue(is_object($datas), 'asserting good json datas');
- $this->assertObjectHasAttribute('datas', $datas);
- $this->assertObjectHasAttribute('error', $datas);
- }
+ $this->assertEquals(200, $this->client->getResponse()->getStatusCode(), sprintf('set note to element %s ', $validationBasket->getId()));
+ $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-type'));
+ $datas = json_decode($this->client->getResponse()->getContent());
+ $this->assertTrue(is_object($datas), 'asserting good json datas');
+ $this->assertObjectHasAttribute('datas', $datas);
+ $this->assertObjectHasAttribute('error', $datas);
+ }
}
diff --git a/tests/Alchemy/Phrasea/Application/OAuth2Test.php b/tests/Alchemy/Phrasea/Application/OAuth2Test.php
index 7237482df8..5e86600fc2 100644
--- a/tests/Alchemy/Phrasea/Application/OAuth2Test.php
+++ b/tests/Alchemy/Phrasea/Application/OAuth2Test.php
@@ -9,153 +9,138 @@ use Silex\WebTestCase;
* Test oauthv2 flow based on ietf authv2 spec
* @link http://tools.ietf.org/html/draft-ietf-oauth-v2-18
*/
-
-/**
- *
- *
- */
class oauthv2_application_test extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
- /**
- *
- * @var API_OAuth2_Application
- */
- public static $appli;
- public static $account_id;
- public static $account;
- public $oauth;
- protected $client;
- protected $queryParameters;
+ /**
+ *
+ * @var API_OAuth2_Application
+ */
+ public static $appli;
+ public static $account_id;
+ public static $account;
+ public $oauth;
+ protected $client;
+ protected $queryParameters;
- public static function setUpBeforeClass()
- {
- parent::setUpBeforeClass();
- $parameters = array(
- 'type' => 'web'
- , 'name' => 'test'
- , 'description' => 'une description'
- , 'callback' => 'http://callback.com/callback/'
- , 'website' => 'http://website.com/'
- );
+ public static function setUpBeforeClass()
+ {
+ parent::setUpBeforeClass();
- self::$appli = API_OAuth2_Application::create(appbox::get_instance(\bootstrap::getCore()), self::$user, 'test');
- self::$appli->set_description('une description')
+ self::$appli = API_OAuth2_Application::create(appbox::get_instance(\bootstrap::getCore()), self::$user, 'test');
+ self::$appli->set_description('une description')
->set_redirect_uri('http://callback.com/callback/')
->set_website('http://website.com/')
->set_type(API_OAuth2_Application::WEB_TYPE);
+ }
+ public static function tearDownAfterClass()
+ {
+ if (self::$appli !== false) {
+ self::deleteInsertedRow(appbox::get_instance(\bootstrap::getCore()), self::$appli);
+ }
+ parent::tearDownAfterClass();
+ }
- }
+ public function setUp()
+ {
+ parent::setUp();
+ $this->client = $this->createClient();
- public static function tearDownAfterClass()
- {
- parent::tearDownAfterClass();
- if (self::$appli !== false)
- self::deleteInsertedRow(appbox::get_instance(\bootstrap::getCore()), self::$appli);
- }
+ $this->queryParameters = array(
+ "response_type" => "code",
+ "client_id" => self::$appli->get_client_id(),
+ "redirect_uri" => self::$appli->get_redirect_uri(),
+ "scope" => "",
+ "state" => "valueTest"
+ );
+ }
- public function setUp()
- {
- parent::setUp();
- $this->client = $this->createClient();
-
- $this->queryParameters = array(
- "response_type" => "code",
- "client_id" => self::$appli->get_client_id(),
- "redirect_uri" => self::$appli->get_redirect_uri(),
- "scope" => "",
- "state" => "valueTest"
- );
- }
-
- public static function deleteInsertedRow(appbox $appbox, API_OAuth2_Application $app)
- {
- $conn = $appbox->get_connection();
- $sql = '
+ public static function deleteInsertedRow(appbox $appbox, API_OAuth2_Application $app)
+ {
+ $conn = $appbox->get_connection();
+ $sql = '
DELETE FROM api_applications
WHERE application_id = :id
';
- $t = array(':id' => $app->get_id());
- $stmt = $conn->prepare($sql);
- $stmt->execute($t);
- $sql = '
+ $t = array(':id' => $app->get_id());
+ $stmt = $conn->prepare($sql);
+ $stmt->execute($t);
+ $sql = '
DELETE FROM api_accounts
WHERE api_account_id = :id
';
- $acc = self::getAccount();
- $t = array(':id' => $acc->get_id());
- $stmt = $conn->prepare($sql);
- $stmt->execute($t);
- }
+ $acc = self::getAccount();
+ $t = array(':id' => $acc->get_id());
+ $stmt = $conn->prepare($sql);
+ $stmt->execute($t);
+ }
- public static function getApp($rowId)
- {
- $sql = "SELECT * FROM api_applications WHERE application_id = :app_id";
- $t = array(":app_id" => $rowId);
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $conn = $appbox->get_connection();
- $stmt = $conn->prepare($sql);
- $stmt->execute($t);
- $result = $stmt->fetch(PDO::FETCH_ASSOC);
+ public static function getApp($rowId)
+ {
+ $sql = "SELECT * FROM api_applications WHERE application_id = :app_id";
+ $t = array(":app_id" => $rowId);
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $conn = $appbox->get_connection();
+ $stmt = $conn->prepare($sql);
+ $stmt->execute($t);
+ $result = $stmt->fetch(PDO::FETCH_ASSOC);
- return $result;
- }
+ return $result;
+ }
public static function getAccount()
- {
- $sql = "SELECT api_account_id FROM api_accounts WHERE application_id = :app_id AND usr_id = :usr_id";
- $t = array(":app_id" => self::$appli->get_id(), ":usr_id" => self::$user->get_id());
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $conn = $appbox->get_connection();
- $stmt = $conn->prepare($sql);
- $stmt->execute($t);
- $row = $stmt->fetch(PDO::FETCH_ASSOC);
-
- return new API_OAuth2_Account(appbox::get_instance(\bootstrap::getCore()), $row["api_account_id"]);
- }
-
- public function setQueryParameters($parameter, $value)
- {
- $this->queryParameters[$parameter] = $value;
- }
-
- public function unsetQueryParameter($parameter)
- {
- if (isset($this->queryParameters[$parameter]))
- unset($this->queryParameters[$parameter]);
- }
-
- public function createApplication()
- {
- return require __DIR__ . '/../../../../lib/Alchemy/Phrasea/Application/OAuth2.php';
- }
-
- public function testAuthorizeRedirect()
- {
- //session off
- $apps = API_OAuth2_Application::load_authorized_app_by_user(appbox::get_instance(\bootstrap::getCore()), self::$user);
- foreach($apps as $app)
{
- if($app->get_client_id() == self::$appli->get_client_id())
- {
- $authorize = true;
+ $sql = "SELECT api_account_id FROM api_accounts WHERE application_id = :app_id AND usr_id = :usr_id";
+ $t = array(":app_id" => self::$appli->get_id(), ":usr_id" => self::$user->get_id());
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $conn = $appbox->get_connection();
+ $stmt = $conn->prepare($sql);
+ $stmt->execute($t);
+ $row = $stmt->fetch(PDO::FETCH_ASSOC);
- $this->client->followRedirects();
- }
+ return new API_OAuth2_Account(appbox::get_instance(\bootstrap::getCore()), $row["api_account_id"]);
}
- }
- public function testAuthorize()
- {
- $acc = self::getAccount();
- $acc->set_revoked(true); // revoked to show form
+ public function setQueryParameters($parameter, $value)
+ {
+ $this->queryParameters[$parameter] = $value;
+ }
- $crawler = $this->client->request('GET', '/authorize', $this->queryParameters);
- $this->assertTrue($this->client->getResponse()->isSuccessful());
- $this->assertRegExp("/" . self::$appli->get_client_id() . "/", $this->client->getResponse()->getContent());
- $this->assertRegExp("/" . str_replace("/", '\/', self::$appli->get_redirect_uri()) . "/", $this->client->getResponse()->getContent());
- $this->assertRegExp("/" . $this->queryParameters["response_type"] . "/", $this->client->getResponse()->getContent());
- $this->assertRegExp("/" . $this->queryParameters["scope"] . "/", $this->client->getResponse()->getContent());
- $this->assertRegExp("/" . $this->queryParameters["state"] . "/", $this->client->getResponse()->getContent());
- }
+ public function unsetQueryParameter($parameter)
+ {
+ if (isset($this->queryParameters[$parameter]))
+ unset($this->queryParameters[$parameter]);
+ }
+
+ public function createApplication()
+ {
+ return require __DIR__ . '/../../../../lib/Alchemy/Phrasea/Application/OAuth2.php';
+ }
+
+ public function testAuthorizeRedirect()
+ {
+ //session off
+ $apps = API_OAuth2_Application::load_authorized_app_by_user(appbox::get_instance(\bootstrap::getCore()), self::$user);
+ foreach ($apps as $app) {
+ if ($app->get_client_id() == self::$appli->get_client_id()) {
+ $authorize = true;
+
+ $this->client->followRedirects();
+ }
+ }
+ }
+
+ public function testAuthorize()
+ {
+ $acc = self::getAccount();
+ $acc->set_revoked(true); // revoked to show form
+
+ $crawler = $this->client->request('GET', '/authorize', $this->queryParameters);
+ $this->assertTrue($this->client->getResponse()->isSuccessful());
+ $this->assertRegExp("/" . self::$appli->get_client_id() . "/", $this->client->getResponse()->getContent());
+ $this->assertRegExp("/" . str_replace("/", '\/', self::$appli->get_redirect_uri()) . "/", $this->client->getResponse()->getContent());
+ $this->assertRegExp("/" . $this->queryParameters["response_type"] . "/", $this->client->getResponse()->getContent());
+ $this->assertRegExp("/" . $this->queryParameters["scope"] . "/", $this->client->getResponse()->getContent());
+ $this->assertRegExp("/" . $this->queryParameters["state"] . "/", $this->client->getResponse()->getContent());
+ }
}
diff --git a/tests/Alchemy/Phrasea/Application/OverviewTest.php b/tests/Alchemy/Phrasea/Application/OverviewTest.php
index 55ba9cc00b..bcb4e5955c 100644
--- a/tests/Alchemy/Phrasea/Application/OverviewTest.php
+++ b/tests/Alchemy/Phrasea/Application/OverviewTest.php
@@ -1,20 +1,5 @@
client = $this->createClient();
- }
-
- public static function setUpBeforeClass()
- {
- parent::setUpBeforeClass();
- }
-
- public static function tearDownAfterClass()
- {
- parent::tearDownAfterClass();
- }
-
- public function createApplication()
- {
- return require __DIR__ . '/../../../../lib/Alchemy/Phrasea/Application/Overview.php';
- }
-
- function testDatafilesRouteAuthenticated()
- {
- $registry = registry::get_instance();
- $crawler = $this->client->request('GET', '/datafiles/' . self::$record_1->get_sbas_id() . '/' . self::$record_1->get_record_id() . '/preview/');
- $response = $this->client->getResponse();
-
- if (self::$record_1->get_preview()->get_baseurl() !== '')
+ public function setUp()
{
- $this->assertEquals(302, $response->getStatusCode());
- $url = p4string::delEndSlash($registry->get('GV_ServerName')) . $response->headers->get('Location');
- $headers = http_query::getHttpHeaders($url);
- $this->assertEquals(self::$record_1->get_preview()->get_mime(), $headers['content_type']);
- $this->assertEquals(self::$record_1->get_preview()->get_size(), $headers['download_content_length']);
- }
- else
- {
- $this->assertEquals(200, $response->getStatusCode());
- $content_disposition = explode(';', $response->headers->get('content-disposition'));
- $this->assertEquals($content_disposition[0], 'attachment');
- $this->assertEquals(self::$record_1->get_preview()->get_mime(), $response->headers->get('content-type'));
- $this->assertEquals(self::$record_1->get_preview()->get_size(), $response->headers->get('content-length'));
+ parent::setUp();
+ $this->client = $this->createClient();
}
- $crawler = $this->client->request('GET', '/datafiles/' . self::$record_1->get_sbas_id() . '/' . self::$record_1->get_record_id() . '/asubdefthatdoesnotexists/');
- $response = $this->client->getResponse();
-
- $this->assertEquals(404, $response->getStatusCode());
- }
-
- function testDatafilesRouteNotAuthenticated()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $appbox->get_session()->logout();
- $crawler = $this->client->request('GET', '/datafiles/' . self::$record_1->get_sbas_id() . '/' . self::$record_1->get_record_id() . '/preview/');
- $response = $this->client->getResponse();
- $this->assertEquals(403, $response->getStatusCode());
-
- $crawler = $this->client->request('GET', '/datafiles/' . self::$record_1->get_sbas_id() . '/' . self::$record_1->get_record_id() . '/notfoundreview/');
- $response = $this->client->getResponse();
- $this->assertEquals(403, $response->getStatusCode());
- }
-
- function testPermalinkAuthenticated()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $this->assertTrue($appbox->get_session()->is_authenticated());
- $this->get_a_permalink();
- }
-
- function testPermalinkNotAuthenticated()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $appbox->get_session()->logout();
- $this->assertFalse($appbox->get_session()->is_authenticated());
- $this->get_a_permalink();
- }
-
- protected function get_a_permalink()
- {
- $token = self::$record_1->get_preview()->get_permalink()->get_token();
- $url = '/permalink/v1/whateverIwannt/' . self::$record_1->get_sbas_id() . '/' . self::$record_1->get_record_id() . '/' . $token . '/preview/';
-
- $crawler = $this->client->request('GET', $url);
- $response = $this->client->getResponse();
-
- if (self::$record_1->get_preview()->get_baseurl() !== '')
+ public function createApplication()
{
- $this->assertEquals(302, $response->getStatusCode());
- }
- else
- {
- $this->assertEquals(200, $response->getStatusCode());
+ return require __DIR__ . '/../../../../lib/Alchemy/Phrasea/Application/Overview.php';
}
- $url = $url . 'view/';
- $crawler = $this->client->request('GET', $url);
- $response = $this->client->getResponse();
- $this->assertEquals(200, $response->getStatusCode());
- }
+ function testDatafilesRouteAuthenticated()
+ {
+ $registry = registry::get_instance();
+ $crawler = $this->client->request('GET', '/datafiles/' . self::$record_1->get_sbas_id() . '/' . self::$record_1->get_record_id() . '/preview/');
+ $response = $this->client->getResponse();
+ if (self::$record_1->get_preview()->get_baseurl() !== '') {
+ $this->assertEquals(302, $response->getStatusCode());
+ $url = p4string::delEndSlash($registry->get('GV_ServerName')) . $response->headers->get('Location');
+ $headers = http_query::getHttpHeaders($url);
+ $this->assertEquals(self::$record_1->get_preview()->get_mime(), $headers['content_type']);
+ $this->assertEquals(self::$record_1->get_preview()->get_size(), $headers['download_content_length']);
+ } else {
+ $this->assertEquals(200, $response->getStatusCode());
+ $content_disposition = explode(';', $response->headers->get('content-disposition'));
+ $this->assertEquals($content_disposition[0], 'attachment');
+ $this->assertEquals(self::$record_1->get_preview()->get_mime(), $response->headers->get('content-type'));
+ $this->assertEquals(self::$record_1->get_preview()->get_size(), $response->headers->get('content-length'));
+ }
+
+ $crawler = $this->client->request('GET', '/datafiles/' . self::$record_1->get_sbas_id() . '/' . self::$record_1->get_record_id() . '/asubdefthatdoesnotexists/');
+ $response = $this->client->getResponse();
+
+ $this->assertEquals(404, $response->getStatusCode());
+ }
+
+ function testDatafilesRouteNotAuthenticated()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $appbox->get_session()->logout();
+ $crawler = $this->client->request('GET', '/datafiles/' . self::$record_1->get_sbas_id() . '/' . self::$record_1->get_record_id() . '/preview/');
+ $response = $this->client->getResponse();
+ $this->assertEquals(403, $response->getStatusCode());
+
+ $crawler = $this->client->request('GET', '/datafiles/' . self::$record_1->get_sbas_id() . '/' . self::$record_1->get_record_id() . '/notfoundreview/');
+ $response = $this->client->getResponse();
+ $this->assertEquals(403, $response->getStatusCode());
+ }
+
+ function testPermalinkAuthenticated()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $this->assertTrue($appbox->get_session()->is_authenticated());
+ $this->get_a_permalink();
+ }
+
+ function testPermalinkNotAuthenticated()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $appbox->get_session()->logout();
+ $this->assertFalse($appbox->get_session()->is_authenticated());
+ $this->get_a_permalink();
+ }
+
+ protected function get_a_permalink()
+ {
+ $token = self::$record_1->get_preview()->get_permalink()->get_token();
+ $url = '/permalink/v1/whateverIwannt/' . self::$record_1->get_sbas_id() . '/' . self::$record_1->get_record_id() . '/' . $token . '/preview/';
+
+ $crawler = $this->client->request('GET', $url);
+ $response = $this->client->getResponse();
+
+ if (self::$record_1->get_preview()->get_baseurl() !== '') {
+ $this->assertEquals(302, $response->getStatusCode());
+ } else {
+ $this->assertEquals(200, $response->getStatusCode());
+ }
+
+ $url = $url . 'view/';
+ $crawler = $this->client->request('GET', $url);
+ $response = $this->client->getResponse();
+ $this->assertEquals(200, $response->getStatusCode());
+ }
}
diff --git a/tests/Alchemy/Phrasea/Application/RootTest.php b/tests/Alchemy/Phrasea/Application/RootTest.php
index ae676e32a7..9f00d6203a 100644
--- a/tests/Alchemy/Phrasea/Application/RootTest.php
+++ b/tests/Alchemy/Phrasea/Application/RootTest.php
@@ -7,57 +7,55 @@ use Symfony\Component\HttpFoundation\Response;
class ApplicationRootTest extends PhraseanetWebTestCaseAuthenticatedAbstract
{
+ protected $client;
+ protected static $need_records = false;
- protected $client;
- protected static $need_records = false;
+ public function createApplication()
+ {
+ return require __DIR__ . '/../../../../lib/Alchemy/Phrasea/Application/Root.php';
+ }
- public function createApplication()
- {
- return require __DIR__ . '/../../../../lib/Alchemy/Phrasea/Application/Root.php';
- }
+ public function setUp()
+ {
+ parent::setUp();
+ $this->client = $this->createClient();
+ }
- public function setUp()
- {
- parent::setUp();
- $this->client = $this->createClient();
- }
+ public function testRouteSlash()
+ {
+ $crawler = $this->client->request('GET', '/');
+ $response = $this->client->getResponse();
+ $this->assertEquals(302, $response->getStatusCode());
+ $this->assertRegExp('/^\/login\/\?redirect=[\/a-zA-Z]+/', $response->headers->get('location'));
+ }
- public function testRouteSlash()
- {
- $crawler = $this->client->request('GET', '/');
- $response = $this->client->getResponse();
- $this->assertEquals(302, $response->getStatusCode());
- $this->assertRegExp('/^\/login\/\?redirect=[\/a-zA-Z]+/', $response->headers->get('location'));
- }
+ public function testRouteRobots()
+ {
+ $registry = \registry::get_instance();
- public function testRouteRobots()
- {
- $registry = \registry::get_instance();
+ $original_value = $registry->get('GV_allow_search_engine');
- $original_value = $registry->get('GV_allow_search_engine');
+ $registry->set('GV_allow_search_engine', false, \registry::TYPE_BOOLEAN);
- $registry->set('GV_allow_search_engine', false, \registry::TYPE_BOOLEAN);
+ $crawler = $this->client->request('GET', '/robots.txt');
+ $response = $this->client->getResponse();
+ $this->assertEquals(200, $response->getStatusCode());
+ $this->assertEquals('text/plain; charset=UTF-8', $response->headers->get('Content-Type'));
+ $this->assertEquals('UTF-8', $response->getCharset());
- $crawler = $this->client->request('GET', '/robots.txt');
- $response = $this->client->getResponse();
- $this->assertEquals(200, $response->getStatusCode());
- $this->assertEquals('text/plain; charset=UTF-8', $response->headers->get('Content-Type'));
- $this->assertEquals('UTF-8', $response->getCharset());
+ $this->assertRegExp('/^Disallow: \/$/m', $response->getContent());
- $this->assertRegExp('/^Disallow: \/$/m', $response->getContent());
+ $registry = \registry::get_instance();
+ $registry->set('GV_allow_search_engine', true, \registry::TYPE_BOOLEAN);
- $registry = \registry::get_instance();
- $registry->set('GV_allow_search_engine', true, \registry::TYPE_BOOLEAN);
+ $crawler = $this->client->request('GET', '/robots.txt');
+ $response = $this->client->getResponse();
+ $this->assertEquals(200, $response->getStatusCode());
+ $this->assertEquals('text/plain; charset=UTF-8', $response->headers->get('Content-Type'));
+ $this->assertEquals('UTF-8', $response->getCharset());
- $crawler = $this->client->request('GET', '/robots.txt');
- $response = $this->client->getResponse();
- $this->assertEquals(200, $response->getStatusCode());
- $this->assertEquals('text/plain; charset=UTF-8', $response->headers->get('Content-Type'));
- $this->assertEquals('UTF-8', $response->getCharset());
-
- $this->assertRegExp('/^Allow: \/$/m', $response->getContent());
-
- $registry->set('GV_allow_search_engine', $original_value, \registry::TYPE_BOOLEAN);
- }
+ $this->assertRegExp('/^Allow: \/$/m', $response->getContent());
+ $registry->set('GV_allow_search_engine', $original_value, \registry::TYPE_BOOLEAN);
+ }
}
diff --git a/tests/Alchemy/Phrasea/Application/SetupTest.php b/tests/Alchemy/Phrasea/Application/SetupTest.php
index cf98d650dd..b9db7d4cfc 100644
--- a/tests/Alchemy/Phrasea/Application/SetupTest.php
+++ b/tests/Alchemy/Phrasea/Application/SetupTest.php
@@ -21,7 +21,6 @@ class ApplicationSetupTest extends PhraseanetWebTestCaseAbstract
* @var \connection_pdo
*/
protected $connection;
-
protected $registry = array();
public function createApplication()
@@ -62,7 +61,7 @@ class ApplicationSetupTest extends PhraseanetWebTestCaseAbstract
foreach ($params as $param) {
$this->registry[$param] = $registry->get($param);
}
- $this->markTestSkipped('To review');
+ $this->markTestSkipped('To review');
}
public function tearDown()
@@ -194,24 +193,21 @@ class ApplicationSetupTest extends PhraseanetWebTestCaseAbstract
public function temporaryReInstall()
{
if (file_exists($this->root . 'config/config.yml.unitTests')) {
- if(file_exists($this->root . 'config/config.yml'))
- {
+ if (file_exists($this->root . 'config/config.yml')) {
unlink($this->root . 'config/config.yml');
}
rename($this->root . 'config/config.yml.unitTests', $this->root . 'config/config.yml');
}
if (file_exists($this->root . 'config/services.yml.unitTests')) {
- if(file_exists($this->root . 'config/services.yml'))
- {
+ if (file_exists($this->root . 'config/services.yml')) {
unlink($this->root . 'config/services.yml');
}
rename($this->root . 'config/services.yml.unitTests', $this->root . 'config/services.yml');
}
if (file_exists($this->root . 'config/connexions.yml.unitTests')) {
- if(file_exists($this->root . 'config/connexions.yml'))
- {
+ if (file_exists($this->root . 'config/connexions.yml')) {
unlink($this->root . 'config/connexions.yml');
}
diff --git a/tests/Alchemy/Phrasea/Cache/ApcCacheTest.php b/tests/Alchemy/Phrasea/Cache/ApcCacheTest.php
index 3d04c7afff..9847d1116b 100644
--- a/tests/Alchemy/Phrasea/Cache/ApcCacheTest.php
+++ b/tests/Alchemy/Phrasea/Cache/ApcCacheTest.php
@@ -4,46 +4,43 @@ require_once __DIR__ . '/../../../PhraseanetPHPUnitAbstract.class.inc';
class ApcCacheTest extends \PHPUnit_Framework_TestCase
{
+ /**
+ * @var ApcCache
+ */
+ protected $object;
- /**
- * @var ApcCache
- */
- protected $object;
-
- public function setUp()
- {
- if (!extension_loaded('apc'))
+ public function setUp()
{
- $this->markTestSkipped('Apc is not installed');
+ if ( ! extension_loaded('apc')) {
+ $this->markTestSkipped('Apc is not installed');
+ }
+ $this->object = new \Alchemy\Phrasea\Cache\ApcCache;
}
- $this->object = new \Alchemy\Phrasea\Cache\ApcCache;
- }
- public function testIsServer()
- {
- $this->assertTrue(is_bool($this->object->isServer()));
- }
+ public function testIsServer()
+ {
+ $this->assertTrue(is_bool($this->object->isServer()));
+ }
- public function testGetStats()
- {
- $this->assertTrue(is_array($this->object->getStats()) || is_null($this->object->getStats()));
- }
+ public function testGetStats()
+ {
+ $this->assertTrue(is_array($this->object->getStats()) || is_null($this->object->getStats()));
+ }
- public function testGet()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- public function testDeleteMulti()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
+ public function testGet()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+ public function testDeleteMulti()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
}
diff --git a/tests/Alchemy/Phrasea/Cache/ArrayCacheTest.php b/tests/Alchemy/Phrasea/Cache/ArrayCacheTest.php
index 08580b2806..508cc4697a 100644
--- a/tests/Alchemy/Phrasea/Cache/ArrayCacheTest.php
+++ b/tests/Alchemy/Phrasea/Cache/ArrayCacheTest.php
@@ -4,42 +4,40 @@ require_once __DIR__ . '/../../../PhraseanetPHPUnitAbstract.class.inc';
class ArrayCacheTest extends \PHPUnit_Framework_TestCase
{
+ /**
+ * @var ArrayCache
+ */
+ protected $object;
- /**
- * @var ArrayCache
- */
- protected $object;
+ public function setUp()
+ {
+ $this->object = new \Alchemy\Phrasea\Cache\ArrayCache;
+ }
- public function setUp()
- {
- $this->object = new \Alchemy\Phrasea\Cache\ArrayCache;
- }
+ public function testIsServer()
+ {
+ $this->assertTrue(is_bool($this->object->isServer()));
+ }
- public function testIsServer()
- {
- $this->assertTrue(is_bool($this->object->isServer()));
- }
+ public function testGetStats()
+ {
+ $this->assertTrue(is_array($this->object->getStats()) || is_null($this->object->getStats()));
+ }
- public function testGetStats()
- {
- $this->assertTrue(is_array($this->object->getStats()) || is_null($this->object->getStats()));
- }
-
- public function testGet()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- public function testDeleteMulti()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
+ public function testGet()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+ public function testDeleteMulti()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
}
diff --git a/tests/Alchemy/Phrasea/Cache/ManagerTest.php b/tests/Alchemy/Phrasea/Cache/ManagerTest.php
deleted file mode 100644
index 4bbc474f80..0000000000
--- a/tests/Alchemy/Phrasea/Cache/ManagerTest.php
+++ /dev/null
@@ -1,43 +0,0 @@
-object = new \Alchemy\Phrasea\Cache\Manager(self::);
- }
-
- /**
- * @covers {className}::{origMethodName}
- * @todo Implement testFlushAll().
- */
- public function testFlushAll()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @covers {className}::{origMethodName}
- * @todo Implement testGet().
- */
- public function testGet()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
-}
-
diff --git a/tests/Alchemy/Phrasea/Cache/MemcacheCacheTest.php b/tests/Alchemy/Phrasea/Cache/MemcacheCacheTest.php
index b9965a9722..39016536d0 100644
--- a/tests/Alchemy/Phrasea/Cache/MemcacheCacheTest.php
+++ b/tests/Alchemy/Phrasea/Cache/MemcacheCacheTest.php
@@ -4,55 +4,51 @@ require_once __DIR__ . '/../../../PhraseanetPHPUnitAbstract.class.inc';
class MemcacheCacheTest extends \PHPUnit_Framework_TestCase
{
+ /**
+ * @var MemcacheCache
+ */
+ protected $object;
- /**
- * @var MemcacheCache
- */
- protected $object;
-
- public function setUp()
- {
- $this->object = new \Alchemy\Phrasea\Cache\MemcacheCache;
-
- if(!class_exists('Memcache'))
+ public function setUp()
{
- $this->markTestSkipped('No memcache extension');
+ $this->object = new \Alchemy\Phrasea\Cache\MemcacheCache;
+
+ if ( ! class_exists('Memcache')) {
+ $this->markTestSkipped('No memcache extension');
+ }
+
+ $memcache = new Memcache();
+ if ( ! @$memcache->connect('localhost', 11211)) {
+ $this->markTestSkipped('No memcache server');
+ }
+
+ $this->object->setMemcache($memcache);
}
- $memcache = new Memcache();
- if(!@$memcache->connect('localhost', 11211))
+ public function testIsServer()
{
- $this->markTestSkipped('No memcache server');
+ $this->assertTrue(is_bool($this->object->isServer()));
}
- $this->object->setMemcache($memcache);
- }
+ public function testGetStats()
+ {
+ $this->assertTrue(is_array($this->object->getStats()) || is_null($this->object->getStats()));
+ }
- public function testIsServer()
- {
- $this->assertTrue(is_bool($this->object->isServer()));
- }
-
- public function testGetStats()
- {
- $this->assertTrue(is_array($this->object->getStats()) || is_null($this->object->getStats()));
- }
-
- public function testGet()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- public function testDeleteMulti()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
+ public function testGet()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+ public function testDeleteMulti()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
}
diff --git a/tests/Alchemy/Phrasea/Cache/RedisCacheTest.php b/tests/Alchemy/Phrasea/Cache/RedisCacheTest.php
index 47d8476e52..2c19ad33d6 100644
--- a/tests/Alchemy/Phrasea/Cache/RedisCacheTest.php
+++ b/tests/Alchemy/Phrasea/Cache/RedisCacheTest.php
@@ -1,70 +1,47 @@
connect('127.0.0.1', 6379);
- }
- catch(\Exception $e)
- {
- $ok = false;
- }
- if (!$ok)
- {
- $this->markTestSkipped('The ' . __CLASS__ . ' requires the use of redis');
- }
+ if (extension_loaded('Redis')) {
+ $redis = new Redis();
+ try {
+ $ok = @$redis->connect('127.0.0.1', 6379);
+ } catch (\Exception $e) {
+ $ok = false;
+ }
+ if ( ! $ok) {
+ $this->markTestSkipped('The ' . __CLASS__ . ' requires the use of redis');
+ }
+ } else {
+ $this->markTestSkipped('The ' . __CLASS__ . ' requires the use of redis');
+ }
+
+ $cache = new \Alchemy\Phrasea\Cache\RedisCache();
+ $cache->setRedis($redis);
+ // Test save
+ $cache->save('test_key', 'testing this out');
+
+ // Test contains to test that save() worked
+ $this->assertTrue($cache->contains('test_key'));
+
+ $cache->save('test_key1', 'testing this out', 20);
+
+ // Test contains to test that save() worked
+ $this->assertTrue($cache->contains('test_key1'));
+
+ // Test fetch
+ $this->assertEquals('testing this out', $cache->fetch('test_key'));
+
+ // Test delete
+ $cache->save('test_key2', 'test2');
+ $cache->delete('test_key2');
+ $this->assertFalse($cache->contains('test_key2'));
+
+ $this->assertEquals($redis, $cache->getRedis());
}
- else
- {
- $this->markTestSkipped('The ' . __CLASS__ . ' requires the use of redis');
- }
-
- $cache = new \Alchemy\Phrasea\Cache\RedisCache();
- $cache->setRedis($redis);
- // Test save
- $cache->save('test_key', 'testing this out');
-
- // Test contains to test that save() worked
- $this->assertTrue($cache->contains('test_key'));
-
- $cache->save('test_key1', 'testing this out', 20);
-
- // Test contains to test that save() worked
- $this->assertTrue($cache->contains('test_key1'));
-
- // Test fetch
- $this->assertEquals('testing this out', $cache->fetch('test_key'));
-
- // Test delete
- $cache->save('test_key2', 'test2');
- $cache->delete('test_key2');
- $this->assertFalse($cache->contains('test_key2'));
-
- $this->assertEquals($redis, $cache->getRedis());
- }
-
}
diff --git a/tests/Alchemy/Phrasea/Cache/XcacheCacheTest.php b/tests/Alchemy/Phrasea/Cache/XcacheCacheTest.php
index eb22ea3b28..ccfb93f5f7 100644
--- a/tests/Alchemy/Phrasea/Cache/XcacheCacheTest.php
+++ b/tests/Alchemy/Phrasea/Cache/XcacheCacheTest.php
@@ -4,47 +4,44 @@ require_once __DIR__ . '/../../../PhraseanetPHPUnitAbstract.class.inc';
class XcacheCacheTest extends \PHPUnit_Framework_TestCase
{
+ /**
+ * @var XcacheCache
+ */
+ protected $object;
- /**
- * @var XcacheCache
- */
- protected $object;
-
- public function setUp()
- {
- if(!function_exists('xcache_info'))
+ public function setUp()
{
- $this->markTestSkipped('Xcache not loaded');
+ if ( ! function_exists('xcache_info')) {
+ $this->markTestSkipped('Xcache not loaded');
+ }
+
+ $this->object = new \Alchemy\Phrasea\Cache\XcacheCache;
}
- $this->object = new \Alchemy\Phrasea\Cache\XcacheCache;
- }
+ public function testIsServer()
+ {
+ $this->assertTrue(is_bool($this->object->isServer()));
+ }
- public function testIsServer()
- {
- $this->assertTrue(is_bool($this->object->isServer()));
- }
+ public function testGetStats()
+ {
+ $this->assertTrue(is_array($this->object->getStats()) || is_null($this->object->getStats()));
+ }
- public function testGetStats()
- {
- $this->assertTrue(is_array($this->object->getStats()) || is_null($this->object->getStats()));
- }
-
- public function testGet()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- public function testDeleteMulti()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
+ public function testGet()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+ public function testDeleteMulti()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
}
diff --git a/tests/Alchemy/Phrasea/Controller/Admin/DescriptionTest.php b/tests/Alchemy/Phrasea/Controller/Admin/DescriptionTest.php
index 21f1711958..632c61a89f 100644
--- a/tests/Alchemy/Phrasea/Controller/Admin/DescriptionTest.php
+++ b/tests/Alchemy/Phrasea/Controller/Admin/DescriptionTest.php
@@ -4,263 +4,238 @@ require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.
class DescriptionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
+ protected $client;
+ protected static $need_records = false;
- /**
- * As controllers use WebTestCase, it requires a client
- */
- protected $client;
-
- /**
- * If the controller tests require some records, specify it her
- *
- * For example, this will loacd 2 records
- * (self::$record_1 and self::$record_2) :
- *
- * $need_records = 2;
- *
- */
- protected static $need_records = false;
-
- /**
- * The application loader
- */
- 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 testRouteDescription()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $databox = array_shift($appbox->get_databoxes());
- $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'
- ));
-
- $this->assertTrue($this->client->getResponse()->isRedirect());
- $field->delete();
- }
-
- public function testPostDelete()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $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
+ public function createApplication()
{
- $field = \databox_field::get_instance($databox, $id);
- $field->delete();
- $this->fail("should raise an exception");
+ return require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Admin.php';
}
- catch (\Exception $e)
- {
+ public function setUp()
+ {
+ parent::setUp();
+ $this->client = $this->createClient();
}
- }
- public function testPostCreate()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $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)
+ /**
+ * Default route test
+ */
+ public function testRouteDescription()
{
- if ($field->get_name() === databox_field::generateName($name))
- {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $databox = array_shift($appbox->get_databoxes());
+ $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'
+ ));
+
+ $this->assertTrue($this->client->getResponse()->isRedirect());
$field->delete();
- $find = true;
- }
}
- if (!$find)
+ public function testPostDelete()
{
- $this->fail("should have create a new field");
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $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 testPostDescriptionException()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $databox = array_shift($appbox->get_databoxes());
+ public function testPostCreate()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $databox = array_shift($appbox->get_databoxes());
- $this->client->request("POST", "/description/" . $databox->get_sbas_id() . "/", array(
- 'todelete_ids' => array('unknow_id')
- ));
+ $name = 'test' . uniqid();
- $this->assertTrue($this->client->getResponse()->isRedirect());
+ $this->client->request("POST", "/description/" . $databox->get_sbas_id() . "/", array(
+ 'newfield' => $name
+ ));
- $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'
- ));
+ $this->assertTrue($this->client->getResponse()->isRedirect());
- $this->assertTrue($this->client->getResponse()->isRedirect());
- $field->delete();
+ $fields = $databox->get_meta_structure();
+ $find = false;
- $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'
- ));
+ foreach ($fields as $field) {
+ if ($field->get_name() === databox_field::generateName($name)) {
+ $field->delete();
+ $find = true;
+ }
+ }
- $this->assertTrue($this->client->getResponse()->isRedirect());
- $field->delete();
+ if ( ! $find) {
+ $this->fail("should have create a new field");
+ }
+ }
- $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'
- ));
+ public function testPostDescriptionException()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $databox = array_shift($appbox->get_databoxes());
- $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();
+ $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'
+ ));
+
+ $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'
+ ));
+
+ $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'
+ ));
+
+ $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'
- ));
+ $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'
+ ));
- $this->assertTrue($this->client->getResponse()->isRedirect());
- $field->delete();
- }
+ $this->assertTrue($this->client->getResponse()->isRedirect());
+ $field->delete();
+ }
- public function testPostDescriptionRights()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
+ public function testPostDescriptionRights()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
- $session = $appbox->get_session();
- $auth = new Session_Authentication_None(self::$user_alt1);
- $session->authenticate($auth);
+ $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'
- ));
- $this->assertFalse($this->client->getResponse()->isOk());
- $this->assertEquals("You are not allowed to access this zone", $this->client->getResponse()->getContent());
- $field->delete();
- }
+ $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'
+ ));
+ $this->assertFalse($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(\bootstrap::getCore());
+ public function testGetDescriptionException()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
- $session = $appbox->get_session();
- $auth = new Session_Authentication_None(self::$user_alt1);
- $session->authenticate($auth);
+ $session = $appbox->get_session();
+ $auth = new Session_Authentication_None(self::$user_alt1);
+ $session->authenticate($auth);
- $databox = array_shift($appbox->get_databoxes());
+ $databox = array_shift($appbox->get_databoxes());
- $this->client->request("GET", "/description/" . $databox->get_sbas_id() . "/");
- $this->assertFalse($this->client->getResponse()->isOk());
- $this->assertEquals("You are not allowed to access this zone", $this->client->getResponse()->getContent());
- }
+ $this->client->request("GET", "/description/" . $databox->get_sbas_id() . "/");
+ $this->assertFalse($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(\bootstrap::getCore());
- $databox = array_shift($appbox->get_databoxes());
-
- $this->client->request("GET", "/description/" . $databox->get_sbas_id() . "/");
- $this->assertTrue($this->client->getResponse()->isOk());
- }
-
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $databox = array_shift($appbox->get_databoxes());
+ $this->client->request("GET", "/description/" . $databox->get_sbas_id() . "/");
+ $this->assertTrue($this->client->getResponse()->isOk());
+ }
}
diff --git a/tests/Alchemy/Phrasea/Controller/Admin/FieldsTest.php b/tests/Alchemy/Phrasea/Controller/Admin/FieldsTest.php
index e768e7f552..a6a77e545d 100644
--- a/tests/Alchemy/Phrasea/Controller/Admin/FieldsTest.php
+++ b/tests/Alchemy/Phrasea/Controller/Admin/FieldsTest.php
@@ -4,79 +4,61 @@ require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.
class ControllerFieldsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
+ protected $client;
+ protected static $need_records = false;
- /**
- * As controllers use WebTestCase, it requires a client
- */
- protected $client;
+ public function createApplication()
+ {
+ return require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Admin.php';
+ }
- /**
- * If the controller tests require some records, specify it her
- *
- * For example, this will loacd 2 records
- * (self::$record_1 and self::$record_2) :
- *
- * $need_records = 2;
- *
- */
- protected static $need_records = false;
+ public function setUp()
+ {
+ parent::setUp();
+ $this->client = $this->createClient();
+ }
- /**
- * The application loader
- */
- public function createApplication()
- {
- return require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Admin.php';
- }
+ /**
+ * Default route test
+ */
+ public function testCheckMulti()
+ {
+ $appbox = \appbox::get_instance(\bootstrap::getCore());
+ $databox = array_shift($appbox->get_databoxes());
- public function setUp()
- {
- parent::setUp();
- $this->client = $this->createClient();
- }
+ $field = \databox_field::create($databox, "test" . time());
+ $source = $field->get_source();
- /**
- * Default route test
- */
- public function testCheckMulti()
- {
- $appbox = \appbox::get_instance(\bootstrap::getCore());
- $databox = array_shift($appbox->get_databoxes());
+ $this->client->request("GET", "/fields/checkmulti/", array(
+ 'souce' => $source, 'multi' => 'false'));
- $field = \databox_field::create($databox, "test" . time());
- $source = $field->get_source();
+ $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();
+ }
- $this->client->request("GET", "/fields/checkmulti/", array(
- 'souce' => $source, 'multi' => 'false'));
+ public function testCheckReadOnly()
+ {
+ $appbox = \appbox::get_instance(\bootstrap::getCore());
+ $databox = array_shift($appbox->get_databoxes());
- $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();
- }
+ $field = \databox_field::create($databox, "test" . time());
+ $source = $field->get_source();
- public function testCheckReadOnly()
- {
- $appbox = \appbox::get_instance(\bootstrap::getCore());
- $databox = array_shift($appbox->get_databoxes());
+ $this->client->request("GET", "/fields/checkreadonly/", array(
+ 'souce' => $source, 'readonly' => 'false'));
- $field = \databox_field::create($databox, "test" . time());
- $source = $field->get_source();
-
- $this->client->request("GET", "/fields/checkreadonly/", array(
- 'souce' => $source, '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();
- }
+ $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();
+ }
}
diff --git a/tests/Alchemy/Phrasea/Controller/Admin/PublicationTest.php b/tests/Alchemy/Phrasea/Controller/Admin/PublicationTest.php
index 15694c8766..70b5f822a7 100644
--- a/tests/Alchemy/Phrasea/Controller/Admin/PublicationTest.php
+++ b/tests/Alchemy/Phrasea/Controller/Admin/PublicationTest.php
@@ -7,382 +7,360 @@ use Symfony\Component\HttpFoundation\Response;
class Module_Admin_Route_PublicationTest extends PhraseanetWebTestCaseAuthenticatedAbstract
{
+ public static $account = null;
+ public static $api = null;
+ protected $client;
- public static $account = null;
- public static $api = null;
- protected $client;
-
- public static function setUpBeforeClass()
- {
- parent::setUpBeforeClass();
- }
-
- public static function tearDownAfterClass()
- {
- parent::tearDownAfterClass();
- }
-
- public function setUp()
- {
- parent::setUp();
- $this->client = $this->createClient();
- }
-
- public function createApplication()
- {
- return require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Admin.php';
- }
-
- public function testList()
- {
- $crawler = $this->client->request('GET', '/publications/list/');
- $pageContent = $this->client->getResponse()->getContent();
- $this->assertTrue($this->client->getResponse()->isOk());
- $feeds = Feed_Collection::load_all(appbox::get_instance(\bootstrap::getCore()), self::$user);
-
- foreach ($feeds->get_feeds() as $feed)
+ public function setUp()
{
- $this->assertRegExp('/\/admin\/publications\/feed\/' . $feed->get_id() . '/', $pageContent);
- if ($feed->get_collection() != null)
- $this->assertRegExp('/' . $feed->get_collection()->get_name() . '/', $pageContent);
- if ($feed->is_owner(self::$user))
- $this->assertEquals(1, $crawler->filterXPath("//form[@action='/admin/publications/feed/" . $feed->get_id() . "/delete/']")->count());
+ parent::setUp();
+ $this->client = $this->createClient();
}
- }
- public function testCreate()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
-
- foreach ($appbox->get_databoxes() as $databox)
+ public function createApplication()
{
- foreach ($databox->get_collections() as $collection)
- {
- $base_id = $collection->get_base_id();
- break;
- }
+ return require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Admin.php';
}
- $feeds = Feed_Collection::load_all($appbox, self::$user);
- $count = sizeof($feeds->get_feeds());
- $crawler = $this->client->request('POST', '/publications/create/', array("title" => "hello", "subtitle" => "coucou", "base_id" => $base_id));
+ public function testList()
+ {
+ $crawler = $this->client->request('GET', '/publications/list/');
+ $pageContent = $this->client->getResponse()->getContent();
+ $this->assertTrue($this->client->getResponse()->isOk());
+ $feeds = Feed_Collection::load_all(appbox::get_instance(\bootstrap::getCore()), self::$user);
- $this->assertTrue($this->client->getResponse()->isRedirect('/admin/publications/list/'));
+ foreach ($feeds->get_feeds() as $feed) {
+ $this->assertRegExp('/\/admin\/publications\/feed\/' . $feed->get_id() . '/', $pageContent);
+ if ($feed->get_collection() != null)
+ $this->assertRegExp('/' . $feed->get_collection()->get_name() . '/', $pageContent);
+ if ($feed->is_owner(self::$user))
+ $this->assertEquals(1, $crawler->filterXPath("//form[@action='/admin/publications/feed/" . $feed->get_id() . "/delete/']")->count());
+ }
+ }
- $feeds = Feed_Collection::load_all(appbox::get_instance(\bootstrap::getCore()), self::$user);
- $count_after = sizeof($feeds->get_feeds());
- $this->assertGreaterThan($count, $count_after);
+ public function testCreate()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
- $feed = array_pop($feeds->get_feeds());
+ foreach ($appbox->get_databoxes() as $databox) {
+ foreach ($databox->get_collections() as $collection) {
+ $base_id = $collection->get_base_id();
+ break;
+ }
+ }
+ $feeds = Feed_Collection::load_all($appbox, self::$user);
+ $count = sizeof($feeds->get_feeds());
- $feed->delete();
- }
+ $crawler = $this->client->request('POST', '/publications/create/', array("title" => "hello", "subtitle" => "coucou", "base_id" => $base_id));
- public function testGetFeed()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $feed = Feed_Adapter::create($appbox, self::$user, "salut", 'coucou');
- $crawler = $this->client->request('GET', '/publications/feed/' . $feed->get_id() . '/');
- $this->assertTrue($this->client->getResponse()->isOk());
- $this->assertEquals(1, $crawler->filterXPath("//form[@action='/admin/publications/feed/" . $feed->get_id() . "/update/']")->count());
- $this->assertEquals(1, $crawler->filterXPath("//input[@value='salut']")->count());
- $this->assertEquals(1, $crawler->filterXPath("//input[@value='coucou']")->count());
+ $this->assertTrue($this->client->getResponse()->isRedirect('/admin/publications/list/'));
- $feed->delete();
- }
+ $feeds = Feed_Collection::load_all(appbox::get_instance(\bootstrap::getCore()), self::$user);
+ $count_after = sizeof($feeds->get_feeds());
+ $this->assertGreaterThan($count, $count_after);
- public function testUpdateFeedNotOwner()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
- //is not owner
- $stub = $this->getMock("user_adapter", array(), array(), "", false);
- //return a different userid
- $stub->expects($this->any())->method("get_id")->will($this->returnValue(99999999));
+ $feed = array_pop($feeds->get_feeds());
- $feed = Feed_Adapter::create($appbox, $stub, "salut", 'coucou');
- $this->client->request("POST", "/publications/feed/" . $feed->get_id() . "/update/");
- $this->assertTrue($this->client->getResponse()->isRedirect(), 'update fails, i\'m redirected');
- $this->assertTrue(
+ $feed->delete();
+ }
+
+ public function testGetFeed()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $feed = Feed_Adapter::create($appbox, self::$user, "salut", 'coucou');
+ $crawler = $this->client->request('GET', '/publications/feed/' . $feed->get_id() . '/');
+ $this->assertTrue($this->client->getResponse()->isOk());
+ $this->assertEquals(1, $crawler->filterXPath("//form[@action='/admin/publications/feed/" . $feed->get_id() . "/update/']")->count());
+ $this->assertEquals(1, $crawler->filterXPath("//input[@value='salut']")->count());
+ $this->assertEquals(1, $crawler->filterXPath("//input[@value='coucou']")->count());
+
+ $feed->delete();
+ }
+
+ public function testUpdateFeedNotOwner()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ //is not owner
+ $stub = $this->getMock("user_adapter", array(), array(), "", false);
+ //return a different userid
+ $stub->expects($this->any())->method("get_id")->will($this->returnValue(99999999));
+
+ $feed = Feed_Adapter::create($appbox, $stub, "salut", 'coucou');
+ $this->client->request("POST", "/publications/feed/" . $feed->get_id() . "/update/");
+ $this->assertTrue($this->client->getResponse()->isRedirect(), 'update fails, i\'m redirected');
+ $this->assertTrue(
strpos(
- $this->client->getResponse()->headers->get('Location')
- , '/admin/publications/feed/' . $feed->get_id() . '/?'
+ $this->client->getResponse()->headers->get('Location')
+ , '/admin/publications/feed/' . $feed->get_id() . '/?'
) === 0);
- $feed->delete();
- }
+ $feed->delete();
+ }
- public function testUpdatedFeedException()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
+ public function testUpdatedFeedException()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
- $feed = Feed_Adapter::create($appbox, self::$user, "salut", 'coucou');
+ $feed = Feed_Adapter::create($appbox, self::$user, "salut", 'coucou');
- $this->client->request("POST", "/publications/feed/" . $feed->get_id() . "/update/", array(
- 'title' => 'test'
- , 'subtitle' => 'test'
- , 'public' => '1'
- ));
+ $this->client->request("POST", "/publications/feed/" . $feed->get_id() . "/update/", array(
+ 'title' => 'test'
+ , 'subtitle' => 'test'
+ , 'public' => '1'
+ ));
- $feed = new Feed_Adapter($appbox, $feed->get_id());
+ $feed = new Feed_Adapter($appbox, $feed->get_id());
- $this->assertTrue(
+ $this->assertTrue(
strpos(
- $this->client->getResponse()->headers->get('Location')
- , '/admin/publications/list/'
+ $this->client->getResponse()->headers->get('Location')
+ , '/admin/publications/list/'
) === 0);
- $this->assertEquals('test', $feed->get_title());
- $this->assertEquals('test', $feed->get_subtitle());
- $this->assertTrue($feed->is_public());
- $this->assertNull($feed->get_collection());
+ $this->assertEquals('test', $feed->get_title());
+ $this->assertEquals('test', $feed->get_subtitle());
+ $this->assertTrue($feed->is_public());
+ $this->assertNull($feed->get_collection());
- $feed->delete();
- }
+ $feed->delete();
+ }
- public function testUpdatedFeedOwner()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
+ public function testUpdatedFeedOwner()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
- $feed = Feed_Adapter::create($appbox, self::$user, "salut", 'coucou');
+ $feed = Feed_Adapter::create($appbox, self::$user, "salut", 'coucou');
- $this->client->request("POST", "/publications/feed/" . $feed->get_id() . "/update/", array(
- 'title' => 'test'
- , 'subtitle' => 'test'
- , 'public' => '1'
- , 'base_id' => self::$collection->get_base_id()
- ));
+ $this->client->request("POST", "/publications/feed/" . $feed->get_id() . "/update/", array(
+ 'title' => 'test'
+ , 'subtitle' => 'test'
+ , 'public' => '1'
+ , 'base_id' => self::$collection->get_base_id()
+ ));
- $this->assertTrue(
+ $this->assertTrue(
strpos(
- $this->client->getResponse()->headers->get('Location')
- , '/admin/publications/list/'
+ $this->client->getResponse()->headers->get('Location')
+ , '/admin/publications/list/'
) === 0);
- $feed = new Feed_Adapter($appbox, $feed->get_id());
+ $feed = new Feed_Adapter($appbox, $feed->get_id());
- $collection = $feed->get_collection();
+ $collection = $feed->get_collection();
- $this->assertEquals('test', $feed->get_title());
- $this->assertEquals('test', $feed->get_subtitle());
- $this->assertFalse($feed->is_public());
- $this->assertEquals(self::$collection->get_base_id(), $collection->get_base_id());
+ $this->assertEquals('test', $feed->get_title());
+ $this->assertEquals('test', $feed->get_subtitle());
+ $this->assertFalse($feed->is_public());
+ $this->assertEquals(self::$collection->get_base_id(), $collection->get_base_id());
- $this->assertTrue(
+ $this->assertTrue(
strpos(
- $this->client->getResponse()->headers->get('Location')
- , '/admin/publications/list/'
+ $this->client->getResponse()->headers->get('Location')
+ , '/admin/publications/list/'
) === 0);
- $feed->delete();
- }
+ $feed->delete();
+ }
- public function testIconUploadErrorOwner()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
+ public function testIconUploadErrorOwner()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
- //is not owner
- $stub = $this->getMock("user_adapter", array(), array(), "", false);
- //return a different userid
- $stub->expects($this->any())->method("get_id")->will($this->returnValue(99999999));
+ //is not owner
+ $stub = $this->getMock("user_adapter", array(), array(), "", false);
+ //return a different userid
+ $stub->expects($this->any())->method("get_id")->will($this->returnValue(99999999));
- $feed = Feed_Adapter::create($appbox, $stub, "salut", 'coucou');
+ $feed = Feed_Adapter::create($appbox, $stub, "salut", 'coucou');
- $this->client->request("POST", "/publications/feed/" . $feed->get_id() . "/iconupload/", array(), array());
+ $this->client->request("POST", "/publications/feed/" . $feed->get_id() . "/iconupload/", array(), array());
- $response = $this->client->getResponse();
- $this->assertTrue($response->isOk());
- $this->assertRegexp("/ERROR:you are not allowed/", $response->getContent());
+ $response = $this->client->getResponse();
+ $this->assertTrue($response->isOk());
+ $this->assertRegexp("/ERROR:you are not allowed/", $response->getContent());
- $feed->delete();
- }
+ $feed->delete();
+ }
- public function testIconUploadErrorFileData()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
+ public function testIconUploadErrorFileData()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
- $feed = Feed_Adapter::create($appbox, self::$user, "salut", 'coucou');
+ $feed = Feed_Adapter::create($appbox, self::$user, "salut", 'coucou');
- $this->client->request(
+ $this->client->request(
"POST"
, "/publications/feed/" . $feed->get_id() . "/iconupload/"
, array()
- , array('Filedata' => array('error' => 1))
- );
- $response = $this->client->getResponse();
- $this->assertTrue($response->isOk());
- $this->assertRegexp("/ERROR:error while upload/", $response->getContent());
+ , array('Filedata' => array('error' => 1))
+ );
+ $response = $this->client->getResponse();
+ $this->assertTrue($response->isOk());
+ $this->assertRegexp("/ERROR:error while upload/", $response->getContent());
- $feed->delete();
- }
+ $feed->delete();
+ }
- public function testIconUploadErrorFileType()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
+ public function testIconUploadErrorFileType()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
- $feed = Feed_Adapter::create($appbox, self::$user, "salut", 'coucou');
+ $feed = Feed_Adapter::create($appbox, self::$user, "salut", 'coucou');
- $this->client->request(
+ $this->client->request(
"POST"
, "/publications/feed/" . $feed->get_id() . "/iconupload/"
, array()
- , array('Filedata' => array('error' => 0, 'tmp_name' => __DIR__ . '/../../../../testfiles/test007.ppt'))
- );
- $response = $this->client->getResponse();
- $this->assertTrue($response->isOk());
- $this->assertRegexp("/ERROR:bad filetype/", $response->getContent());
+ , array('Filedata' => array('error' => 0, 'tmp_name' => __DIR__ . '/../../../../testfiles/test007.ppt'))
+ );
+ $response = $this->client->getResponse();
+ $this->assertTrue($response->isOk());
+ $this->assertRegexp("/ERROR:bad filetype/", $response->getContent());
- $feed->delete();
- }
+ $feed->delete();
+ }
- public function testIconUpload()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
+ public function testIconUpload()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
- $feed = Feed_Adapter::create($appbox, self::$user, "salut", 'coucou');
+ $feed = Feed_Adapter::create($appbox, self::$user, "salut", 'coucou');
- copy(__DIR__ . '/../../../../testfiles/logocoll.gif', __DIR__ . '/../../../../testfiles/logocoll1.gif');
- $this->client->request(
+ copy(__DIR__ . '/../../../../testfiles/logocoll.gif', __DIR__ . '/../../../../testfiles/logocoll1.gif');
+ $this->client->request(
"POST"
, "/publications/feed/" . $feed->get_id() . "/iconupload/"
, array()
- , array('Filedata' => array('error' => 0, 'tmp_name' => __DIR__ . '/../../../../testfiles/logocoll1.gif'))
- );
- $response = $this->client->getResponse();
- $this->assertTrue($response->isOk());
+ , array('Filedata' => array('error' => 0, 'tmp_name' => __DIR__ . '/../../../../testfiles/logocoll1.gif'))
+ );
+ $response = $this->client->getResponse();
+ $this->assertTrue($response->isOk());
- $feed = new Feed_Adapter($appbox, $feed->get_id());
- try
- {
- $file = new SplFileObject(__DIR__ . '/../../../../testfiles/logocoll1.gif');
- $this->fail('logo not deleted');
- }
- catch (\Exception $e)
- {
+ $feed = new Feed_Adapter($appbox, $feed->get_id());
+ try {
+ $file = new SplFileObject(__DIR__ . '/../../../../testfiles/logocoll1.gif');
+ $this->fail('logo not deleted');
+ } catch (\Exception $e) {
+ }
+
+ $this->assertRegexp("#FILEHREF:/custom/feed_" . $feed->get_id() . ".jpg?[0-9]*#", $response->getContent());
+
+ $feed->delete();
}
- $this->assertRegexp("#FILEHREF:/custom/feed_" . $feed->get_id() . ".jpg?[0-9]*#", $response->getContent());
-
- $feed->delete();
- }
-
- public function testAddPublisher()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
-
- $feed = Feed_Adapter::create($appbox, self::$user, "salut", 'coucou');
-
- $this->client->request("POST", "/publications/feed/" . $feed->get_id() . "/addpublisher/", array(
- 'usr_id' => self::$user_alt1->get_id()
- ));
-
- $response = $this->client->getResponse();
- $this->assertTrue($response->isRedirect());
-
- $feed = new Feed_Adapter($appbox, $feed->get_id());
- $publishers = $feed->get_publishers();
-
- $this->assertTrue(isset($publishers[self::$user_alt1->get_id()]));
- $this->assertTrue(
- strpos(
- $this->client->getResponse()->headers->get('Location')
- , '/admin/publications/feed/' . $feed->get_id() . '/'
- ) === 0);
-
- $feed->delete();
- }
-
- public function testAddPublisherException()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
-
- $feed = Feed_Adapter::create($appbox, self::$user, "salut", 'coucou');
-
- $this->client->request("POST", "/publications/feed/" . $feed->get_id() . "/addpublisher/");
-
- $feed = new Feed_Adapter($appbox, $feed->get_id());
- $response = $this->client->getResponse();
- $this->assertTrue($response->isRedirect());
- $this->assertTrue(
- strpos(
- $this->client->getResponse()->headers->get('Location')
- , '/admin/publications/feed/' . $feed->get_id() . '/?err'
- ) === 0);
-
- $feed->delete();
- }
-
- public function testRemovePublisher()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
-
- $feed = Feed_Adapter::create($appbox, self::$user, "salut", 'coucou');
-
- $this->client->request("POST", "/publications/feed/" . $feed->get_id() . "/removepublisher/", array(
- 'usr_id' => self::$user_alt1->get_id()
- ));
-
- $response = $this->client->getResponse();
- $this->assertTrue($response->isRedirect());
-
- $feed = new Feed_Adapter($appbox, $feed->get_id());
- $publishers = $feed->get_publishers();
-
- $this->assertFalse(isset($publishers[self::$user_alt1->get_id()]));
- $this->assertTrue(
- strpos(
- $this->client->getResponse()->headers->get('Location')
- , '/admin/publications/feed/' . $feed->get_id() . '/'
- ) === 0);
-
- $feed->delete();
- }
-
- public function testRemovePublisherException()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
-
- $feed = Feed_Adapter::create($appbox, self::$user, "salut", 'coucou');
-
- $this->client->request("POST", "/publications/feed/" . $feed->get_id() . "/removepublisher/");
-
- $response = $this->client->getResponse();
- $this->assertTrue($response->isRedirect());
-
- $feed = new Feed_Adapter($appbox, $feed->get_id());
-
- $this->assertTrue(
- strpos(
- $this->client->getResponse()->headers->get('Location')
- , '/admin/publications/feed/' . $feed->get_id() . '/?err'
- ) === 0);
-
- $feed->delete();
- }
-
- public function testDeleteFeed()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
-
- $feed = Feed_Adapter::create($appbox, self::$user, "salut", 'coucou');
-
- $this->client->request("POST", "/publications/feed/" . $feed->get_id() . "/delete/");
-
- $response = $this->client->getResponse();
- $this->assertTrue($response->isRedirect());
-
- try
- {
- $feed = new Feed_Adapter($appbox, $feed->get_id());
- $feed->delete();
- $this->fail("fail deleting feed");
- }
- catch(\Exception $e)
+ public function testAddPublisher()
{
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $feed = Feed_Adapter::create($appbox, self::$user, "salut", 'coucou');
+
+ $this->client->request("POST", "/publications/feed/" . $feed->get_id() . "/addpublisher/", array(
+ 'usr_id' => self::$user_alt1->get_id()
+ ));
+
+ $response = $this->client->getResponse();
+ $this->assertTrue($response->isRedirect());
+
+ $feed = new Feed_Adapter($appbox, $feed->get_id());
+ $publishers = $feed->get_publishers();
+
+ $this->assertTrue(isset($publishers[self::$user_alt1->get_id()]));
+ $this->assertTrue(
+ strpos(
+ $this->client->getResponse()->headers->get('Location')
+ , '/admin/publications/feed/' . $feed->get_id() . '/'
+ ) === 0);
+
+ $feed->delete();
}
- }
+ public function testAddPublisherException()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $feed = Feed_Adapter::create($appbox, self::$user, "salut", 'coucou');
+
+ $this->client->request("POST", "/publications/feed/" . $feed->get_id() . "/addpublisher/");
+
+ $feed = new Feed_Adapter($appbox, $feed->get_id());
+ $response = $this->client->getResponse();
+ $this->assertTrue($response->isRedirect());
+ $this->assertTrue(
+ strpos(
+ $this->client->getResponse()->headers->get('Location')
+ , '/admin/publications/feed/' . $feed->get_id() . '/?err'
+ ) === 0);
+
+ $feed->delete();
+ }
+
+ public function testRemovePublisher()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+
+ $feed = Feed_Adapter::create($appbox, self::$user, "salut", 'coucou');
+
+ $this->client->request("POST", "/publications/feed/" . $feed->get_id() . "/removepublisher/", array(
+ 'usr_id' => self::$user_alt1->get_id()
+ ));
+
+ $response = $this->client->getResponse();
+ $this->assertTrue($response->isRedirect());
+
+ $feed = new Feed_Adapter($appbox, $feed->get_id());
+ $publishers = $feed->get_publishers();
+
+ $this->assertFalse(isset($publishers[self::$user_alt1->get_id()]));
+ $this->assertTrue(
+ strpos(
+ $this->client->getResponse()->headers->get('Location')
+ , '/admin/publications/feed/' . $feed->get_id() . '/'
+ ) === 0);
+
+ $feed->delete();
+ }
+
+ public function testRemovePublisherException()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+
+ $feed = Feed_Adapter::create($appbox, self::$user, "salut", 'coucou');
+
+ $this->client->request("POST", "/publications/feed/" . $feed->get_id() . "/removepublisher/");
+
+ $response = $this->client->getResponse();
+ $this->assertTrue($response->isRedirect());
+
+ $feed = new Feed_Adapter($appbox, $feed->get_id());
+
+ $this->assertTrue(
+ strpos(
+ $this->client->getResponse()->headers->get('Location')
+ , '/admin/publications/feed/' . $feed->get_id() . '/?err'
+ ) === 0);
+
+ $feed->delete();
+ }
+
+ public function testDeleteFeed()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+
+ $feed = Feed_Adapter::create($appbox, self::$user, "salut", 'coucou');
+
+ $this->client->request("POST", "/publications/feed/" . $feed->get_id() . "/delete/");
+
+ $response = $this->client->getResponse();
+ $this->assertTrue($response->isRedirect());
+
+ try {
+ $feed = new Feed_Adapter($appbox, $feed->get_id());
+ $feed->delete();
+ $this->fail("fail deleting feed");
+ } catch (\Exception $e) {
+
+ }
+ }
}
diff --git a/tests/Alchemy/Phrasea/Controller/Admin/RootTest.php b/tests/Alchemy/Phrasea/Controller/Admin/RootTest.php
index d5b4699fb6..82e1518aa8 100644
--- a/tests/Alchemy/Phrasea/Controller/Admin/RootTest.php
+++ b/tests/Alchemy/Phrasea/Controller/Admin/RootTest.php
@@ -4,47 +4,29 @@ require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.
class RootTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
+ protected $client;
+ protected static $need_records = false;
- /**
- * As controllers use WebTestCase, it requires a client
- */
- protected $client;
+ public function createApplication()
+ {
+ return require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Admin.php';
+ }
- /**
- * If the controller tests require some records, specify it her
- *
- * For example, this will loacd 2 records
- * (self::$record_1 and self::$record_2) :
- *
- * $need_records = 2;
- *
- */
- protected static $need_records = false;
+ public function setUp()
+ {
+ parent::setUp();
+ $this->client = $this->createClient();
+ }
- /**
- * The application loader
- */
- 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 testRouteSlash()
- {
- $this->client->request('GET', '/', array('section' => 'base:featured'));
- $this->assertTrue($this->client->getResponse()->isOk());
-
- $this->client->request('GET', '/');
- $this->assertTrue($this->client->getResponse()->isOk());
- }
+ /**
+ * Default route test
+ */
+ public function testRouteSlash()
+ {
+ $this->client->request('GET', '/', array('section' => 'base:featured'));
+ $this->assertTrue($this->client->getResponse()->isOk());
+ $this->client->request('GET', '/');
+ $this->assertTrue($this->client->getResponse()->isOk());
+ }
}
diff --git a/tests/Alchemy/Phrasea/Controller/Admin/SubdefsTest.php b/tests/Alchemy/Phrasea/Controller/Admin/SubdefsTest.php
index 734222f5b3..2622609336 100644
--- a/tests/Alchemy/Phrasea/Controller/Admin/SubdefsTest.php
+++ b/tests/Alchemy/Phrasea/Controller/Admin/SubdefsTest.php
@@ -4,26 +4,9 @@ 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
- *
- * For example, this will loacd 2 records
- * (self::$record_1 and self::$record_2) :
- *
- * $need_records = 2;
- *
- */
protected static $need_records = false;
- /**
- * The application loader
- */
public function createApplication()
{
return require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Admin.php';
@@ -40,7 +23,7 @@ class ControllerSubdefsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
*/
public function testRouteGetSubdef()
{
- $appbox = appbox::get_instance(\bootstrap::getCore());
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$databox = array_shift($appbox->get_databoxes());
$this->client->request("GET", "/subdefs/" . $databox->get_sbas_id() . "/");
$this->assertTrue($this->client->getResponse()->isOk());
@@ -48,13 +31,13 @@ class ControllerSubdefsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
public function testPostRouteAddSubdef()
{
- $appbox = appbox::get_instance(\bootstrap::getCore());
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$databox = array_shift($appbox->get_databoxes());
$this->client->request("POST", "/subdefs/" . $databox->get_sbas_id() . "/", array('add_subdef' => array(
- 'class' => 'thumbnail',
- 'name' => 'aname',
- 'group' => 'image'
- )));
+ 'class' => 'thumbnail',
+ 'name' => 'aname',
+ 'group' => 'image'
+ )));
$this->assertTrue($this->client->getResponse()->isRedirect());
$subdefs = $databox->get_subdef_structure();
$subdefs->get_subdef("image", "aname");
@@ -63,46 +46,43 @@ class ControllerSubdefsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
public function testPostRouteDeleteSubdef()
{
- $appbox = appbox::get_instance(\bootstrap::getCore());
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$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
- {
+ try {
$subdefs->get_subdef("image", "name");
$this->fail("should raise an exception");
- }
- catch (\Exception $e)
- {
+ } catch (\Exception $e) {
}
}
public function testPostRouteAddSubdefWithNoParams()
{
- $appbox = appbox::get_instance(\bootstrap::getCore());
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$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
- ))
+ , 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");
+ $subdef = $subdefs->get_subdef("image", "name");
/* @var $subdef \databox_subdef */
$this->assertFalse($subdef->is_downloadable());
@@ -118,5 +98,4 @@ class ControllerSubdefsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$subdefs->delete_subdef("image", "name");
}
-
}
diff --git a/tests/Alchemy/Phrasea/Controller/Admin/UsersTest.php b/tests/Alchemy/Phrasea/Controller/Admin/UsersTest.php
index 4580654881..d5272166d5 100644
--- a/tests/Alchemy/Phrasea/Controller/Admin/UsersTest.php
+++ b/tests/Alchemy/Phrasea/Controller/Admin/UsersTest.php
@@ -4,359 +4,332 @@ require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.
class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
+ protected $client;
- /**
- * As controllers use WebTestCase, it requires a client
- */
- protected $client;
+ protected static $need_records = false;
+ protected $usersParameters;
- /**
- * If the controller tests require some records, specify it her
- *
- * For example, this will loacd 2 records
- * (self::$record_1 and self::$record_2) :
- *
- * $need_records = 2;
- *
- */
- protected static $need_records = false;
- protected $usersParameters;
-
- /**
- * The application loader
- */
- public function createApplication()
- {
- return require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Admin.php';
- }
-
- public function setUp()
- {
- $this->usersParameters = array("users" => implode(';', array(self::$user->get_id(), self::$user_alt1->get_id())));
- parent::setUp();
- $this->client = $this->createClient();
- }
-
- public function testRouteRightsPost()
- {
- $this->client->request('POST', '/users/rights/', $this->usersParameters);
- $response = $this->client->getResponse();
- $this->assertTrue($response->isOk());
- }
-
- public function testRouteRightsGet()
- {
- $this->client->request('GET', '/users/rights/', $this->usersParameters);
- $response = $this->client->getResponse();
- $this->assertTrue($response->isOk());
- }
-
- public function testRouteDelete()
- {
- $appbox = \appbox::get_instance(\bootstrap::getCore());
-
- $username = uniqid('user_');
- $user = User_Adapter::create($appbox, $username, "test", $username . "@email.com", false);
- $id = $user->get_id();
-
- $this->client->request('POST', '/users/delete/', array('users' => $id));
- $response = $this->client->getResponse();
- $this->assertTrue($response->isRedirect());
- try
+ public function createApplication()
{
- $user = User_Adapter::getInstance($id, $appbox);
- $user->delete();
- $this->fail("user not deleted");
+ return require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Admin.php';
}
- catch (\Exception $e)
+
+ public function setUp()
{
-
+ parent::setUp();
+ $this->usersParameters = array("users" => implode(';', array(self::$user->get_id(), self::$user_alt1->get_id())));
+ $this->client = $this->createClient();
}
- }
- public function testRouteRightsApply()
- {
- $appbox = \appbox::get_instance(\bootstrap::getCore());
+ public function testRouteRightsPost()
+ {
+ $this->client->request('POST', '/users/rights/', $this->usersParameters);
+ $response = $this->client->getResponse();
+ $this->assertTrue($response->isOk());
+ }
- $username = uniqid('user_');
- $user = User_Adapter::create($appbox, $username, "test", $username . "@email.com", false);
+ public function testRouteRightsGet()
+ {
+ $this->client->request('GET', '/users/rights/', $this->usersParameters);
+ $response = $this->client->getResponse();
+ $this->assertTrue($response->isOk());
+ }
- $base_id = self::$collection->get_base_id();
- $_GET['values'] = 'canreport_' . $base_id . '=1&manage_' . self::$collection->get_base_id() . '=1&canpush_' . self::$collection->get_base_id() . '=1';
- $_GET['user_infos'] = "user_infos[email]=" . $user->get_email();
+ public function testRouteDelete()
+ {
+ $appbox = \appbox::get_instance(\bootstrap::getCore());
- $this->client->request('POST', '/users/rights/apply/', array('users' => $user->get_id()));
- $response = $this->client->getResponse();
- $this->assertTrue($response->isOK());
- $this->assertEquals("application/json", $response->headers->get("content-type"));
- $datas = json_decode($response->getContent());
- $this->assertTrue(is_object($datas));
- $datas = json_decode($response->getContent());
- $this->assertFalse($datas->error);
- $this->assertTrue($user->ACL()->has_right_on_base($base_id, "manage"));
- $this->assertTrue($user->ACL()->has_right_on_base($base_id, "canpush"));
- $this->assertTrue($user->ACL()->has_right_on_base($base_id, "canreport"));
- $user->delete();
- }
+ $username = uniqid('user_');
+ $user = User_Adapter::create($appbox, $username, "test", $username . "@email.com", false);
+ $id = $user->get_id();
- public function testRouteRightsApplyException()
- {
- $this->markTestIncomplete();
- $_GET = array();
- $appbox = \appbox::get_instance(\bootstrap::getCore());
- $username = uniqid('user_');
- $user = User_Adapter::create($appbox, $username, "test", $username . "@email.com", false);
- $base_id = self::$collection->get_base_id();
- $_GET['values'] = 'canreport_' . $base_id . '=1&manage_' . self::$collection->get_base_id() . '=1&canpush_' . self::$collection->get_base_id() . '=1';
- $_GET['user_infos'] = "user_infos[email]=" . $user->get_email();
- $this->client->request('POST', '/users/rights/apply/', array('users' => $user->get_id()));
- $response = $this->client->getResponse();
- $this->assertTrue($response->isOK());
- $this->assertEquals("application/json", $response->headers->get("content-type"));
- $datas = json_decode($response->getContent());
- $this->assertTrue(is_object($datas));
- $this->assertTrue($datas->error);
- $user->delete();
- }
+ $this->client->request('POST', '/users/delete/', array('users' => $id));
+ $response = $this->client->getResponse();
+ $this->assertTrue($response->isRedirect());
+ try {
+ $user = User_Adapter::getInstance($id, $appbox);
+ $user->delete();
+ $this->fail("user not deleted");
+ } catch (\Exception $e) {
- public function testRouteQuota()
- {
- $base_id = array_pop(array_keys(self::$user->ACL()->get_granted_base()));
- $params = array('base_id'=>$base_id, 'users'=>self::$user->get_id());
+ }
+ }
- $this->client->request('POST', '/users/rights/quotas/', $params);
- $response = $this->client->getResponse();
- $this->assertTrue($response->isOK());
- }
+ public function testRouteRightsApply()
+ {
+ $appbox = \appbox::get_instance(\bootstrap::getCore());
- public function testRouteQuotaAdd()
- {
- $params = array(
- 'base_id' => self::$collection->get_base_id()
- , 'quota' => '1', 'droits' => 38, 'restes' => 15);
- $this->client->request('POST', '/users/rights/quotas/apply/', $params);
- $response = $this->client->getResponse();
- $this->assertTrue($response->isOK());
- }
+ $username = uniqid('user_');
+ $user = User_Adapter::create($appbox, $username, "test", $username . "@email.com", false);
- public function testRouteQuotaRemove()
- {
- $base_id = array_pop(array_keys(self::$user->ACL()->get_granted_base()));
- $params = array('base_id'=>$base_id, 'users'=>self::$user->get_id());
+ $base_id = self::$collection->get_base_id();
+ $_GET['values'] = 'canreport_' . $base_id . '=1&manage_' . self::$collection->get_base_id() . '=1&canpush_' . self::$collection->get_base_id() . '=1';
+ $_GET['user_infos'] = "user_infos[email]=" . $user->get_email();
- $this->client->request('POST', '/users/rights/quotas/apply/', $params);
- $response = $this->client->getResponse();
- $this->assertTrue($response->isOK());
- }
+ $this->client->request('POST', '/users/rights/apply/', array('users' => $user->get_id()));
+ $response = $this->client->getResponse();
+ $this->assertTrue($response->isOK());
+ $this->assertEquals("application/json", $response->headers->get("content-type"));
+ $datas = json_decode($response->getContent());
+ $this->assertTrue(is_object($datas));
+ $datas = json_decode($response->getContent());
+ $this->assertFalse($datas->error);
+ $this->assertTrue($user->ACL()->has_right_on_base($base_id, "manage"));
+ $this->assertTrue($user->ACL()->has_right_on_base($base_id, "canpush"));
+ $this->assertTrue($user->ACL()->has_right_on_base($base_id, "canreport"));
+ $user->delete();
+ }
- public function testRouteRightTime()
- {
- $base_id = array_pop(array_keys(self::$user->ACL()->get_granted_base()));
- $params = array('base_id'=>$base_id, 'users'=>self::$user->get_id());
+ public function testRouteRightsApplyException()
+ {
+ $this->markTestIncomplete();
+ $_GET = array();
+ $appbox = \appbox::get_instance(\bootstrap::getCore());
+ $username = uniqid('user_');
+ $user = User_Adapter::create($appbox, $username, "test", $username . "@email.com", false);
+ $base_id = self::$collection->get_base_id();
+ $_GET['values'] = 'canreport_' . $base_id . '=1&manage_' . self::$collection->get_base_id() . '=1&canpush_' . self::$collection->get_base_id() . '=1';
+ $_GET['user_infos'] = "user_infos[email]=" . $user->get_email();
+ $this->client->request('POST', '/users/rights/apply/', array('users' => $user->get_id()));
+ $response = $this->client->getResponse();
+ $this->assertTrue($response->isOK());
+ $this->assertEquals("application/json", $response->headers->get("content-type"));
+ $datas = json_decode($response->getContent());
+ $this->assertTrue(is_object($datas));
+ $this->assertTrue($datas->error);
+ $user->delete();
+ }
- $this->client->request('POST', '/users/rights/time/', $params);
- $response = $this->client->getResponse();
- $this->assertTrue($response->isOK());
- }
+ public function testRouteQuota()
+ {
+ $base_id = array_pop(array_keys(self::$user->ACL()->get_granted_base()));
+ $params = array('base_id' => $base_id, 'users' => self::$user->get_id());
- public function testRouteRightTimeApply()
- {
- $appbox = \appbox::get_instance(\bootstrap::getCore());
- $username = uniqid('user_');
- $user = User_Adapter::create($appbox, $username, "test", $username . "@email.com", false);
- $base_id = self::$collection->get_base_id();
- $date = new \Datetime();
- $date->modify("-10 days");
- $dmin = $date->format(DATE_ATOM);
- $date->modify("+30 days");
- $dmax = $date->format(DATE_ATOM);
- $this->client->request('POST', '/users/rights/time/apply/', array('base_id' => $base_id, 'dmin' => $dmin, 'dmax' => $dmax, 'limit' => 1, 'users' => $user->get_id()));
- $response = $this->client->getResponse();
- $this->assertTrue($response->isOK());
+ $this->client->request('POST', '/users/rights/quotas/', $params);
+ $response = $this->client->getResponse();
+ $this->assertTrue($response->isOK());
+ }
+
+ public function testRouteQuotaAdd()
+ {
+ $params = array(
+ 'base_id' => self::$collection->get_base_id()
+ , 'quota' => '1', 'droits' => 38, 'restes' => 15);
+ $this->client->request('POST', '/users/rights/quotas/apply/', $params);
+ $response = $this->client->getResponse();
+ $this->assertTrue($response->isOK());
+ }
+
+ public function testRouteQuotaRemove()
+ {
+ $base_id = array_pop(array_keys(self::$user->ACL()->get_granted_base()));
+ $params = array('base_id' => $base_id, 'users' => self::$user->get_id());
+
+ $this->client->request('POST', '/users/rights/quotas/apply/', $params);
+ $response = $this->client->getResponse();
+ $this->assertTrue($response->isOK());
+ }
+
+ public function testRouteRightTime()
+ {
+ $base_id = array_pop(array_keys(self::$user->ACL()->get_granted_base()));
+ $params = array('base_id' => $base_id, 'users' => self::$user->get_id());
+
+ $this->client->request('POST', '/users/rights/time/', $params);
+ $response = $this->client->getResponse();
+ $this->assertTrue($response->isOK());
+ }
+
+ public function testRouteRightTimeApply()
+ {
+ $appbox = \appbox::get_instance(\bootstrap::getCore());
+ $username = uniqid('user_');
+ $user = User_Adapter::create($appbox, $username, "test", $username . "@email.com", false);
+ $base_id = self::$collection->get_base_id();
+ $date = new \Datetime();
+ $date->modify("-10 days");
+ $dmin = $date->format(DATE_ATOM);
+ $date->modify("+30 days");
+ $dmax = $date->format(DATE_ATOM);
+ $this->client->request('POST', '/users/rights/time/apply/', array('base_id' => $base_id, 'dmin' => $dmin, 'dmax' => $dmax, 'limit' => 1, 'users' => $user->get_id()));
+ $response = $this->client->getResponse();
+ $this->assertTrue($response->isOK());
// $this->assertTrue($user->ACL()->is_limited($base_id));
- $user->delete();
- }
-
- public function testRouteRightMask()
- {
- $base_id = array_pop(array_keys(self::$user->ACL()->get_granted_base()));
- $params = array('base_id'=>$base_id, 'users'=>self::$user->get_id());
-
- $this->client->request('POST', '/users/rights/masks/', $params);
- $response = $this->client->getResponse();
- $this->assertTrue($response->isOK());
- }
-
- public function testRouteRightMaskApply()
- {
- $this->markTestIncomplete();
- $base_id = self::$collection->get_base_id();
- $username = uniqid('user_');
- $user = User_Adapter::create($appbox, $username, "test", $username . "@email.com", false);
- $this->client->request('POST', '/users/rights/masks/apply/', array(
- 'base_id' => $base_id, 'vand_and', 'vand_or', 'vxor_or', 'vxor_and'
- ));
- $response = $this->client->getResponse();
- $this->assertTrue($response->isOK());
- $user->delete();
- }
-
- public function testRouteSearch()
- {
- $this->client->request('POST', '/users/search/');
- $response = $this->client->getResponse();
- $this->assertTrue($response->isOK());
- }
-
- public function testRoutesearchExport()
- {
- $this->client->request('POST', '/users/search/export/');
- $response = $this->client->getResponse();
- $this->assertTrue($response->isOK());
- $this->assertEquals("text/plain; charset=UTF-8", $response->headers->get("Content-type"));
- $this->assertEquals("attachment; filename=export.txt", $response->headers->get("content-disposition"));
- }
-
- public function testRouteThSearch()
- {
- $this->client->request('GET', '/users/typeahead/search/', array('term' => 'admin'));
- $response = $this->client->getResponse();
- $this->assertTrue($response->isOK());
- $this->assertEquals("application/json", $response->headers->get("content-type"));
- }
-
- public function testRouteApplyTp()
- {
- $appbox = \appbox::get_instance(\bootstrap::getCore());
-
- $templateName = uniqid('template_');
- $template = User_Adapter::create($appbox, $templateName, "test", $templateName . "@email.com", false);
- $template->set_template(self::$user);
-
- $username = uniqid('user_');
- $user = User_Adapter::create($appbox, $username, "test", $username . "@email.com", false);
-
- $this->client->request('POST', '/users/apply_template/', array(
- 'template' => $template->get_id()
- , 'users' => $user->get_id())
- );
-
- $response = $this->client->getResponse();
- $this->assertTrue($response->isRedirect());
-
- $template->delete();
- $user->delete();
- }
-
- public function testRouteCreateException()
- {
- $this->client->request('POST', '/users/create/', array('value' => '', 'template' => '1'));
- $response = $this->client->getResponse();
- $this->assertTrue($response->isOK());
- $this->assertEquals("application/json", $response->headers->get("content-type"));
- $datas = json_decode($response->getContent());
- $this->assertTrue(is_object($datas));
- $this->assertTrue($datas->error);
- }
-
- public function testRouteCreateExceptionUser()
- {
- $this->client->request('POST', '/users/create/', array('value' => '', 'template' => '0'));
- $response = $this->client->getResponse();
- $this->assertTrue($response->isOK());
- $this->assertEquals("application/json", $response->headers->get("content-type"));
- $datas = json_decode($response->getContent());
- $this->assertTrue(is_object($datas));
- $this->assertTrue($datas->error);
- }
-
- public function testRouteCreateUser()
- {
- $appbox = \appbox::get_instance(\bootstrap::getCore());
-
- $username = uniqid('user_');
- $user = User_Adapter::create($appbox, $username, "test", $username . "@email.com", false);
-
- $this->client->request('POST', '/users/create/', array('value' => $username . "@email.com", 'template' => '0'));
-
- $response = $this->client->getResponse();
-
- $this->assertTrue($response->isOK());
- $this->assertEquals("application/json", $response->headers->get("content-type"));
- $datas = json_decode($response->getContent());
- $this->assertTrue(is_object($datas));
- $this->assertFalse($datas->error);
-
- try
- {
- $user = \User_Adapter::getInstance((int) $datas->data, $appbox);
- $user->delete();
+ $user->delete();
}
- catch (\Exception $e)
+
+ public function testRouteRightMask()
{
- $this->fail("could not delete created user " . $e->getMessage());
+ $base_id = array_pop(array_keys(self::$user->ACL()->get_granted_base()));
+ $params = array('base_id' => $base_id, 'users' => self::$user->get_id());
+
+ $this->client->request('POST', '/users/rights/masks/', $params);
+ $response = $this->client->getResponse();
+ $this->assertTrue($response->isOK());
}
- }
-
- public function testRouteExportCsv()
- {
- $this->client->request('POST', '/users/export/csv/');
- $response = $this->client->getResponse();
- $this->assertTrue($response->isOK());
- $this->assertRegexp("#text/csv#", $response->headers->get("content-type"));
- $this->assertRegexp("#charset=UTF-8#", $response->headers->get("content-type"));
- $this->assertEquals("attachment; filename=export.txt", $response->headers->get("content-disposition"));
- }
-
-
- public function testResetRights()
- {
- $appbox = \appbox::get_instance(self::$core);
- $username = uniqid('user_');
- $user = User_Adapter::create($appbox, $username, "test", $username . "@email.com", false);
-
- $user->ACL()->give_access_to_sbas(array_keys($appbox->get_databoxes()));
-
- foreach ($appbox->get_databoxes() as $databox)
+ public function testRouteRightMaskApply()
{
+ $this->markTestIncomplete();
+ $base_id = self::$collection->get_base_id();
+ $username = uniqid('user_');
+ $user = User_Adapter::create($appbox, $username, "test", $username . "@email.com", false);
+ $this->client->request('POST', '/users/rights/masks/apply/', array(
+ 'base_id' => $base_id, 'vand_and', 'vand_or', 'vxor_or', 'vxor_and'
+ ));
+ $response = $this->client->getResponse();
+ $this->assertTrue($response->isOK());
+ $user->delete();
+ }
- $rights = array(
- 'bas_manage' => '1'
- , 'bas_modify_struct' => '1'
- , 'bas_modif_th' => '1'
- , 'bas_chupub' => '1'
- );
+ public function testRouteSearch()
+ {
+ $this->client->request('POST', '/users/search/');
+ $response = $this->client->getResponse();
+ $this->assertTrue($response->isOK());
+ }
- $user->ACL()->update_rights_to_sbas($databox->get_sbas_id(), $rights);
+ public function testRoutesearchExport()
+ {
+ $this->client->request('POST', '/users/search/export/');
+ $response = $this->client->getResponse();
+ $this->assertTrue($response->isOK());
+ $this->assertEquals("text/plain; charset=UTF-8", $response->headers->get("Content-type"));
+ $this->assertEquals("attachment; filename=export.txt", $response->headers->get("content-disposition"));
+ }
- foreach ($databox->get_collections() as $collection)
- {
- $base_id = $collection->get_base_id();
- $user->ACL()->give_access_to_base(array($base_id));
+ public function testRouteThSearch()
+ {
+ $this->client->request('GET', '/users/typeahead/search/', array('term' => 'admin'));
+ $response = $this->client->getResponse();
+ $this->assertTrue($response->isOK());
+ $this->assertEquals("application/json", $response->headers->get("content-type"));
+ }
- $rights = array(
- 'canputinalbum' => '1'
- , 'candwnldhd' => '1'
- , 'candwnldsubdef' => '1'
- , 'nowatermark' => '1'
+ public function testRouteApplyTp()
+ {
+ $appbox = \appbox::get_instance(\bootstrap::getCore());
+
+ $templateName = uniqid('template_');
+ $template = User_Adapter::create($appbox, $templateName, "test", $templateName . "@email.com", false);
+ $template->set_template(self::$user);
+
+ $username = uniqid('user_');
+ $user = User_Adapter::create($appbox, $username, "test", $username . "@email.com", false);
+
+ $this->client->request('POST', '/users/apply_template/', array(
+ 'template' => $template->get_id()
+ , 'users' => $user->get_id())
);
- $user->ACL()->update_rights_to_base($collection->get_base_id(), $rights);
- break;
- }
+ $response = $this->client->getResponse();
+ $this->assertTrue($response->isRedirect());
+
+ $template->delete();
+ $user->delete();
}
+
+ public function testRouteCreateException()
+ {
+ $this->client->request('POST', '/users/create/', array('value' => '', 'template' => '1'));
+ $response = $this->client->getResponse();
+ $this->assertTrue($response->isOK());
+ $this->assertEquals("application/json", $response->headers->get("content-type"));
+ $datas = json_decode($response->getContent());
+ $this->assertTrue(is_object($datas));
+ $this->assertTrue($datas->error);
+ }
+
+ public function testRouteCreateExceptionUser()
+ {
+ $this->client->request('POST', '/users/create/', array('value' => '', 'template' => '0'));
+ $response = $this->client->getResponse();
+ $this->assertTrue($response->isOK());
+ $this->assertEquals("application/json", $response->headers->get("content-type"));
+ $datas = json_decode($response->getContent());
+ $this->assertTrue(is_object($datas));
+ $this->assertTrue($datas->error);
+ }
+
+ public function testRouteCreateUser()
+ {
+ $appbox = \appbox::get_instance(\bootstrap::getCore());
+
+ $username = uniqid('user_');
+ $user = User_Adapter::create($appbox, $username, "test", $username . "@email.com", false);
+
+ $this->client->request('POST', '/users/create/', array('value' => $username . "@email.com", 'template' => '0'));
+
+ $response = $this->client->getResponse();
+
+ $this->assertTrue($response->isOK());
+ $this->assertEquals("application/json", $response->headers->get("content-type"));
+ $datas = json_decode($response->getContent());
+ $this->assertTrue(is_object($datas));
+ $this->assertFalse($datas->error);
+
+ try {
+ $user = \User_Adapter::getInstance((int) $datas->data, $appbox);
+ $user->delete();
+ } catch (\Exception $e) {
+ $this->fail("could not delete created user " . $e->getMessage());
+ }
+ }
+
+ public function testRouteExportCsv()
+ {
+ $this->client->request('POST', '/users/export/csv/');
+ $response = $this->client->getResponse();
+ $this->assertTrue($response->isOK());
+ $this->assertRegexp("#text/csv#", $response->headers->get("content-type"));
+ $this->assertRegexp("#charset=UTF-8#", $response->headers->get("content-type"));
+ $this->assertEquals("attachment; filename=export.txt", $response->headers->get("content-disposition"));
+ }
+
+ public function testResetRights()
+ {
+ $appbox = \appbox::get_instance(self::$core);
+ $username = uniqid('user_');
+ $user = User_Adapter::create($appbox, $username, "test", $username . "@email.com", false);
+
+ $user->ACL()->give_access_to_sbas(array_keys($appbox->get_databoxes()));
+
+ foreach ($appbox->get_databoxes() as $databox) {
+
+ $rights = array(
+ 'bas_manage' => '1'
+ , 'bas_modify_struct' => '1'
+ , 'bas_modif_th' => '1'
+ , 'bas_chupub' => '1'
+ );
+
+ $user->ACL()->update_rights_to_sbas($databox->get_sbas_id(), $rights);
+
+ foreach ($databox->get_collections() as $collection) {
+ $base_id = $collection->get_base_id();
+ $user->ACL()->give_access_to_base(array($base_id));
+
+ $rights = array(
+ 'canputinalbum' => '1'
+ , 'candwnldhd' => '1'
+ , 'candwnldsubdef' => '1'
+ , 'nowatermark' => '1'
+ );
+
+ $user->ACL()->update_rights_to_base($collection->get_base_id(), $rights);
+ break;
+ }
+ }
//
- $this->client->request('POST', '/users/rights/reset/', array('users' => $user->get_id()));
- $response = $this->client->getResponse();
- $this->assertTrue($response->isOK());
- $this->assertEquals("application/json", $response->headers->get("content-type"));
- $datas = json_decode($response->getContent());
- $this->assertTrue(is_object($datas));
- $this->assertFalse($datas->error);
- $this->assertFalse($user->ACL()->has_access_to_base($base_id));
- $user->delete();
- }
-
+ $this->client->request('POST', '/users/rights/reset/', array('users' => $user->get_id()));
+ $response = $this->client->getResponse();
+ $this->assertTrue($response->isOK());
+ $this->assertEquals("application/json", $response->headers->get("content-type"));
+ $datas = json_decode($response->getContent());
+ $this->assertTrue(is_object($datas));
+ $this->assertFalse($datas->error);
+ $this->assertFalse($user->ACL()->has_access_to_base($base_id));
+ $user->delete();
+ }
}
diff --git a/tests/Alchemy/Phrasea/Controller/BoilerPlate.php b/tests/Alchemy/Phrasea/Controller/BoilerPlate.php
index 8a2d124894..a3d611861a 100644
--- a/tests/Alchemy/Phrasea/Controller/BoilerPlate.php
+++ b/tests/Alchemy/Phrasea/Controller/BoilerPlate.php
@@ -21,49 +21,48 @@ use Symfony\Component\HttpFoundation\Response;
*/
class BoilerPlate extends \PhraseanetWebTestCaseAbstract
{
+ /**
+ * As controllers use WebTestCase, it requires a client
+ */
+ protected $client;
- /**
- * As controllers use WebTestCase, it requires a client
- */
- protected $client;
- /**
- * If the controller tests require some records, specify it her
- *
- * For example, this will loacd 2 records
- * (self::$record_1 and self::$record_2) :
- *
- * $need_records = 2;
- *
- */
- protected static $need_records = false;
+ /**
+ * If the controller tests require some records, specify it her
+ *
+ * For example, this will loacd 2 records
+ * (self::$record_1 and self::$record_2) :
+ *
+ * $need_records = 2;
+ *
+ */
+ protected static $need_records = false;
- /**
- * The application loader
- */
- public function createApplication()
- {
- return require __DIR__ . '/../../../../Path/To/Application.php';
- }
+ /**
+ * The application loader
+ */
+ public function createApplication()
+ {
+ return require __DIR__ . '/../../../../Path/To/Application.php';
+ }
- public function setUp()
- {
- parent::setUp();
- $this->client = $this->createClient();
- }
+ public function setUp()
+ {
+ parent::setUp();
+ $this->client = $this->createClient();
+ }
- public function tearDown()
- {
- parent::tearDown();
- }
+ public function tearDown()
+ {
+ parent::tearDown();
+ }
- /**
- * Default route test
- */
- public function testRouteSlash()
- {
- $this->markTestIncomplete(
+ /**
+ * Default route test
+ */
+ public function testRouteSlash()
+ {
+ $this->markTestIncomplete(
'This test has not been implemented yet.'
- );
- }
-
+ );
+ }
}
diff --git a/tests/Alchemy/Phrasea/Controller/Prod/BasketTest.php b/tests/Alchemy/Phrasea/Controller/Prod/BasketTest.php
index ac557bf83f..8bbc6bfad3 100644
--- a/tests/Alchemy/Phrasea/Controller/Prod/BasketTest.php
+++ b/tests/Alchemy/Phrasea/Controller/Prod/BasketTest.php
@@ -1,694 +1,672 @@
client = $this->createClient();
+ }
- public function setUp()
- {
- parent::setUp();
- $this->client = $this->createClient();
- }
+ public function createApplication()
+ {
+ return require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Prod.php';
+ }
- public function createApplication()
- {
- return require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Prod.php';
- }
+ public function testRootPost()
+ {
+ $route = '/baskets/';
- public function testRootPost()
- {
- $route = '/baskets/';
+ $records = array(
+ self::$record_1->get_serialize_key(),
+ self::$record_2->get_serialize_key(),
+ ' ',
+ '42',
+ self::$record_no_access->get_serialize_key()
+ );
- $records = array(
- self::$record_1->get_serialize_key(),
- self::$record_2->get_serialize_key(),
- ' ',
- '42',
- self::$record_no_access->get_serialize_key()
- );
+ $lst = implode(';', $records);
- $lst = implode(';', $records);
-
- $this->client->request(
+ $this->client->request(
'POST', $route, array(
- 'name' => 'panier',
- 'desc' => 'mon beau panier',
- 'lst' => $lst)
- );
+ 'name' => 'panier',
+ 'desc' => 'mon beau panier',
+ 'lst' => $lst)
+ );
- $response = $this->client->getResponse();
+ $response = $this->client->getResponse();
- $query = self::$core->getEntityManager()->createQuery(
+ $query = self::$core->getEntityManager()->createQuery(
'SELECT COUNT(b.id) FROM \Entities\Basket b'
- );
+ );
- $count = $query->getSingleScalarResult();
+ $count = $query->getSingleScalarResult();
- $this->assertEquals(1, $count);
+ $this->assertEquals(1, $count);
- $this->assertEquals(302, $response->getStatusCode());
+ $this->assertEquals(302, $response->getStatusCode());
- $query = self::$core->getEntityManager()->createQuery(
+ $query = self::$core->getEntityManager()->createQuery(
'SELECT b FROM \Entities\Basket b'
- );
+ );
- $basket = array_shift($query->getResult());
- /* @var $basket \Entities\Basket */
- $this->assertEquals(2, $basket->getElements()->count());
- }
+ $basket = array_shift($query->getResult());
+ /* @var $basket \Entities\Basket */
+ $this->assertEquals(2, $basket->getElements()->count());
+ }
- public function testRootPostJSON()
- {
- $route = '/baskets/';
+ public function testRootPostJSON()
+ {
+ $route = '/baskets/';
- $this->client->request(
+ $this->client->request(
'POST'
, $route
, array(
- 'name' => 'panier',
- 'desc' => 'mon beau panier',
+ 'name' => 'panier',
+ 'desc' => 'mon beau panier',
)
, array()
, array(
- "HTTP_ACCEPT" => "application/json"
+ "HTTP_ACCEPT" => "application/json"
)
- );
+ );
- $response = $this->client->getResponse();
+ $response = $this->client->getResponse();
- $query = self::$core->getEntityManager()->createQuery(
+ $query = self::$core->getEntityManager()->createQuery(
'SELECT COUNT(b.id) FROM \Entities\Basket b'
- );
+ );
- $count = $query->getSingleScalarResult();
+ $count = $query->getSingleScalarResult();
- $this->assertEquals(1, $count);
+ $this->assertEquals(1, $count);
- $this->assertEquals(200, $response->getStatusCode());
- }
-
- public function testCreateGet()
- {
- $route = '/baskets/create/';
-
- $crawler = $this->client->request('GET', $route);
-
- $response = $this->client->getResponse();
-
- $this->assertEquals(200, $response->getStatusCode());
-
- $filter = "form[action='/prod/baskets/']";
- $this->assertEquals(1, $crawler->filter($filter)->count());
-
- $filter = "form[action='/prod/baskets/'] input[name='name']";
- $this->assertEquals(1, $crawler->filter($filter)->count());
-
- $filter = "form[action='/prod/baskets/'] textarea[name='description']";
- $this->assertEquals(1, $crawler->filter($filter)->count());
- }
-
- public function testBasketGet()
- {
- $basket = $this->insertOneBasket();
-
- $route = sprintf('/baskets/%s/', $basket->getId());
-
- $crawler = $this->client->request('GET', $route);
-
- $response = $this->client->getResponse();
-
- $this->assertEquals(200, $response->getStatusCode());
- }
-
- public function testBasketDeleteElementPost()
- {
- /* @var $em \Doctrine\ORM\EntityManager */
- $em = self::$core->getEntityManager();
-
- $basket = $this->insertOneBasket();
-
- $record = self::$record_1;
-
- $basket_element = new \Entities\BasketElement();
- $basket_element->setBasket($basket);
- $basket_element->setRecord($record);
- $basket_element->setLastInBasket();
-
- $basket->addBasketElement($basket_element);
-
- $em->persist($basket);
-
- $em->flush();
-
- $route = sprintf(
- "/baskets/%s/delete/%s/", $basket->getId(), $basket_element->getId()
- );
-
- $crawler = $this->client->request('POST', $route);
-
- $response = $this->client->getResponse();
-
- $em = self::$core->getEntityManager();
- /* @var $em \Doctrine\ORM\EntityManager */
-
- $em->refresh($basket);
-
- $this->assertEquals(302, $response->getStatusCode());
-
- $this->assertEquals(0, $basket->getElements()->count());
- }
-
- public function testBasketDeleteElementPostJSON()
- {
- /* @var $em \Doctrine\ORM\EntityManager */
- $em = self::$core->getEntityManager();
-
- $basket = $this->insertOneBasket();
-
- $record = self::$record_1;
-
- $basket_element = new \Entities\BasketElement();
- $basket_element->setBasket($basket);
- $basket_element->setRecord($record);
- $basket_element->setLastInBasket();
-
- $basket->addBasketElement($basket_element);
-
- $em->persist($basket);
-
- $em->flush();
-
- $route = sprintf(
- "/baskets/%s/delete/%s/", $basket->getId(), $basket_element->getId()
- );
-
- $crawler = $this->client->request(
- 'POST', $route, array(), array(), array(
- "HTTP_ACCEPT" => "application/json")
- );
-
- $response = $this->client->getResponse();
-
- $em->refresh($basket);
-
- $this->assertEquals(200, $response->getStatusCode());
-
- $this->assertEquals(0, $basket->getElements()->count());
- }
-
- public function testBasketDeletePost()
- {
- $basket = $this->insertOneBasket();
-
- $route = sprintf('/baskets/%s/delete/', $basket->getId());
-
- $crawler = $this->client->request('POST', $route);
-
- $response = $this->client->getResponse();
-
- $query = self::$core->getEntityManager()->createQuery(
- 'SELECT COUNT(b.id) FROM \Entities\Basket b'
- );
-
- $count = $query->getSingleScalarResult();
-
- $this->assertEquals(0, $count);
-
- $this->assertEquals(302, $response->getStatusCode());
- }
-
- public function testBasketDeletePostJSON()
- {
- $basket = $this->insertOneBasket();
-
- $route = sprintf('/baskets/%s/delete/', $basket->getId());
-
- $crawler = $this->client->request(
- 'POST', $route, array(), array(), array(
- "HTTP_ACCEPT" => "application/json")
- );
-
- $this->client->getRequest()->setRequestFormat('json');
-
- $response = $this->client->getResponse();
-
- $query = self::$core->getEntityManager()->createQuery(
- 'SELECT COUNT(b.id) FROM \Entities\Basket b'
- );
-
- $count = $query->getSingleScalarResult();
-
- $this->assertEquals(0, $count);
-
- $this->assertEquals(200, $response->getStatusCode());
- }
-
- public function testBasketUpdatePost()
- {
- $basket = $this->insertOneBasket();
-
- $route = sprintf('/baskets/%s/update/', $basket->getId());
-
- $crawler = $this->client->request(
- 'POST', $route, array(
- 'name' => 'new_name',
- 'description' => 'new_desc')
- );
-
- $response = $this->client->getResponse();
-
- $em = self::$core->getEntityManager();
- /* @var $em \Doctrine\ORM\EntityManager */
- $basket = $em->getRepository('Entities\Basket')->find($basket->getId());
-
- $this->assertEquals('new_name', $basket->getName());
- $this->assertEquals('new_desc', $basket->getDescription());
-
- $this->assertEquals(302, $response->getStatusCode());
- }
-
- public function testBasketUpdatePostJSON()
- {
- $basket = $this->insertOneBasket();
-
- $route = sprintf('/baskets/%s/update/', $basket->getId());
-
- $crawler = $this->client->request(
- 'POST', $route, array(
- 'name' => 'new_name',
- 'description' => 'new_desc'
- ), array(), array(
- "HTTP_ACCEPT" => "application/json")
- );
-
- $response = $this->client->getResponse();
-
- $em = self::$core->getEntityManager();
- /* @var $em \Doctrine\ORM\EntityManager */
- $basket = $em->getRepository('Entities\Basket')->find($basket->getId());
-
- $this->assertEquals('new_name', $basket->getName());
- $this->assertEquals('new_desc', $basket->getDescription());
-
- $this->assertEquals(200, $response->getStatusCode());
- }
-
- public function testReorderGet()
- {
- $basket = $this->insertOneBasketEnv();
-
- $route = sprintf("/baskets/%s/reorder/", $basket->getId());
-
- $crawler = $this->client->request("GET", $route);
-
- $response = $this->client->getResponse();
-
- $this->assertEquals(200, $response->getStatusCode());
-
- foreach ($basket->getElements() as $elements)
- {
- $filter = sprintf("form[action='/prod/baskets/%s/reorder/']", $elements->getId());
- $this->assertEquals(1, $crawler->filter($filter)->count());
+ $this->assertEquals(200, $response->getStatusCode());
}
- }
- public function testBasketUpdateGet()
- {
- $basket = $this->insertOneBasket();
+ public function testCreateGet()
+ {
+ $route = '/baskets/create/';
- $route = sprintf('/baskets/%s/update/', $basket->getId());
+ $crawler = $this->client->request('GET', $route);
- $crawler = $this->client->request(
+ $response = $this->client->getResponse();
+
+ $this->assertEquals(200, $response->getStatusCode());
+
+ $filter = "form[action='/prod/baskets/']";
+ $this->assertEquals(1, $crawler->filter($filter)->count());
+
+ $filter = "form[action='/prod/baskets/'] input[name='name']";
+ $this->assertEquals(1, $crawler->filter($filter)->count());
+
+ $filter = "form[action='/prod/baskets/'] textarea[name='description']";
+ $this->assertEquals(1, $crawler->filter($filter)->count());
+ }
+
+ public function testBasketGet()
+ {
+ $basket = $this->insertOneBasket();
+
+ $route = sprintf('/baskets/%s/', $basket->getId());
+
+ $crawler = $this->client->request('GET', $route);
+
+ $response = $this->client->getResponse();
+
+ $this->assertEquals(200, $response->getStatusCode());
+ }
+
+ public function testBasketDeleteElementPost()
+ {
+ /* @var $em \Doctrine\ORM\EntityManager */
+ $em = self::$core->getEntityManager();
+
+ $basket = $this->insertOneBasket();
+
+ $record = self::$record_1;
+
+ $basket_element = new \Entities\BasketElement();
+ $basket_element->setBasket($basket);
+ $basket_element->setRecord($record);
+ $basket_element->setLastInBasket();
+
+ $basket->addBasketElement($basket_element);
+
+ $em->persist($basket);
+
+ $em->flush();
+
+ $route = sprintf(
+ "/baskets/%s/delete/%s/", $basket->getId(), $basket_element->getId()
+ );
+
+ $crawler = $this->client->request('POST', $route);
+
+ $response = $this->client->getResponse();
+
+ $em = self::$core->getEntityManager();
+ /* @var $em \Doctrine\ORM\EntityManager */
+
+ $em->refresh($basket);
+
+ $this->assertEquals(302, $response->getStatusCode());
+
+ $this->assertEquals(0, $basket->getElements()->count());
+ }
+
+ public function testBasketDeleteElementPostJSON()
+ {
+ /* @var $em \Doctrine\ORM\EntityManager */
+ $em = self::$core->getEntityManager();
+
+ $basket = $this->insertOneBasket();
+
+ $record = self::$record_1;
+
+ $basket_element = new \Entities\BasketElement();
+ $basket_element->setBasket($basket);
+ $basket_element->setRecord($record);
+ $basket_element->setLastInBasket();
+
+ $basket->addBasketElement($basket_element);
+
+ $em->persist($basket);
+
+ $em->flush();
+
+ $route = sprintf(
+ "/baskets/%s/delete/%s/", $basket->getId(), $basket_element->getId()
+ );
+
+ $crawler = $this->client->request(
+ 'POST', $route, array(), array(), array(
+ "HTTP_ACCEPT" => "application/json")
+ );
+
+ $response = $this->client->getResponse();
+
+ $em->refresh($basket);
+
+ $this->assertEquals(200, $response->getStatusCode());
+
+ $this->assertEquals(0, $basket->getElements()->count());
+ }
+
+ public function testBasketDeletePost()
+ {
+ $basket = $this->insertOneBasket();
+
+ $route = sprintf('/baskets/%s/delete/', $basket->getId());
+
+ $crawler = $this->client->request('POST', $route);
+
+ $response = $this->client->getResponse();
+
+ $query = self::$core->getEntityManager()->createQuery(
+ 'SELECT COUNT(b.id) FROM \Entities\Basket b'
+ );
+
+ $count = $query->getSingleScalarResult();
+
+ $this->assertEquals(0, $count);
+
+ $this->assertEquals(302, $response->getStatusCode());
+ }
+
+ public function testBasketDeletePostJSON()
+ {
+ $basket = $this->insertOneBasket();
+
+ $route = sprintf('/baskets/%s/delete/', $basket->getId());
+
+ $crawler = $this->client->request(
+ 'POST', $route, array(), array(), array(
+ "HTTP_ACCEPT" => "application/json")
+ );
+
+ $this->client->getRequest()->setRequestFormat('json');
+
+ $response = $this->client->getResponse();
+
+ $query = self::$core->getEntityManager()->createQuery(
+ 'SELECT COUNT(b.id) FROM \Entities\Basket b'
+ );
+
+ $count = $query->getSingleScalarResult();
+
+ $this->assertEquals(0, $count);
+
+ $this->assertEquals(200, $response->getStatusCode());
+ }
+
+ public function testBasketUpdatePost()
+ {
+ $basket = $this->insertOneBasket();
+
+ $route = sprintf('/baskets/%s/update/', $basket->getId());
+
+ $crawler = $this->client->request(
+ 'POST', $route, array(
+ 'name' => 'new_name',
+ 'description' => 'new_desc')
+ );
+
+ $response = $this->client->getResponse();
+
+ $em = self::$core->getEntityManager();
+ /* @var $em \Doctrine\ORM\EntityManager */
+ $basket = $em->getRepository('Entities\Basket')->find($basket->getId());
+
+ $this->assertEquals('new_name', $basket->getName());
+ $this->assertEquals('new_desc', $basket->getDescription());
+
+ $this->assertEquals(302, $response->getStatusCode());
+ }
+
+ public function testBasketUpdatePostJSON()
+ {
+ $basket = $this->insertOneBasket();
+
+ $route = sprintf('/baskets/%s/update/', $basket->getId());
+
+ $crawler = $this->client->request(
+ 'POST', $route, array(
+ 'name' => 'new_name',
+ 'description' => 'new_desc'
+ ), array(), array(
+ "HTTP_ACCEPT" => "application/json")
+ );
+
+ $response = $this->client->getResponse();
+
+ $em = self::$core->getEntityManager();
+ /* @var $em \Doctrine\ORM\EntityManager */
+ $basket = $em->getRepository('Entities\Basket')->find($basket->getId());
+
+ $this->assertEquals('new_name', $basket->getName());
+ $this->assertEquals('new_desc', $basket->getDescription());
+
+ $this->assertEquals(200, $response->getStatusCode());
+ }
+
+ public function testReorderGet()
+ {
+ $basket = $this->insertOneBasketEnv();
+
+ $route = sprintf("/baskets/%s/reorder/", $basket->getId());
+
+ $crawler = $this->client->request("GET", $route);
+
+ $response = $this->client->getResponse();
+
+ $this->assertEquals(200, $response->getStatusCode());
+
+ foreach ($basket->getElements() as $elements) {
+ $filter = sprintf("form[action='/prod/baskets/%s/reorder/']", $elements->getId());
+ $this->assertEquals(1, $crawler->filter($filter)->count());
+ }
+ }
+
+ public function testBasketUpdateGet()
+ {
+ $basket = $this->insertOneBasket();
+
+ $route = sprintf('/baskets/%s/update/', $basket->getId());
+
+ $crawler = $this->client->request(
'GET', $route, array(
- 'name' => 'new_name',
- 'description' => 'new_desc')
- );
+ 'name' => 'new_name',
+ 'description' => 'new_desc')
+ );
- $response = $this->client->getResponse();
+ $response = $this->client->getResponse();
- $this->assertEquals(200, $response->getStatusCode());
+ $this->assertEquals(200, $response->getStatusCode());
- $filter = "form[action='/prod/baskets/" . $basket->getId() . "/update/']";
- $this->assertEquals($crawler->filter($filter)->count(), 1);
+ $filter = "form[action='/prod/baskets/" . $basket->getId() . "/update/']";
+ $this->assertEquals($crawler->filter($filter)->count(), 1);
- $node = $crawler
+ $node = $crawler
->filter('input[name=name]');
- $this->assertEquals($basket->getName(), $node->attr('value'));
+ $this->assertEquals($basket->getName(), $node->attr('value'));
- $node = $crawler
+ $node = $crawler
->filter('textarea[name=description]');
- $this->assertEquals($basket->getDescription(), $node->text());
- }
+ $this->assertEquals($basket->getDescription(), $node->text());
+ }
- public function testBasketArchivedPost()
- {
- $basket = $this->insertOneBasket();
+ public function testBasketArchivedPost()
+ {
+ $basket = $this->insertOneBasket();
- $route = sprintf('/baskets/%s/archive/', $basket->getId());
+ $route = sprintf('/baskets/%s/archive/', $basket->getId());
- $crawler = $this->client->request('POST', $route, array('archive' => '1'));
+ $crawler = $this->client->request('POST', $route, array('archive' => '1'));
- $response = $this->client->getResponse();
+ $response = $this->client->getResponse();
- $em = self::$core->getEntityManager();
- /* @var $em \Doctrine\ORM\EntityManager */
- $basket = $em->getRepository('Entities\Basket')->find($basket->getId());
+ $em = self::$core->getEntityManager();
+ /* @var $em \Doctrine\ORM\EntityManager */
+ $basket = $em->getRepository('Entities\Basket')->find($basket->getId());
- $this->assertTrue($basket->getArchived());
+ $this->assertTrue($basket->getArchived());
- $crawler = $this->client->request('POST', $route, array('archive' => '0'));
+ $crawler = $this->client->request('POST', $route, array('archive' => '0'));
- $response = $this->client->getResponse();
+ $response = $this->client->getResponse();
- $em->refresh($basket);
+ $em->refresh($basket);
- $this->assertFalse($basket->getArchived());
+ $this->assertFalse($basket->getArchived());
- $this->assertEquals(302, $response->getStatusCode());
- }
+ $this->assertEquals(302, $response->getStatusCode());
+ }
- public function testBasketArchivedPostJSON()
- {
- $basket = $this->insertOneBasket();
+ public function testBasketArchivedPostJSON()
+ {
+ $basket = $this->insertOneBasket();
- $route = sprintf('/baskets/%s/archive/', $basket->getId());
+ $route = sprintf('/baskets/%s/archive/', $basket->getId());
- $crawler = $this->client->request(
+ $crawler = $this->client->request(
'POST', $route, array(
- 'archive' => '1'
+ 'archive' => '1'
), array(), array(
- "HTTP_ACCEPT" => "application/json"
+ "HTTP_ACCEPT" => "application/json"
)
- );
+ );
- $response = $this->client->getResponse();
+ $response = $this->client->getResponse();
- $em = self::$core->getEntityManager();
- /* @var $em \Doctrine\ORM\EntityManager */
- $basket = $em->getRepository('Entities\Basket')->find($basket->getId());
+ $em = self::$core->getEntityManager();
+ /* @var $em \Doctrine\ORM\EntityManager */
+ $basket = $em->getRepository('Entities\Basket')->find($basket->getId());
- $this->assertTrue($basket->getArchived());
+ $this->assertTrue($basket->getArchived());
- $crawler = $this->client->request(
+ $crawler = $this->client->request(
'POST', $route, array(
- 'archive' => '0'
+ 'archive' => '0'
), array(), array(
- "HTTP_ACCEPT" => "application/json"
+ "HTTP_ACCEPT" => "application/json"
)
- );
+ );
- $response = $this->client->getResponse();
+ $response = $this->client->getResponse();
- $em->refresh($basket);
+ $em->refresh($basket);
- $this->assertFalse($basket->getArchived());
+ $this->assertFalse($basket->getArchived());
- $this->assertEquals(200, $response->getStatusCode());
- }
+ $this->assertEquals(200, $response->getStatusCode());
+ }
- public function testAddElementPost()
- {
- $basket = $this->insertOneBasket();
+ public function testAddElementPost()
+ {
+ $basket = $this->insertOneBasket();
- $route = sprintf('/baskets/%s/addElements/', $basket->getId());
+ $route = sprintf('/baskets/%s/addElements/', $basket->getId());
- $records = array(
- self::$record_1->get_serialize_key(),
- self::$record_2->get_serialize_key(),
- ' ',
- '42',
- 'abhak',
- self::$record_no_access->get_serialize_key(),
- );
+ $records = array(
+ self::$record_1->get_serialize_key(),
+ self::$record_2->get_serialize_key(),
+ ' ',
+ '42',
+ 'abhak',
+ self::$record_no_access->get_serialize_key(),
+ );
- $lst = implode(';', $records);
+ $lst = implode(';', $records);
- $crawler = $this->client->request('POST', $route, array('lst' => $lst));
+ $crawler = $this->client->request('POST', $route, array('lst' => $lst));
- $response = $this->client->getResponse();
+ $response = $this->client->getResponse();
- $this->assertEquals(302, $response->getStatusCode());
+ $this->assertEquals(302, $response->getStatusCode());
- $em = self::$core->getEntityManager();
- /* @var $em \Doctrine\ORM\EntityManager */
- $basket = $em->getRepository('Entities\Basket')->find($basket->getId());
+ $em = self::$core->getEntityManager();
+ /* @var $em \Doctrine\ORM\EntityManager */
+ $basket = $em->getRepository('Entities\Basket')->find($basket->getId());
- $this->assertEquals(2, $basket->getElements()->count());
- }
+ $this->assertEquals(2, $basket->getElements()->count());
+ }
+ public function testAddElementToValidationPost()
+ {
- public function testAddElementToValidationPost()
- {
+ $em = self::$core->getEntityManager();
- $em = self::$core->getEntityManager();
+ $datas = $em->getRepository('Entities\ValidationData')->findAll();
+ $countDatas = count($datas);
- $datas = $em->getRepository('Entities\ValidationData')->findAll();
- $countDatas = count($datas);
+ $basket = $this->insertOneBasket();
- $basket = $this->insertOneBasket();
+ $validationSession = new \Entities\ValidationSession();
- $validationSession = new \Entities\ValidationSession();
+ $validationSession->setDescription('Une description au hasard');
+ $validationSession->setName('Un nom de validation');
- $validationSession->setDescription('Une description au hasard');
- $validationSession->setName('Un nom de validation');
+ $expires = new \DateTime();
+ $expires->modify('+1 week');
- $expires = new \DateTime();
- $expires->modify('+1 week');
+ $validationSession->setExpires($expires);
+ $validationSession->setInitiator(self::$user);
- $validationSession->setExpires($expires);
- $validationSession->setInitiator(self::$user);
+ $em->persist($validationSession);
- $em->persist($validationSession);
+ $basket->setValidation($validationSession);
- $basket->setValidation($validationSession);
+ $validationSession->setBasket($basket);
- $validationSession->setBasket($basket);
+ $validationParticipant = new \Entities\ValidationParticipant();
+ $validationParticipant->setSession($validationSession);
+ $validationParticipant->setUser(self::$user_alt1);
- $validationParticipant = new \Entities\ValidationParticipant();
- $validationParticipant->setSession($validationSession);
- $validationParticipant->setUser(self::$user_alt1);
+ $em->persist($validationParticipant);
- $em->persist($validationParticipant);
+ $validationSession->addValidationParticipant($validationParticipant);
- $validationSession->addValidationParticipant($validationParticipant);
+ $em->flush();
- $em->flush();
+ $route = sprintf('/baskets/%s/addElements/', $basket->getId());
- $route = sprintf('/baskets/%s/addElements/', $basket->getId());
+ $records = array(
+ self::$record_1->get_serialize_key(),
+ self::$record_2->get_serialize_key(),
+ ' ',
+ '42',
+ 'abhak',
+ self::$record_no_access->get_serialize_key(),
+ );
- $records = array(
- self::$record_1->get_serialize_key(),
- self::$record_2->get_serialize_key(),
- ' ',
- '42',
- 'abhak',
- self::$record_no_access->get_serialize_key(),
- );
+ $lst = implode(';', $records);
- $lst = implode(';', $records);
+ $this->client->request('POST', $route, array('lst' => $lst));
- $this->client->request('POST', $route, array('lst' => $lst));
+ $response = $this->client->getResponse();
- $response = $this->client->getResponse();
+ $this->assertEquals(302, $response->getStatusCode());
- $this->assertEquals(302, $response->getStatusCode());
+ $em = self::$core->getEntityManager();
+ /* @var $em \Doctrine\ORM\EntityManager */
+ $basket = $em->getRepository('Entities\Basket')->find($basket->getId());
- $em = self::$core->getEntityManager();
- /* @var $em \Doctrine\ORM\EntityManager */
- $basket = $em->getRepository('Entities\Basket')->find($basket->getId());
+ $this->assertEquals(2, $basket->getElements()->count());
- $this->assertEquals(2, $basket->getElements()->count());
+ $datas = $em->getRepository('Entities\ValidationData')->findAll();
- $datas = $em->getRepository('Entities\ValidationData')->findAll();
+ $this->assertTrue($countDatas < count($datas), 'assert that ' . count($datas) . ' > ' . $countDatas);
+ }
- $this->assertTrue($countDatas < count($datas), 'assert that '.count($datas).' > '.$countDatas );
- }
+ public function testAddElementPostJSON()
+ {
+ $basket = $this->insertOneBasket();
+ $route = sprintf('/baskets/%s/addElements/', $basket->getId());
- public function testAddElementPostJSON()
- {
- $basket = $this->insertOneBasket();
+ $records = array(
+ self::$record_1->get_serialize_key(),
+ self::$record_2->get_serialize_key()
+ );
- $route = sprintf('/baskets/%s/addElements/', $basket->getId());
+ $lst = implode(';', $records);
- $records = array(
- self::$record_1->get_serialize_key(),
- self::$record_2->get_serialize_key()
- );
-
- $lst = implode(';', $records);
-
- $crawler = $this->client->request(
+ $crawler = $this->client->request(
'POST', $route, array(
- 'lst' => $lst
+ 'lst' => $lst
), array(), array(
- "HTTP_ACCEPT" => "application/json"
+ "HTTP_ACCEPT" => "application/json"
)
- );
+ );
- $response = $this->client->getResponse();
+ $response = $this->client->getResponse();
- $em = self::$core->getEntityManager();
- /* @var $em \Doctrine\ORM\EntityManager */
- $basket = $em->getRepository('Entities\Basket')->find($basket->getId());
+ $em = self::$core->getEntityManager();
+ /* @var $em \Doctrine\ORM\EntityManager */
+ $basket = $em->getRepository('Entities\Basket')->find($basket->getId());
- $this->assertEquals(200, $response->getStatusCode());
+ $this->assertEquals(200, $response->getStatusCode());
- $this->assertEquals(2, $basket->getElements()->count());
- }
+ $this->assertEquals(2, $basket->getElements()->count());
+ }
- public function testRouteStealElements()
- {
- $em = self::$core->getEntityManager();
+ public function testRouteStealElements()
+ {
+ $em = self::$core->getEntityManager();
- $BasketElement = $this->insertOneBasketElement();
+ $BasketElement = $this->insertOneBasketElement();
- $Basket_1 = $BasketElement->getBasket();
+ $Basket_1 = $BasketElement->getBasket();
- $Basket_2 = $this->insertOneBasket();
+ $Basket_2 = $this->insertOneBasket();
- $route = sprintf('/baskets/%s/stealElements/', $Basket_2->getId());
+ $route = sprintf('/baskets/%s/stealElements/', $Basket_2->getId());
- $this->client->request(
+ $this->client->request(
'POST', $route, array(
- 'elements' => array($BasketElement->getId(), 'ufdsd')
+ 'elements' => array($BasketElement->getId(), 'ufdsd')
), array()
- );
+ );
- $response = $this->client->getResponse();
+ $response = $this->client->getResponse();
- $this->assertTrue($response->isRedirect());
+ $this->assertTrue($response->isRedirect());
- $em = self::$core->getEntityManager();
- /* @var $em \Doctrine\ORM\EntityManager */
+ $em = self::$core->getEntityManager();
+ /* @var $em \Doctrine\ORM\EntityManager */
- $basket = $em->getRepository('Entities\Basket')->find($Basket_1->getId());
- $this->assertInstanceOf('\Entities\Basket', $basket);
- $this->assertEquals(0, $basket->getElements()->count());
+ $basket = $em->getRepository('Entities\Basket')->find($Basket_1->getId());
+ $this->assertInstanceOf('\Entities\Basket', $basket);
+ $this->assertEquals(0, $basket->getElements()->count());
- $basket = $em->getRepository('Entities\Basket')->find($Basket_2->getId());
- $this->assertInstanceOf('\Entities\Basket', $basket);
- $this->assertEquals(1, $basket->getElements()->count());
+ $basket = $em->getRepository('Entities\Basket')->find($Basket_2->getId());
+ $this->assertInstanceOf('\Entities\Basket', $basket);
+ $this->assertEquals(1, $basket->getElements()->count());
+ }
- }
+ public function testRouteStealElementsJson()
+ {
+ $em = self::$core->getEntityManager();
- public function testRouteStealElementsJson()
- {
- $em = self::$core->getEntityManager();
+ $BasketElement = $this->insertOneBasketElement();
- $BasketElement = $this->insertOneBasketElement();
+ $Basket_1 = $BasketElement->getBasket();
- $Basket_1 = $BasketElement->getBasket();
+ $Basket_2 = $this->insertOneBasket();
- $Basket_2 = $this->insertOneBasket();
+ $route = sprintf('/baskets/%s/stealElements/', $Basket_2->getId());
- $route = sprintf('/baskets/%s/stealElements/', $Basket_2->getId());
-
- $this->client->request(
+ $this->client->request(
'POST', $route, array(
- 'elements' => array($BasketElement->getId())
+ 'elements' => array($BasketElement->getId())
), array()
, array(
- "HTTP_ACCEPT" => "application/json"
+ "HTTP_ACCEPT" => "application/json"
)
- );
+ );
- $response = $this->client->getResponse();
+ $response = $this->client->getResponse();
- $this->assertEquals(200, $response->getStatusCode());
+ $this->assertEquals(200, $response->getStatusCode());
- $datas = (array) json_decode($response->getContent());
+ $datas = (array) json_decode($response->getContent());
- $this->assertArrayHasKey('message', $datas);
- $this->assertArrayHasKey('success', $datas);
- $this->assertTrue($datas['success']);
+ $this->assertArrayHasKey('message', $datas);
+ $this->assertArrayHasKey('success', $datas);
+ $this->assertTrue($datas['success']);
- $basket = $em->getRepository('Entities\Basket')->find($Basket_1->getId());
- $this->assertInstanceOf('\Entities\Basket', $basket);
- $this->assertEquals(0, $basket->getElements()->count());
+ $basket = $em->getRepository('Entities\Basket')->find($Basket_1->getId());
+ $this->assertInstanceOf('\Entities\Basket', $basket);
+ $this->assertEquals(0, $basket->getElements()->count());
- $basket = $em->getRepository('Entities\Basket')->find($Basket_2->getId());
- $this->assertInstanceOf('\Entities\Basket', $basket);
- $this->assertEquals(1, $basket->getElements()->count());
+ $basket = $em->getRepository('Entities\Basket')->find($Basket_2->getId());
+ $this->assertInstanceOf('\Entities\Basket', $basket);
+ $this->assertEquals(1, $basket->getElements()->count());
+ }
- }
+ /**
+ * Test when i remove a basket, all relations are removed too :
+ * - basket elements
+ * - validations sessions
+ * - validation participants
+ */
+ public function testRemoveBasket()
+ {
+ $basket = $this->insertOneBasketEnv();
- /**
- * Test when i remove a basket, all relations are removed too :
- * - basket elements
- * - validations sessions
- * - validation participants
- */
- public function testRemoveBasket()
- {
- $basket = $this->insertOneBasketEnv();
+ $em = self::$core->getEntityManager();
+ /* @var $em \Doctrine\ORM\EntityManager */
+ $basket = $em->find("Entities\Basket", $basket->getId());
- $em = self::$core->getEntityManager();
- /* @var $em \Doctrine\ORM\EntityManager */
- $basket = $em->find("Entities\Basket", $basket->getId());
+ $em->remove($basket);
- $em->remove($basket);
+ $em->flush();
- $em->flush();
-
- $query = $em->createQuery(
+ $query = $em->createQuery(
'SELECT COUNT(v.id) FROM \Entities\ValidationParticipant v'
- );
+ );
- $count = $query->getSingleScalarResult();
+ $count = $query->getSingleScalarResult();
- $this->assertEquals(0, $count);
+ $this->assertEquals(0, $count);
- $query = $em->createQuery(
+ $query = $em->createQuery(
'SELECT COUNT(b.id) FROM \Entities\BasketElement b'
- );
+ );
- $count = $query->getSingleScalarResult();
+ $count = $query->getSingleScalarResult();
- $this->assertEquals(0, $count);
+ $this->assertEquals(0, $count);
- $query = $em->createQuery(
+ $query = $em->createQuery(
'SELECT COUNT(v.id) FROM \Entities\ValidationSession v'
- );
+ );
- $count = $query->getSingleScalarResult();
+ $count = $query->getSingleScalarResult();
- $this->assertEquals(0, $count);
+ $this->assertEquals(0, $count);
- $query = $em->createQuery(
+ $query = $em->createQuery(
'SELECT COUNT(b.id) FROM \Entities\Basket b'
- );
+ );
- $count = $query->getSingleScalarResult();
-
- $this->assertEquals(0, $count);
- }
+ $count = $query->getSingleScalarResult();
+ $this->assertEquals(0, $count);
+ }
}
diff --git a/tests/Alchemy/Phrasea/Controller/Prod/BridgeTest.php b/tests/Alchemy/Phrasea/Controller/Prod/BridgeTest.php
index 39c6701ed0..da948998b9 100644
--- a/tests/Alchemy/Phrasea/Controller/Prod/BridgeTest.php
+++ b/tests/Alchemy/Phrasea/Controller/Prod/BridgeTest.php
@@ -8,431 +8,398 @@ use Symfony\Component\HttpFoundation\Response;
class BridgeApplication extends PhraseanetWebTestCaseAuthenticatedAbstract
{
+ public static $account = null;
+ public static $api = null;
+ protected $client;
+ protected static $need_records = 1;
- public static $account = null;
- public static $api = null;
- protected $client;
- protected static $need_records = 1;
-
- public static function setUpBeforeClass()
- {
- parent::setUpBeforeClass();
- }
-
- public static function tearDownAfterClass()
- {
- parent::tearDownAfterClass();
- }
-
- public function setUp()
- {
- parent::setUp();
- $this->client = $this->createClient();
- try
+ public function setUp()
{
- self::$api = Bridge_Api::get_by_api_name(appbox::get_instance(\bootstrap::getCore()), 'apitest');
- }
- catch (Bridge_Exception_ApiNotFound $e)
- {
- self::$api = Bridge_Api::create(appbox::get_instance(\bootstrap::getCore()), 'apitest');
+ parent::setUp();
+ $this->client = $this->createClient();
+ try {
+ self::$api = Bridge_Api::get_by_api_name(appbox::get_instance(\bootstrap::getCore()), 'apitest');
+ } catch (Bridge_Exception_ApiNotFound $e) {
+ self::$api = Bridge_Api::create(appbox::get_instance(\bootstrap::getCore()), 'apitest');
+ }
+
+ try {
+ self::$account = Bridge_Account::load_account_from_distant_id(appbox::get_instance(\bootstrap::getCore()), self::$api, self::$user, 'kirikoo');
+ } catch (Bridge_Exception_AccountNotFound $e) {
+ self::$account = Bridge_Account::create(appbox::get_instance(\bootstrap::getCore()), self::$api, self::$user, 'kirikoo', 'coucou');
+ }
}
- try
+ public function tearDown()
{
- self::$account = Bridge_Account::load_account_from_distant_id(appbox::get_instance(\bootstrap::getCore()), self::$api, self::$user, 'kirikoo');
+ if (self::$api instanceof Bridge_Api) {
+ self::$api->delete();
+ }
+ if (self::$account instanceof Bridge_Account) {
+ self::$account->delete();
+ }
+ parent::tearDown();
}
- catch (Bridge_Exception_AccountNotFound $e)
+
+ public function createApplication()
{
- self::$account = Bridge_Account::create(appbox::get_instance(\bootstrap::getCore()), self::$api, self::$user, 'kirikoo', 'coucou');
+ return include realpath(__DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Prod.php');
}
- }
- public function tearDown()
- {
- parent::tearDown();
- if (self::$api instanceof Bridge_Api)
- self::$api->delete();
- if (self::$account instanceof Bridge_Account)
- self::$account->delete();
- }
+ /**
+ * @todo create a new basket dont take an existing one
+ */
+ public function testManager()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $accounts = Bridge_Account::get_accounts_by_user($appbox, self::$user);
+ $usr_id = self::$user->get_id();
- public function createApplication()
- {
- return include realpath(__DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Prod.php');
- }
+ $basket = $this->insertOneBasket();
- /**
- * @todo create a new basket dont take an existing one
- */
- public function testManager()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $accounts = Bridge_Account::get_accounts_by_user($appbox, self::$user);
- $usr_id = self::$user->get_id();
+ $crawler = $this->client->request('POST', '/bridge/manager/', array('ssel' => $basket->getId()));
+ $pageContent = $this->client->getResponse()->getContent();
+ $this->assertTrue($this->client->getResponse()->isOk());
+ }
- $basket = $this->insertOneBasket();
+ public function testLogin()
+ {
+ $this->client->request('GET', '/bridge/login/Apitest/');
+ $test = new Bridge_Api_Apitest(registry::get_instance(), new Bridge_Api_Auth_None());
+ $this->assertTrue($this->client->getResponse()->getStatusCode() == 302);
+ $this->assertTrue($this->client->getResponse()->isRedirect($test->get_auth_url()));
+ }
- $crawler = $this->client->request('POST', '/bridge/manager/', array('ssel' => $basket->getId()));
- $pageContent = $this->client->getResponse()->getContent();
- $this->assertTrue($this->client->getResponse()->isOk());
- }
+ public function testCallBackFailed()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $session = $appbox->get_session();
+ $crawler = $this->client->request('GET', '/bridge/callback/unknow_api/');
+ $this->assertTrue($this->client->getResponse()->isOk());
+ }
- public function testLogin()
- {
- $this->client->request('GET', '/bridge/login/Apitest/');
- $test = new Bridge_Api_Apitest(registry::get_instance(), new Bridge_Api_Auth_None());
- $this->assertTrue($this->client->getResponse()->getStatusCode() == 302);
- $this->assertTrue($this->client->getResponse()->isRedirect($test->get_auth_url()));
- }
-
- public function testCallBackFailed()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $session = $appbox->get_session();
- $crawler = $this->client->request('GET', '/bridge/callback/unknow_api/');
- $this->assertTrue($this->client->getResponse()->isOk());
- }
-
- public function testCallBackAccountAlreadyDefined()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $crawler = $this->client->request('GET', '/bridge/callback/apitest/');
- $this->assertTrue($this->client->getResponse()->isOk());
- $pageContent = $this->client->getResponse()->getContent();
- //check for errors in the crawler
- $phpunit = $this;
- $crawler
+ public function testCallBackAccountAlreadyDefined()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $crawler = $this->client->request('GET', '/bridge/callback/apitest/');
+ $this->assertTrue($this->client->getResponse()->isOk());
+ $pageContent = $this->client->getResponse()->getContent();
+ //check for errors in the crawler
+ $phpunit = $this;
+ $crawler
->filter('div')
- ->reduce(function ($node, $i) use ($phpunit)
- {
- if (!$node->getAttribute('class'))
- {
+ ->reduce(function ($node, $i) use ($phpunit) {
+ if ( ! $node->getAttribute('class')) {
return false;
- }
- elseif ($node->getAttribute('class') == 'error_auth')
- {
+ } elseif ($node->getAttribute('class') == 'error_auth') {
$phpunit->fail("Erreur callback");
- }
- });
- $settings = self::$account->get_settings();
- $this->assertEquals("kikoo", $settings->get("auth_token"));
- $this->assertEquals("kooki", $settings->get("refresh_token"));
- $this->assertEquals("biloute", $settings->get("access_token"));
- $settings->delete("auth_token");
- $settings->delete("refresh_token");
- $settings->delete("access_token");
- }
+ }
+ });
+ $settings = self::$account->get_settings();
+ $this->assertEquals("kikoo", $settings->get("auth_token"));
+ $this->assertEquals("kooki", $settings->get("refresh_token"));
+ $this->assertEquals("biloute", $settings->get("access_token"));
+ $settings->delete("auth_token");
+ $settings->delete("refresh_token");
+ $settings->delete("access_token");
+ }
- public function testCallBackAccountNoDefined()
- {
- if (self::$account instanceof Bridge_Account)
- self::$account->delete();
- $crawler = $this->client->request('GET', '/bridge/callback/apitest/');
- $this->assertTrue($this->client->getResponse()->isOk());
- $phpunit = $this;
- $crawler
+ public function testCallBackAccountNoDefined()
+ {
+ if (self::$account instanceof Bridge_Account)
+ self::$account->delete();
+ $crawler = $this->client->request('GET', '/bridge/callback/apitest/');
+ $this->assertTrue($this->client->getResponse()->isOk());
+ $phpunit = $this;
+ $crawler
->filter('div')
- ->reduce(function ($node, $i) use ($phpunit)
- {
- if (!$node->getAttribute('class'))
- {
+ ->reduce(function ($node, $i) use ($phpunit) {
+ if ( ! $node->getAttribute('class')) {
return false;
- }
- elseif ($node->getAttribute('class') == 'error_auth')
- {
+ } elseif ($node->getAttribute('class') == 'error_auth') {
$phpunit->fail("Erreur callback");
- }
- });
- try
- {
- self::$account = Bridge_Account::load_account_from_distant_id(appbox::get_instance(\bootstrap::getCore()), self::$api, self::$user, 'kirikoo');
- $settings = self::$account->get_settings();
- $this->assertEquals("kikoo", $settings->get("auth_token"));
- $this->assertEquals("kooki", $settings->get("refresh_token"));
- $this->assertEquals("biloute", $settings->get("access_token"));
- $settings->delete("auth_token");
- $settings->delete("refresh_token");
- $settings->delete("access_token");
- }
- catch (Bridge_Exception_AccountNotFound $e)
- {
- $this->fail("No account created after callback");
+ }
+ });
+ try {
+ self::$account = Bridge_Account::load_account_from_distant_id(appbox::get_instance(\bootstrap::getCore()), self::$api, self::$user, 'kirikoo');
+ $settings = self::$account->get_settings();
+ $this->assertEquals("kikoo", $settings->get("auth_token"));
+ $this->assertEquals("kooki", $settings->get("refresh_token"));
+ $this->assertEquals("biloute", $settings->get("access_token"));
+ $settings->delete("auth_token");
+ $settings->delete("refresh_token");
+ $settings->delete("access_token");
+ } catch (Bridge_Exception_AccountNotFound $e) {
+ $this->fail("No account created after callback");
+ }
+
+ if ( ! self::$account instanceof Bridge_Account)
+ self::$account = Bridge_Account::create(appbox::get_instance(\bootstrap::getCore()), self::$api, self::$user, 'kirikoo', 'coucou');
}
- if (!self::$account instanceof Bridge_Account)
- self::$account = Bridge_Account::create(appbox::get_instance(\bootstrap::getCore()), self::$api, self::$user, 'kirikoo', 'coucou');
- }
-
- public function testLogout()
- {
- self::$account->get_settings()->set("auth_token", "somethingNotNull"); //connected
- $url = sprintf('/bridge/adapter/%d/logout/', self::$account->get_id());
- $this->client->request('GET', $url);
- $redirect = sprintf("/prod/bridge/adapter/%s/load-elements/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type());
- $this->assertTrue($this->client->getResponse()->isRedirect($redirect));
- $this->assertNull(self::$account->get_settings()->get("auth_token"));
- }
-
- public function testLoadElements()
- {
- self::$account->get_settings()->set("auth_token", "somethingNotNull"); //connected
- $url = sprintf("/bridge/adapter/%s/load-elements/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type());
- $account = new Bridge_Account(appbox::get_instance(\bootstrap::getCore()), self::$api, self::$account->get_id());
- $crawler = $this->client->request('GET', $url, array("page" => 1));
- $this->assertTrue($this->client->getResponse()->isOk());
- $this->assertNotContains(self::$account->get_api()->generate_login_url(registry::get_instance(), self::$account->get_api()->get_connector()->get_name()), $this->client->getResponse()->getContent());
- }
-
- public function testLoadRecords()
- {
- self::$account->get_settings()->set("auth_token", "somethingNotNull"); //connected
- $url = sprintf("/bridge/adapter/%s/load-records/", self::$account->get_id());
- $crawler = $this->client->request('GET', $url, array("page" => 1));
- $elements = Bridge_Element::get_elements_by_account(appbox::get_instance(\bootstrap::getCore()), self::$account);
- $this->assertTrue($this->client->getResponse()->isOk());
- $this->assertEquals(sizeof($elements), $crawler->filterXPath("//table/tr")->count());
- $this->assertNotContains(self::$account->get_api()->generate_login_url(registry::get_instance(), self::$account->get_api()->get_connector()->get_name()), $this->client->getResponse()->getContent());
- }
-
- public function testLoadRecordsDisconnected()
- {
- $this->client->followRedirects();
- self::$account->get_settings()->set("auth_token", null); //deconnected
- $url = sprintf("/bridge/adapter/%s/load-records/", self::$account->get_id());
- $crawler = $this->client->request('GET', $url, array("page" => 1));
- $pageContent = $this->client->getResponse()->getContent();
- $this->assertContains($url, $pageContent);
- $this->deconnected($crawler, $pageContent);
- }
-
- public function testLoadContainers()
- {
- self::$account->get_settings()->set("auth_token", "somethingNotNull"); //connected
- $url = sprintf("/bridge/adapter/%s/load-containers/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_container_type());
- $crawler = $this->client->request('GET', $url, array("page" => 1));
- $elements = Bridge_Element::get_elements_by_account(appbox::get_instance(\bootstrap::getCore()), self::$account);
- $this->assertTrue($this->client->getResponse()->isOk());
- $this->assertNotContains(self::$account->get_api()->generate_login_url(registry::get_instance(), self::$account->get_api()->get_connector()->get_name()), $this->client->getResponse()->getContent());
- }
-
- public function testLoadContainersDisconnected()
- {
- $this->client->followRedirects();
- self::$account->get_settings()->set("auth_token", null); //deconnected
- $url = sprintf("/bridge/adapter/%s/load-containers/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_container_type());
- $crawler = $this->client->request('GET', $url, array("page" => 1));
- $pageContent = $this->client->getResponse()->getContent();
- $this->assertContains($url, $pageContent);
- $this->deconnected($crawler, $pageContent);
- }
-
- public function testLoadElementsDisconnected()
- {
- $this->client->followRedirects();
- self::$account->get_settings()->set("auth_token", null); //deconnected
- $url = sprintf("/bridge/adapter/%s/load-elements/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type());
- $crawler = $this->client->request('GET', $url, array("page" => 1));
- $this->assertTrue($this->client->getResponse()->isOk());
- $pageContent = $this->client->getResponse()->getContent();
- $this->assertContains($url, $pageContent);
- $this->deconnected($crawler, $pageContent);
- }
-
- public function testLogoutDeconnected()
- {
- $this->client->followRedirects();
- self::$account->get_settings()->set("auth_token", null); //deconnected
- $url = sprintf('/bridge/adapter/%d/logout/', self::$account->get_id());
- $crawler = $this->client->request('GET', $url);
- $pageContent = $this->client->getResponse()->getContent();
- $this->assertContains("/adapter/" . self::$account->get_id() . "/logout/", $pageContent);
- $this->deconnected($crawler, $pageContent);
- }
-
- public function testActionDeconnected()
- {
- $this->client->followRedirects();
- self::$account->get_settings()->set("auth_token", null); //deconnected
- $url = sprintf("/bridge/action/%s/une action/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type());
- $crawler = $this->client->request('GET', $url);
- $pageContent = $this->client->getResponse()->getContent();
- $this->assertContains($url, $pageContent);
- $this->deconnected($crawler, $pageContent);
- }
-
- public function testActionUnknow()
- {
- self::$account->get_settings()->set("auth_token", "somethingNotNull"); //connected
- $url = sprintf("/bridge/action/%s/ajjfhfjozqd/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type());
- try
+ public function testLogout()
{
- $crawler = $this->client->request('GET', $url, array("elements_list" => "1;2;3"));
- $this->fail("expected Exception here");
- }
- catch (Exception $e)
- {
-
+ self::$account->get_settings()->set("auth_token", "somethingNotNull"); //connected
+ $url = sprintf('/bridge/adapter/%d/logout/', self::$account->get_id());
+ $this->client->request('GET', $url);
+ $redirect = sprintf("/prod/bridge/adapter/%s/load-elements/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type());
+ $this->assertTrue($this->client->getResponse()->isRedirect($redirect));
+ $this->assertNull(self::$account->get_settings()->get("auth_token"));
}
- try
+ public function testLoadElements()
{
- $crawler = $this->client->request('POST', $url, array("elements_list" => "1;2;3"));
- $this->fail("expected Exception here");
+ self::$account->get_settings()->set("auth_token", "somethingNotNull"); //connected
+ $url = sprintf("/bridge/adapter/%s/load-elements/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type());
+ $account = new Bridge_Account(appbox::get_instance(\bootstrap::getCore()), self::$api, self::$account->get_id());
+ $crawler = $this->client->request('GET', $url, array("page" => 1));
+ $this->assertTrue($this->client->getResponse()->isOk());
+ $this->assertNotContains(self::$account->get_api()->generate_login_url(registry::get_instance(), self::$account->get_api()->get_connector()->get_name()), $this->client->getResponse()->getContent());
}
- catch (Exception $e)
+
+ public function testLoadRecords()
{
-
+ self::$account->get_settings()->set("auth_token", "somethingNotNull"); //connected
+ $url = sprintf("/bridge/adapter/%s/load-records/", self::$account->get_id());
+ $crawler = $this->client->request('GET', $url, array("page" => 1));
+ $elements = Bridge_Element::get_elements_by_account(appbox::get_instance(\bootstrap::getCore()), self::$account);
+ $this->assertTrue($this->client->getResponse()->isOk());
+ $this->assertEquals(sizeof($elements), $crawler->filterXPath("//table/tr")->count());
+ $this->assertNotContains(self::$account->get_api()->generate_login_url(registry::get_instance(), self::$account->get_api()->get_connector()->get_name()), $this->client->getResponse()->getContent());
}
- }
- public function testActionModifyTooManyElements()
- {
- self::$account->get_settings()->set("auth_token", "somethingNotNull"); //connected
- $url = sprintf("/bridge/action/%s/modify/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type());
- $crawler = $this->client->request('GET', $url, array("element_list" => "1_2;1_3;1_4"));
- $redirect = sprintf("/prod/bridge/adapter/%s/load-elements/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type());
- $this->assertTrue($this->client->getResponse()->isRedirect());
- $this->assertContains($redirect, $this->client->getResponse()->headers->get("location"));
- $this->assertContains("error=", $this->client->getResponse()->headers->get("location"));
- $this->assertNotContains(self::$account->get_api()->generate_login_url(registry::get_instance(), self::$account->get_api()->get_connector()->get_name()), $this->client->getResponse()->getContent());
+ public function testLoadRecordsDisconnected()
+ {
+ $this->client->followRedirects();
+ self::$account->get_settings()->set("auth_token", null); //deconnected
+ $url = sprintf("/bridge/adapter/%s/load-records/", self::$account->get_id());
+ $crawler = $this->client->request('GET', $url, array("page" => 1));
+ $pageContent = $this->client->getResponse()->getContent();
+ $this->assertContains($url, $pageContent);
+ $this->deconnected($crawler, $pageContent);
+ }
- $this->client->request('POST', $url, array("element_list" => "1_2;1_3;1_4"));
- $this->assertTrue($this->client->getResponse()->isRedirect());
- }
+ public function testLoadContainers()
+ {
+ self::$account->get_settings()->set("auth_token", "somethingNotNull"); //connected
+ $url = sprintf("/bridge/adapter/%s/load-containers/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_container_type());
+ $crawler = $this->client->request('GET', $url, array("page" => 1));
+ $elements = Bridge_Element::get_elements_by_account(appbox::get_instance(\bootstrap::getCore()), self::$account);
+ $this->assertTrue($this->client->getResponse()->isOk());
+ $this->assertNotContains(self::$account->get_api()->generate_login_url(registry::get_instance(), self::$account->get_api()->get_connector()->get_name()), $this->client->getResponse()->getContent());
+ }
- public function testActionModifyElement()
- {
- self::$account->get_settings()->set("auth_token", "somethingNotNull"); //connected
- $url = sprintf("/bridge/action/%s/modify/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type());
- $crawler = $this->client->request('GET', $url, array("elements_list" => "element123qcs789"));
- $this->assertTrue($this->client->getResponse()->isOk());
- $this->assertNotContains(self::$account->get_api()->generate_login_url(registry::get_instance(), self::$account->get_api()->get_connector()->get_name()), $this->client->getResponse()->getContent());
+ public function testLoadContainersDisconnected()
+ {
+ $this->client->followRedirects();
+ self::$account->get_settings()->set("auth_token", null); //deconnected
+ $url = sprintf("/bridge/adapter/%s/load-containers/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_container_type());
+ $crawler = $this->client->request('GET', $url, array("page" => 1));
+ $pageContent = $this->client->getResponse()->getContent();
+ $this->assertContains($url, $pageContent);
+ $this->deconnected($crawler, $pageContent);
+ }
- $this->client->request('POST', $url, array("elements_list" => "element123qcs789"));
- $this->assertTrue($this->client->getResponse()->isRedirect());
- }
+ public function testLoadElementsDisconnected()
+ {
+ $this->client->followRedirects();
+ self::$account->get_settings()->set("auth_token", null); //deconnected
+ $url = sprintf("/bridge/adapter/%s/load-elements/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type());
+ $crawler = $this->client->request('GET', $url, array("page" => 1));
+ $this->assertTrue($this->client->getResponse()->isOk());
+ $pageContent = $this->client->getResponse()->getContent();
+ $this->assertContains($url, $pageContent);
+ $this->deconnected($crawler, $pageContent);
+ }
- public function testActionModifyElementError()
- {
- self::$account->get_settings()->set("auth_token", "somethingNotNull");
- Bridge_Api_Apitest::$hasError = true;
- $url = sprintf("/bridge/action/%s/modify/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type());
- $this->client->request('POST', $url, array("elements_list" => "element123qcs789"));
- $this->assertTrue($this->client->getResponse()->isOk());
- }
+ public function testLogoutDeconnected()
+ {
+ $this->client->followRedirects();
+ self::$account->get_settings()->set("auth_token", null); //deconnected
+ $url = sprintf('/bridge/adapter/%d/logout/', self::$account->get_id());
+ $crawler = $this->client->request('GET', $url);
+ $pageContent = $this->client->getResponse()->getContent();
+ $this->assertContains("/adapter/" . self::$account->get_id() . "/logout/", $pageContent);
+ $this->deconnected($crawler, $pageContent);
+ }
- public function testActionModifyElementException()
- {
- self::$account->get_settings()->set("auth_token", "somethingNotNull");
- Bridge_Api_Apitest::$hasException = true;
- $url = sprintf("/bridge/action/%s/modify/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type());
- $this->client->request('POST', $url, array("elements_list" => "element123qcs789"));
- $this->assertTrue($this->client->getResponse()->isRedirect());
- $this->assertRegexp('/error/', $this->client->getResponse()->headers->get('location'));
- }
+ public function testActionDeconnected()
+ {
+ $this->client->followRedirects();
+ self::$account->get_settings()->set("auth_token", null); //deconnected
+ $url = sprintf("/bridge/action/%s/une action/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type());
+ $crawler = $this->client->request('GET', $url);
+ $pageContent = $this->client->getResponse()->getContent();
+ $this->assertContains($url, $pageContent);
+ $this->deconnected($crawler, $pageContent);
+ }
- public function testActionDeleteElement()
- {
- self::$account->get_settings()->set("auth_token", "somethingNotNull");
- $url = sprintf("/bridge/action/%s/deleteelement/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type());
- $this->client->request('GET', $url, array("elements_list" => "element123qcs789"));
- $this->assertTrue($this->client->getResponse()->isOk());
+ public function testActionUnknow()
+ {
+ self::$account->get_settings()->set("auth_token", "somethingNotNull"); //connected
+ $url = sprintf("/bridge/action/%s/ajjfhfjozqd/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type());
+ try {
+ $crawler = $this->client->request('GET', $url, array("elements_list" => "1;2;3"));
+ $this->fail("expected Exception here");
+ } catch (Exception $e) {
- Bridge_Api_Apitest::$hasException = true;
- $url = sprintf("/bridge/action/%s/deleteelement/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type());
- $this->client->request('POST', $url, array("elements_list" => "element123qcs789"));
- $this->assertTrue($this->client->getResponse()->isRedirect());
- $this->assertRegexp('/error/', $this->client->getResponse()->headers->get('location'));
+ }
- $url = sprintf("/bridge/action/%s/deleteelement/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type());
- $this->client->request('POST', $url, array("elements_list" => "element123qcs789"));
- $this->assertTrue($this->client->getResponse()->isRedirect());
- }
+ try {
+ $crawler = $this->client->request('POST', $url, array("elements_list" => "1;2;3"));
+ $this->fail("expected Exception here");
+ } catch (Exception $e) {
- public function testActionCreateContainer()
- {
- self::$account->get_settings()->set("auth_token", "somethingNotNull"); //connected
+ }
+ }
- $url = sprintf("/bridge/action/%s/createcontainer/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_container_type());
- $this->client->request('GET', $url);
- $this->assertTrue($this->client->getResponse()->isOk());
+ public function testActionModifyTooManyElements()
+ {
+ self::$account->get_settings()->set("auth_token", "somethingNotNull"); //connected
+ $url = sprintf("/bridge/action/%s/modify/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type());
+ $crawler = $this->client->request('GET', $url, array("element_list" => "1_2;1_3;1_4"));
+ $redirect = sprintf("/prod/bridge/adapter/%s/load-elements/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type());
+ $this->assertTrue($this->client->getResponse()->isRedirect());
+ $this->assertContains($redirect, $this->client->getResponse()->headers->get("location"));
+ $this->assertContains("error=", $this->client->getResponse()->headers->get("location"));
+ $this->assertNotContains(self::$account->get_api()->generate_login_url(registry::get_instance(), self::$account->get_api()->get_connector()->get_name()), $this->client->getResponse()->getContent());
+
+ $this->client->request('POST', $url, array("element_list" => "1_2;1_3;1_4"));
+ $this->assertTrue($this->client->getResponse()->isRedirect());
+ }
+
+ public function testActionModifyElement()
+ {
+ self::$account->get_settings()->set("auth_token", "somethingNotNull"); //connected
+ $url = sprintf("/bridge/action/%s/modify/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type());
+ $crawler = $this->client->request('GET', $url, array("elements_list" => "element123qcs789"));
+ $this->assertTrue($this->client->getResponse()->isOk());
+ $this->assertNotContains(self::$account->get_api()->generate_login_url(registry::get_instance(), self::$account->get_api()->get_connector()->get_name()), $this->client->getResponse()->getContent());
+
+ $this->client->request('POST', $url, array("elements_list" => "element123qcs789"));
+ $this->assertTrue($this->client->getResponse()->isRedirect());
+ }
+
+ public function testActionModifyElementError()
+ {
+ self::$account->get_settings()->set("auth_token", "somethingNotNull");
+ Bridge_Api_Apitest::$hasError = true;
+ $url = sprintf("/bridge/action/%s/modify/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type());
+ $this->client->request('POST', $url, array("elements_list" => "element123qcs789"));
+ $this->assertTrue($this->client->getResponse()->isOk());
+ }
+
+ public function testActionModifyElementException()
+ {
+ self::$account->get_settings()->set("auth_token", "somethingNotNull");
+ Bridge_Api_Apitest::$hasException = true;
+ $url = sprintf("/bridge/action/%s/modify/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type());
+ $this->client->request('POST', $url, array("elements_list" => "element123qcs789"));
+ $this->assertTrue($this->client->getResponse()->isRedirect());
+ $this->assertRegexp('/error/', $this->client->getResponse()->headers->get('location'));
+ }
+
+ public function testActionDeleteElement()
+ {
+ self::$account->get_settings()->set("auth_token", "somethingNotNull");
+ $url = sprintf("/bridge/action/%s/deleteelement/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type());
+ $this->client->request('GET', $url, array("elements_list" => "element123qcs789"));
+ $this->assertTrue($this->client->getResponse()->isOk());
+
+ Bridge_Api_Apitest::$hasException = true;
+ $url = sprintf("/bridge/action/%s/deleteelement/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type());
+ $this->client->request('POST', $url, array("elements_list" => "element123qcs789"));
+ $this->assertTrue($this->client->getResponse()->isRedirect());
+ $this->assertRegexp('/error/', $this->client->getResponse()->headers->get('location'));
+
+ $url = sprintf("/bridge/action/%s/deleteelement/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type());
+ $this->client->request('POST', $url, array("elements_list" => "element123qcs789"));
+ $this->assertTrue($this->client->getResponse()->isRedirect());
+ }
+
+ public function testActionCreateContainer()
+ {
+ self::$account->get_settings()->set("auth_token", "somethingNotNull"); //connected
+
+ $url = sprintf("/bridge/action/%s/createcontainer/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_container_type());
+ $this->client->request('GET', $url);
+ $this->assertTrue($this->client->getResponse()->isOk());
- Bridge_Api_Apitest::$hasException = true;
- $url = sprintf("/bridge/action/%s/createcontainer/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type());
- $this->client->request('POST', $url);
- $this->assertTrue($this->client->getResponse()->isRedirect());
- $this->assertRegexp('/error/', $this->client->getResponse()->headers->get('location'));
+ Bridge_Api_Apitest::$hasException = true;
+ $url = sprintf("/bridge/action/%s/createcontainer/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type());
+ $this->client->request('POST', $url);
+ $this->assertTrue($this->client->getResponse()->isRedirect());
+ $this->assertRegexp('/error/', $this->client->getResponse()->headers->get('location'));
- $url = sprintf("/bridge/action/%s/createcontainer/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_container_type());
- $this->client->request('POST', $url, array('title' => 'test', 'description' => 'description'));
- $this->assertTrue($this->client->getResponse()->isRedirect());
- $this->assertRegexp('/success/', $this->client->getResponse()->headers->get('location'));
- }
+ $url = sprintf("/bridge/action/%s/createcontainer/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_container_type());
+ $this->client->request('POST', $url, array('title' => 'test', 'description' => 'description'));
+ $this->assertTrue($this->client->getResponse()->isRedirect());
+ $this->assertRegexp('/success/', $this->client->getResponse()->headers->get('location'));
+ }
- /**
- * @todo no templates declared for modify a container in any apis
- */
- public function testActionModifyContainer()
- {
- $this->markTestSkipped("No templates declared for modify a container in any apis");
- self::$account->get_settings()->set("auth_token", "somethingNotNull"); //connected
- $url = sprintf("/bridge/action/%s/modify/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_container_type());
- $crawler = $this->client->request('GET', $url, array("elements_list" => "containerudt456shn"));
- $this->assertTrue($this->client->getResponse()->isOk());
- $pageContent = $this->client->getResponse()->getContent();
- $this->assertNotContains(self::$account->get_api()->generate_login_url(registry::get_instance(), self::$account->get_api()->get_connector()->get_name()), $this->client->getResponse()->getContent());
+ /**
+ * @todo no templates declared for modify a container in any apis
+ */
+ public function testActionModifyContainer()
+ {
+ $this->markTestSkipped("No templates declared for modify a container in any apis");
+ self::$account->get_settings()->set("auth_token", "somethingNotNull"); //connected
+ $url = sprintf("/bridge/action/%s/modify/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_container_type());
+ $crawler = $this->client->request('GET', $url, array("elements_list" => "containerudt456shn"));
+ $this->assertTrue($this->client->getResponse()->isOk());
+ $pageContent = $this->client->getResponse()->getContent();
+ $this->assertNotContains(self::$account->get_api()->generate_login_url(registry::get_instance(), self::$account->get_api()->get_connector()->get_name()), $this->client->getResponse()->getContent());
- $this->client->request('POST', $url, array("elements_list" => "containerudt456shn"));
- $this->assertTrue($this->client->getResponse()->isOk());
- }
+ $this->client->request('POST', $url, array("elements_list" => "containerudt456shn"));
+ $this->assertTrue($this->client->getResponse()->isOk());
+ }
- public function testActionMoveInto()
- {
- self::$account->get_settings()->set("auth_token", "somethingNotNull"); //connected
- $url = sprintf("/bridge/action/%s/moveinto/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type());
- $crawler = $this->client->request('GET', $url, array("elements_list" => "containerudt456shn", 'destination' => self::$account->get_api()->get_connector()->get_default_container_type()));
- $this->assertNotContains("http://dev.phrasea.net/prod/bridge/login/youtube/", $this->client->getResponse()->getContent());
- $this->assertTrue($this->client->getResponse()->isOk());
+ public function testActionMoveInto()
+ {
+ self::$account->get_settings()->set("auth_token", "somethingNotNull"); //connected
+ $url = sprintf("/bridge/action/%s/moveinto/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type());
+ $crawler = $this->client->request('GET', $url, array("elements_list" => "containerudt456shn", 'destination' => self::$account->get_api()->get_connector()->get_default_container_type()));
+ $this->assertNotContains("http://dev.phrasea.net/prod/bridge/login/youtube/", $this->client->getResponse()->getContent());
+ $this->assertTrue($this->client->getResponse()->isOk());
- $this->client->request('POST', $url, array("elements_list" => "containerudt456shn", 'destination' => self::$account->get_api()->get_connector()->get_default_container_type()));
- $this->assertRegexp('/success/', $this->client->getResponse()->headers->get('location'));
- $this->assertTrue($this->client->getResponse()->isRedirect());
+ $this->client->request('POST', $url, array("elements_list" => "containerudt456shn", 'destination' => self::$account->get_api()->get_connector()->get_default_container_type()));
+ $this->assertRegexp('/success/', $this->client->getResponse()->headers->get('location'));
+ $this->assertTrue($this->client->getResponse()->isRedirect());
- Bridge_Api_Apitest::$hasException = true;
- $this->client->request('POST', $url, array("elements_list" => "containerudt456shn", 'destination' => self::$account->get_api()->get_connector()->get_default_container_type()));
- $this->assertRegexp('/error/', $this->client->getResponse()->headers->get('location'));
- $this->assertTrue($this->client->getResponse()->isRedirect());
- }
+ Bridge_Api_Apitest::$hasException = true;
+ $this->client->request('POST', $url, array("elements_list" => "containerudt456shn", 'destination' => self::$account->get_api()->get_connector()->get_default_container_type()));
+ $this->assertRegexp('/error/', $this->client->getResponse()->headers->get('location'));
+ $this->assertTrue($this->client->getResponse()->isRedirect());
+ }
- public function deconnected($crawler, $pageContent)
- {
- $this->assertTrue($this->client->getResponse()->isOk());
- $this->assertContains("prod/bridge/login/" . mb_strtolower(self::$account->get_api()->get_connector()->get_name()) . "/", $pageContent);
- }
+ public function deconnected($crawler, $pageContent)
+ {
+ $this->assertTrue($this->client->getResponse()->isOk());
+ $this->assertContains("prod/bridge/login/" . mb_strtolower(self::$account->get_api()->get_connector()->get_name()) . "/", $pageContent);
+ }
- public function testUpload()
- {
- self::$account->get_settings()->set("auth_token", "somethingNotNull");
- $url = "/bridge/upload/";
- $this->client->request('GET', $url, array("account_id" => self::$account->get_id()));
+ public function testUpload()
+ {
+ self::$account->get_settings()->set("auth_token", "somethingNotNull");
+ $url = "/bridge/upload/";
+ $this->client->request('GET', $url, array("account_id" => self::$account->get_id()));
- $response = $this->client->getResponse();
- $this->assertTrue($response->isOk());
+ $response = $this->client->getResponse();
+ $this->assertTrue($response->isOk());
- $records = array(
- self::$record_1->get_serialize_key()
- );
+ $records = array(
+ self::$record_1->get_serialize_key()
+ );
- Bridge_Api_Apitest::$hasError = true;
- $lst = implode(';', $records);
- $this->client->request('POST', $url, array("account_id" => self::$account->get_id(), 'lst' => $lst));
- $response = $this->client->getResponse();
- $this->assertTrue($response->isOk());
-
- $this->client->request('POST', $url, array("account_id" => self::$account->get_id(), 'lst' => $lst));
- $response = $this->client->getResponse();
- $this->assertTrue($response->isRedirect());
- }
+ Bridge_Api_Apitest::$hasError = true;
+ $lst = implode(';', $records);
+ $this->client->request('POST', $url, array("account_id" => self::$account->get_id(), 'lst' => $lst));
+ $response = $this->client->getResponse();
+ $this->assertTrue($response->isOk());
+ $this->client->request('POST', $url, array("account_id" => self::$account->get_id(), 'lst' => $lst));
+ $response = $this->client->getResponse();
+ $this->assertTrue($response->isRedirect());
+ }
}
diff --git a/tests/Alchemy/Phrasea/Controller/Prod/EditTest.php b/tests/Alchemy/Phrasea/Controller/Prod/EditTest.php
index 6c9f0f2dde..90a8b10405 100644
--- a/tests/Alchemy/Phrasea/Controller/Prod/EditTest.php
+++ b/tests/Alchemy/Phrasea/Controller/Prod/EditTest.php
@@ -2,93 +2,73 @@
require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.class.inc';
-
class ControllerEditTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
+ protected $client;
+ protected static $need_records = 1;
- /**
- * As controllers use WebTestCase, it requires a client
- */
- protected $client;
+ public function createApplication()
+ {
+ return require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Prod.php';
+ }
- /**
- * If the controller tests require some records, specify it her
- *
- * For example, this will loacd 2 records
- * (self::$record_1 and self::$record_2) :
- *
- * $need_records = 2;
- *
- */
- protected static $need_records = 1;
+ public function setUp()
+ {
+ parent::setUp();
+ $this->client = $this->createClient();
+ }
- /**
- * The application loader
- */
- public function createApplication()
- {
- return require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Prod.php';
- }
+ /**
+ * Default route test
+ */
+ public function testRouteSlash()
+ {
+ $this->client->request('POST', '/records/edit/', array('lst' => self::$record_1->get_serialize_key()));
- public function setUp()
- {
- parent::setUp();
- $this->client = $this->createClient();
- }
+ $response = $this->client->getResponse();
- /**
- * Default route test
- */
- public function testRouteSlash()
- {
- $this->client->request('POST', '/records/edit/', array('lst' => self::$record_1->get_serialize_key()));
+ $this->assertTrue($response->isOk());
+ }
- $response = $this->client->getResponse();
+ public function testApply()
+ {
+ $this->client->request('POST', '/records/edit/apply/', array('lst' => self::$record_1->get_serialize_key()));
- $this->assertTrue($response->isOk());
- }
+ $response = $this->client->getResponse();
- public function testApply()
- {
- $this->client->request('POST', '/records/edit/apply/', array('lst' => self::$record_1->get_serialize_key()));
+ $this->assertTrue($response->isOk());
+ }
- $response = $this->client->getResponse();
+ public function testVocabulary()
+ {
+ $this->client->request('GET', '/records/edit/vocabulary/Zanzibar/');
- $this->assertTrue($response->isOk());
- }
+ $response = $this->client->getResponse();
+ $this->assertTrue($response->isOk());
+ $datas = json_decode($response->getContent());
+ $this->assertFalse($datas->success);
+ $this->client->request('GET', '/records/edit/vocabulary/User/');
- public function testVocabulary()
- {
- $this->client->request('GET', '/records/edit/vocabulary/Zanzibar/');
+ $response = $this->client->getResponse();
+ $this->assertTrue($response->isOk());
+ $datas = json_decode($response->getContent());
+ $this->assertFalse($datas->success);
- $response = $this->client->getResponse();
- $this->assertTrue($response->isOk());
- $datas = json_decode($response->getContent());
- $this->assertFalse($datas->success);
+ $params = array('sbas_id' => self::$collection->get_sbas_id());
+ $this->client->request('GET', '/records/edit/vocabulary/Zanzibar/', $params);
- $this->client->request('GET', '/records/edit/vocabulary/User/');
+ $response = $this->client->getResponse();
+ $this->assertTrue($response->isOk());
+ $datas = json_decode($response->getContent());
+ $this->assertFalse($datas->success);
- $response = $this->client->getResponse();
- $this->assertTrue($response->isOk());
- $datas = json_decode($response->getContent());
- $this->assertFalse($datas->success);
-
- $params = array('sbas_id'=>self::$collection->get_sbas_id());
- $this->client->request('GET', '/records/edit/vocabulary/Zanzibar/', $params);
-
- $response = $this->client->getResponse();
- $this->assertTrue($response->isOk());
- $datas = json_decode($response->getContent());
- $this->assertFalse($datas->success);
-
- $params = array('sbas_id'=>self::$collection->get_sbas_id());
- $this->client->request('GET', '/records/edit/vocabulary/User/', $params);
-
- $response = $this->client->getResponse();
- $this->assertTrue($response->isOk());
- $datas = json_decode($response->getContent());
- $this->assertTrue($datas->success);
- }
+ $params = array('sbas_id' => self::$collection->get_sbas_id());
+ $this->client->request('GET', '/records/edit/vocabulary/User/', $params);
+ $response = $this->client->getResponse();
+ $this->assertTrue($response->isOk());
+ $datas = json_decode($response->getContent());
+ $this->assertTrue($datas->success);
+ }
}
diff --git a/tests/Alchemy/Phrasea/Controller/Prod/FeedTest.php b/tests/Alchemy/Phrasea/Controller/Prod/FeedTest.php
index 5591d66a32..724cbb9ded 100644
--- a/tests/Alchemy/Phrasea/Controller/Prod/FeedTest.php
+++ b/tests/Alchemy/Phrasea/Controller/Prod/FeedTest.php
@@ -7,467 +7,447 @@ use Symfony\Component\HttpFoundation\Response;
class ControllerFeedApp extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
-
- /**
- *
- * @var Feed_Adapter
- */
- protected $feed;
-
- /**
- *
- * @var Feed_Entry_Adapter
- */
- protected $entry;
-
- /**
- *
- * @var Feed_Entry_Item
- */
- protected $item;
-
- /**
- *
- * @var Feed_Publisher_Adapter
- */
- protected $publisher;
- protected $client;
- protected $feed_title = 'feed title';
- protected $feed_subtitle = 'feed subtitle';
- protected $entry_title = 'entry title';
- protected $entry_subtitle = 'entry subtitle';
- protected $entry_authorname = 'author name';
- protected $entry_authormail = 'author.mail@example.com';
- protected static $need_records = 2;
- protected static $need_subdefs = false;
-
- public static function setUpBeforeClass()
- {
- parent::setUpBeforeClass();
- }
-
- public static function tearDownAfterClass()
- {
- parent::tearDownAfterClass();
- }
-
- public function setUp()
- {
- parent::setUp();
-
- $appbox = appbox::get_instance(\bootstrap::getCore());
-
- $this->client = $this->createClient();
-
- $this->feed = Feed_Adapter::create(
- $appbox, self::$user, $this->feed_title, $this->feed_subtitle
- );
-
- $this->publisher = Feed_Publisher_Adapter::getPublisher(
- $appbox, $this->feed, self::$user
- );
-
- $this->entry = Feed_Entry_Adapter::create(
- $appbox
- , $this->feed
- , $this->publisher
- , $this->entry_title
- , $this->entry_subtitle
- , $this->entry_authorname
- , $this->entry_authormail
- );
-
- $this->item = Feed_Entry_Item::create($appbox, $this->entry, self::$record_1);
- }
-
- public function tearDown()
- {
- if ($this->feed instanceof Feed_Adapter)
- {
- $this->feed->delete();
- }
- else if($this->entry instanceof Feed_Entry_Adapter)
- {
- $this->entry->delete();
- if ($this->publisher instanceof Feed_Publisher_Adapter)
- {
- $this->publisher->delete();
- }
- }
-
- parent::tearDown();
- }
-
- public function createApplication()
- {
- return require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Prod.php';
- }
-
- public function testRequestAvailable()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $crawler = $this->client->request('POST', '/feeds/requestavailable/');
- $this->assertTrue($this->client->getResponse()->isOk());
- $feeds = Feed_Collection::load_all($appbox, self::$user);
- foreach ($feeds->get_feeds() as $one_feed)
- {
- if ($one_feed->is_publisher(self::$user))
- {
- $this->assertEquals(1, $crawler->filterXPath("//input[@value='" . $one_feed->get_id() . "']")->count());
- }
- }
- }
-
- public function testEntryCreate()
- {
- $params = array(
- "feed_id" => $this->feed->get_id()
- , "title" => "salut"
- , "subtitle" => "coucou"
- , "author_name" => "robert"
- , "author_email" => "robert@kikoo.mail"
- , 'lst' => self::$record_1->get_serialize_key()
- );
-
- $crawler = $this->client->request('POST', '/feeds/entry/create/', $params);
- $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));
- $this->assertFalse($pageContent->error);
- $this->assertFalse($pageContent->message);
- }
-
- public function testEntryCreateError()
- {
- $params = array(
- "feed_id" => 'unknow'
- , "title" => "salut"
- , "subtitle" => "coucou"
- , "author_name" => "robert"
- , "author_email" => "robert@kikoo.mail"
- , 'lst' => self::$record_1->get_serialize_key()
- );
- $crawler = $this->client->request('POST', '/feeds/entry/create/', $params);
- $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));
- $this->assertTrue($pageContent->error);
- $this->assertTrue(is_string($pageContent->message));
- }
-
- public function testEntryEdit()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
-
- $crawler = $this->client->request('GET', '/feeds/entry/' . $this->entry->get_id() . '/edit/');
- $pageContent = $this->client->getResponse()->getContent();
-
- foreach ($this->entry->get_content() as $content)
- {
- $this->assertEquals(1, $crawler->filterXPath("//input[@value='" . $content->get_id() . "' and @name='item_id']")->count());
- }
-
- $this->assertEquals(1, $crawler->filterXPath("//form[@action='/prod/feeds/entry/" . $this->entry->get_id() . "/update/']")->count());
- $this->assertEquals(1, $crawler->filterXPath("//input[@value='" . $this->entry_title . "']")->count());
- $this->assertEquals($this->entry_subtitle, $crawler->filterXPath("//textarea[@id='feed_add_subtitle']")->text());
- $this->assertEquals(1, $crawler->filterXPath("//input[@value='" . $this->entry_authorname . "']")->count());
- $this->assertEquals(1, $crawler->filterXPath("//input[@value='" . $this->entry_authormail . "']")->count());
- }
-
- public function testEntryEditUnauthorized()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
-
- $feed = Feed_Adapter::create(
- $appbox, self::$user_alt1, $this->feed_title, $this->feed_subtitle
- );
-
- $publisher = Feed_Publisher_Adapter::getPublisher(
- $appbox, $feed, self::$user_alt1
- );
-
- $entry = Feed_Entry_Adapter::create(
- $appbox
- , $feed
- , $publisher
- , $this->entry_title
- , $this->entry_subtitle
- , $this->entry_authorname
- , $this->entry_authormail
- );
-
-
- $crawler = $this->client->request('GET', '/feeds/entry/' . $entry->get_id() . '/edit/');
-
- $response = $this->client->getResponse();
-
- $this->assertFalse($response->isOk());
-
- $feed->delete();
- }
-
- public function testEntryUpdate()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
-
- $params = array(
- "feed_id" => $this->feed->get_id()
- , "title" => "dog"
- , "subtitle" => "cat"
- , "author_name" => "bird"
- , "author_email" => "mouse"
- , 'lst' => self::$record_1->get_serialize_key()
- );
-
- $crawler = $this->client->request('POST', '/feeds/entry/' . $this->entry->get_id() . '/update/', $params);
- $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));
- $this->assertFalse($pageContent->error);
- $this->assertTrue(is_string($pageContent->message));
- $this->assertTrue(is_string($pageContent->datas));
- $this->assertRegExp("/entry_" . $this->entry->get_id() . "/", $pageContent->datas);
- }
-
- public function testEntryUpdateNotFound()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
-
- $params = array(
- "feed_id" => 9999999
- , "title" => "dog"
- , "subtitle" => "cat"
- , "author_name" => "bird"
- , "author_email" => "mouse"
- , 'lst' => self::$record_1->get_serialize_key()
- );
-
- $crawler = $this->client->request('POST', '/feeds/entry/99999999/update/', $params);
-
- $response = $this->client->getResponse();
-
- $pageContent = json_decode($response->getContent());
-
- $this->assertTrue($response->isOk());
- $this->assertEquals("application/json", $response->headers->get("content-type"));
- $this->assertTrue(is_object($pageContent));
- $this->assertTrue($pageContent->error);
- $this->assertTrue(is_string($pageContent->message));
- }
-
- public function testEntryUpdateFailed()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
-
- $params = array(
- "feed_id" => 9999999
- , "title" => "dog"
- , "subtitle" => "cat"
- , "author_name" => "bird"
- , "author_email" => "mouse"
- , 'sorted_lst' => self::$record_1->get_serialize_key() . ";" . self::$record_2->get_serialize_key() . ";12345;" . "unknow_unknow"
- );
-
- $crawler = $this->client->request('POST', '/feeds/entry/' . $this->entry->get_id() . '/update/', $params);
-
- $response = $this->client->getResponse();
-
- $this->assertTrue($response->isOk());
- $pageContent = json_decode($response->getContent());
-
- $this->assertEquals("application/json", $response->headers->get("content-type"));
- $this->assertTrue(is_object($pageContent));
- $this->assertTrue($pageContent->error);
- $this->assertTrue(is_string($pageContent->message));
- }
-
- public function testEntryUpdateUnauthorized()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
/**
- * I CREATE A FEED THAT IS NOT MINE
- * */
- $feed = Feed_Adapter::create($appbox, self::$user_alt1, "salut", 'coucou');
- $publisher = Feed_Publisher_Adapter::getPublisher($appbox, $feed, self::$user_alt1);
- $entry = Feed_Entry_Adapter::create($appbox, $feed, $publisher, "hello", "coucou", "salut", "bonjour@phraseanet.com");
- $item = Feed_Entry_Item::create($appbox, $entry, self::$record_1);
+ *
+ * @var Feed_Adapter
+ */
+ protected $feed;
- $params = array(
- "feed_id" => $feed->get_id()
- , "title" => "dog"
- , "subtitle" => "cat"
- , "author_name" => "bird"
- , "author_email" => "mouse"
- , 'lst' => self::$record_1->get_serialize_key()
- );
-
- $crawler = $this->client->request('POST', '/feeds/entry/' . $entry->get_id() . '/update/', $params);
-
- $response = $this->client->getResponse();
-
- $this->assertTrue($response->isOk());
- $pageContent = json_decode($response->getContent());
-
- $this->assertEquals("application/json", $response->headers->get("content-type"));
- $this->assertTrue(is_object($pageContent));
- $this->assertTrue($pageContent->error);
- $this->assertTrue(is_string($pageContent->message));
-
- $feed->delete();
- }
-
- public function testDelete()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
-
- $crawler = $this->client->request('POST', '/feeds/entry/' . $this->entry->get_id() . '/delete/');
-
- $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));
- $this->assertFalse($pageContent->error);
- $this->assertTrue(is_string($pageContent->message));
-
- try
- {
- Feed_Entry_Adapter::load_from_id($appbox, $this->entry->get_id());
- $this->fail("Failed to delete entry");
- }
- catch (Exception $e)
- {
-
- }
- }
-
- public function testDeleteNotFound()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
-
- $crawler = $this->client->request('POST', '/feeds/entry/9999999/delete/');
-
- $response = $this->client->getResponse();
-
- $pageContent = json_decode($this->client->getResponse()->getContent());
-
- $this->assertTrue($response->isOk());
- $this->assertEquals("application/json", $response->headers->get("content-type"));
- $this->assertTrue(is_object($pageContent));
- $this->assertTrue($pageContent->error);
- $this->assertTrue(is_string($pageContent->message));
- }
-
- public function testDeleteUnauthorized()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
/**
- * I CREATE A FEED
- * */
- $feed = Feed_Adapter::create($appbox, self::$user_alt1, "salut", 'coucou');
+ *
+ * @var Feed_Entry_Adapter
+ */
+ protected $entry;
- $publisher = Feed_Publisher_Adapter::getPublisher($appbox, $feed, self::$user_alt1);
- $entry = Feed_Entry_Adapter::create($appbox, $feed, $publisher, "hello", "coucou", "salut", "bonjour@phraseanet.com");
- $item = Feed_Entry_Item::create($appbox, $entry, self::$record_1);
+ /**
+ *
+ * @var Feed_Entry_Item
+ */
+ protected $item;
- $crawler = $this->client->request('POST', '/feeds/entry/' . $entry->get_id() . '/delete/');
+ /**
+ *
+ * @var Feed_Publisher_Adapter
+ */
+ protected $publisher;
+ protected $client;
+ protected $feed_title = 'feed title';
+ protected $feed_subtitle = 'feed subtitle';
+ protected $entry_title = 'entry title';
+ protected $entry_subtitle = 'entry subtitle';
+ protected $entry_authorname = 'author name';
+ protected $entry_authormail = 'author.mail@example.com';
+ protected static $need_records = 2;
+ protected static $need_subdefs = false;
- $response = $this->client->getResponse();
-
- $pageContent = json_decode($this->client->getResponse()->getContent());
-
- $this->assertTrue($response->isOk());
- $this->assertEquals("application/json", $response->headers->get("content-type"));
- $this->assertTrue(is_object($pageContent));
- $this->assertTrue($pageContent->error);
- $this->assertTrue(is_string($pageContent->message));
-
- $feed->delete();
- }
-
- public function testRoot()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
-
- $crawler = $this->client->request('GET', '/feeds/');
-
- $pageContent = $this->client->getResponse()->getContent();
-
- $this->assertTrue($this->client->getResponse()->isOk());
-
- $feeds = Feed_Collection::load_all($appbox, self::$user);
-
- foreach ($feeds->get_feeds() as $one_feed)
+ public static function setUpBeforeClass()
{
- $path = "//div[@class='submenu']/a[@href='/prod/feeds/feed/" . $one_feed->get_id() . "/']";
-
- $msg = sprintf("user %s has access to feed %s", self::$user->get_id(), $one_feed->get_id());
-
- if ($one_feed->has_access(self::$user))
- {
- $this->assertEquals(1, $crawler->filterXPath($path)->count(), $msg);
- }
- else
- {
- $this->fail('Feed_collection::load_all should return feed where I got access');
- }
+ parent::setUpBeforeClass();
}
- }
- public function testGetFeed()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
-
- $feeds = Feed_Collection::load_all($appbox, self::$user);
-
- $crawler = $this->client->request('GET', '/feeds/feed/' . $this->feed->get_id() . "/");
- $pageContent = $this->client->getResponse()->getContent();
-
- foreach ($feeds->get_feeds() as $one_feed)
+ public static function tearDownAfterClass()
{
- $path = "//div[@class='submenu']/a[@href='/prod/feeds/feed/" . $one_feed->get_id() . "/']";
-
- $msg = sprintf("user %s has access to feed %s", self::$user->get_id(), $one_feed->get_id());
-
- if ($one_feed->has_access(self::$user))
- {
- $this->assertEquals(1, $crawler->filterXPath($path)->count(), $msg);
- }
- else
- {
- $this->fail('Feed_collection::load_all should return feed where I got access');
- }
+ parent::tearDownAfterClass();
}
- }
- public function testSuscribeAggregate()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $feeds = Feed_Collection::load_all($appbox, self::$user);
- $crawler = $this->client->request('GET', '/feeds/subscribe/aggregated/');
- $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));
- $this->assertTrue(is_string($pageContent->texte));
- $suscribe_link = $feeds->get_aggregate()->get_user_link(registry::get_instance(), self::$user, Feed_Adapter::FORMAT_RSS, null, false)->get_href();
- $this->assertContains($suscribe_link, $pageContent->texte);
- }
+ public function setUp()
+ {
+ parent::setUp();
- public function testSuscribe()
- {
- $crawler = $this->client->request('GET', '/feeds/subscribe/' . $this->feed->get_id() . '/');
- $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));
- $this->assertTrue(is_string($pageContent->texte));
- $suscribe_link = $this->feed->get_user_link(registry::get_instance(), self::$user, Feed_Adapter::FORMAT_RSS, null, false)->get_href();
- $this->assertContains($suscribe_link, $pageContent->texte);
- }
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $this->client = $this->createClient();
+
+ $this->feed = Feed_Adapter::create(
+ $appbox, self::$user, $this->feed_title, $this->feed_subtitle
+ );
+
+ $this->publisher = Feed_Publisher_Adapter::getPublisher(
+ $appbox, $this->feed, self::$user
+ );
+
+ $this->entry = Feed_Entry_Adapter::create(
+ $appbox
+ , $this->feed
+ , $this->publisher
+ , $this->entry_title
+ , $this->entry_subtitle
+ , $this->entry_authorname
+ , $this->entry_authormail
+ );
+
+ $this->item = Feed_Entry_Item::create($appbox, $this->entry, self::$record_1);
+ }
+
+ public function tearDown()
+ {
+ if ($this->feed instanceof Feed_Adapter) {
+ $this->feed->delete();
+ } else if ($this->entry instanceof Feed_Entry_Adapter) {
+ $this->entry->delete();
+ if ($this->publisher instanceof Feed_Publisher_Adapter) {
+ $this->publisher->delete();
+ }
+ }
+
+ parent::tearDown();
+ }
+
+ public function createApplication()
+ {
+ return require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Prod.php';
+ }
+
+ public function testRequestAvailable()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $crawler = $this->client->request('POST', '/feeds/requestavailable/');
+ $this->assertTrue($this->client->getResponse()->isOk());
+ $feeds = Feed_Collection::load_all($appbox, self::$user);
+ foreach ($feeds->get_feeds() as $one_feed) {
+ if ($one_feed->is_publisher(self::$user)) {
+ $this->assertEquals(1, $crawler->filterXPath("//input[@value='" . $one_feed->get_id() . "']")->count());
+ }
+ }
+ }
+
+ public function testEntryCreate()
+ {
+ $params = array(
+ "feed_id" => $this->feed->get_id()
+ , "title" => "salut"
+ , "subtitle" => "coucou"
+ , "author_name" => "robert"
+ , "author_email" => "robert@kikoo.mail"
+ , 'lst' => self::$record_1->get_serialize_key()
+ );
+
+ $crawler = $this->client->request('POST', '/feeds/entry/create/', $params);
+ $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));
+ $this->assertFalse($pageContent->error);
+ $this->assertFalse($pageContent->message);
+ }
+
+ public function testEntryCreateError()
+ {
+ $params = array(
+ "feed_id" => 'unknow'
+ , "title" => "salut"
+ , "subtitle" => "coucou"
+ , "author_name" => "robert"
+ , "author_email" => "robert@kikoo.mail"
+ , 'lst' => self::$record_1->get_serialize_key()
+ );
+ $crawler = $this->client->request('POST', '/feeds/entry/create/', $params);
+ $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));
+ $this->assertTrue($pageContent->error);
+ $this->assertTrue(is_string($pageContent->message));
+ }
+
+ public function testEntryEdit()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+
+ $crawler = $this->client->request('GET', '/feeds/entry/' . $this->entry->get_id() . '/edit/');
+ $pageContent = $this->client->getResponse()->getContent();
+
+ foreach ($this->entry->get_content() as $content) {
+ $this->assertEquals(1, $crawler->filterXPath("//input[@value='" . $content->get_id() . "' and @name='item_id']")->count());
+ }
+
+ $this->assertEquals(1, $crawler->filterXPath("//form[@action='/prod/feeds/entry/" . $this->entry->get_id() . "/update/']")->count());
+ $this->assertEquals(1, $crawler->filterXPath("//input[@value='" . $this->entry_title . "']")->count());
+ $this->assertEquals($this->entry_subtitle, $crawler->filterXPath("//textarea[@id='feed_add_subtitle']")->text());
+ $this->assertEquals(1, $crawler->filterXPath("//input[@value='" . $this->entry_authorname . "']")->count());
+ $this->assertEquals(1, $crawler->filterXPath("//input[@value='" . $this->entry_authormail . "']")->count());
+ }
+
+ public function testEntryEditUnauthorized()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+
+ $feed = Feed_Adapter::create(
+ $appbox, self::$user_alt1, $this->feed_title, $this->feed_subtitle
+ );
+
+ $publisher = Feed_Publisher_Adapter::getPublisher(
+ $appbox, $feed, self::$user_alt1
+ );
+
+ $entry = Feed_Entry_Adapter::create(
+ $appbox
+ , $feed
+ , $publisher
+ , $this->entry_title
+ , $this->entry_subtitle
+ , $this->entry_authorname
+ , $this->entry_authormail
+ );
+
+
+ $crawler = $this->client->request('GET', '/feeds/entry/' . $entry->get_id() . '/edit/');
+
+ $response = $this->client->getResponse();
+
+ $this->assertFalse($response->isOk());
+
+ $feed->delete();
+ }
+
+ public function testEntryUpdate()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+
+ $params = array(
+ "feed_id" => $this->feed->get_id()
+ , "title" => "dog"
+ , "subtitle" => "cat"
+ , "author_name" => "bird"
+ , "author_email" => "mouse"
+ , 'lst' => self::$record_1->get_serialize_key()
+ );
+
+ $crawler = $this->client->request('POST', '/feeds/entry/' . $this->entry->get_id() . '/update/', $params);
+ $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));
+ $this->assertFalse($pageContent->error);
+ $this->assertTrue(is_string($pageContent->message));
+ $this->assertTrue(is_string($pageContent->datas));
+ $this->assertRegExp("/entry_" . $this->entry->get_id() . "/", $pageContent->datas);
+ }
+
+ public function testEntryUpdateNotFound()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+
+ $params = array(
+ "feed_id" => 9999999
+ , "title" => "dog"
+ , "subtitle" => "cat"
+ , "author_name" => "bird"
+ , "author_email" => "mouse"
+ , 'lst' => self::$record_1->get_serialize_key()
+ );
+
+ $crawler = $this->client->request('POST', '/feeds/entry/99999999/update/', $params);
+
+ $response = $this->client->getResponse();
+
+ $pageContent = json_decode($response->getContent());
+
+ $this->assertTrue($response->isOk());
+ $this->assertEquals("application/json", $response->headers->get("content-type"));
+ $this->assertTrue(is_object($pageContent));
+ $this->assertTrue($pageContent->error);
+ $this->assertTrue(is_string($pageContent->message));
+ }
+
+ public function testEntryUpdateFailed()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+
+ $params = array(
+ "feed_id" => 9999999
+ , "title" => "dog"
+ , "subtitle" => "cat"
+ , "author_name" => "bird"
+ , "author_email" => "mouse"
+ , 'sorted_lst' => self::$record_1->get_serialize_key() . ";" . self::$record_2->get_serialize_key() . ";12345;" . "unknow_unknow"
+ );
+
+ $crawler = $this->client->request('POST', '/feeds/entry/' . $this->entry->get_id() . '/update/', $params);
+
+ $response = $this->client->getResponse();
+
+ $this->assertTrue($response->isOk());
+ $pageContent = json_decode($response->getContent());
+
+ $this->assertEquals("application/json", $response->headers->get("content-type"));
+ $this->assertTrue(is_object($pageContent));
+ $this->assertTrue($pageContent->error);
+ $this->assertTrue(is_string($pageContent->message));
+ }
+
+ public function testEntryUpdateUnauthorized()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ /**
+ * I CREATE A FEED THAT IS NOT MINE
+ * */
+ $feed = Feed_Adapter::create($appbox, self::$user_alt1, "salut", 'coucou');
+ $publisher = Feed_Publisher_Adapter::getPublisher($appbox, $feed, self::$user_alt1);
+ $entry = Feed_Entry_Adapter::create($appbox, $feed, $publisher, "hello", "coucou", "salut", "bonjour@phraseanet.com");
+ $item = Feed_Entry_Item::create($appbox, $entry, self::$record_1);
+
+ $params = array(
+ "feed_id" => $feed->get_id()
+ , "title" => "dog"
+ , "subtitle" => "cat"
+ , "author_name" => "bird"
+ , "author_email" => "mouse"
+ , 'lst' => self::$record_1->get_serialize_key()
+ );
+
+ $crawler = $this->client->request('POST', '/feeds/entry/' . $entry->get_id() . '/update/', $params);
+
+ $response = $this->client->getResponse();
+
+ $this->assertTrue($response->isOk());
+ $pageContent = json_decode($response->getContent());
+
+ $this->assertEquals("application/json", $response->headers->get("content-type"));
+ $this->assertTrue(is_object($pageContent));
+ $this->assertTrue($pageContent->error);
+ $this->assertTrue(is_string($pageContent->message));
+
+ $feed->delete();
+ }
+
+ public function testDelete()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+
+ $crawler = $this->client->request('POST', '/feeds/entry/' . $this->entry->get_id() . '/delete/');
+
+ $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));
+ $this->assertFalse($pageContent->error);
+ $this->assertTrue(is_string($pageContent->message));
+
+ try {
+ Feed_Entry_Adapter::load_from_id($appbox, $this->entry->get_id());
+ $this->fail("Failed to delete entry");
+ } catch (Exception $e) {
+
+ }
+ }
+
+ public function testDeleteNotFound()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+
+ $crawler = $this->client->request('POST', '/feeds/entry/9999999/delete/');
+
+ $response = $this->client->getResponse();
+
+ $pageContent = json_decode($this->client->getResponse()->getContent());
+
+ $this->assertTrue($response->isOk());
+ $this->assertEquals("application/json", $response->headers->get("content-type"));
+ $this->assertTrue(is_object($pageContent));
+ $this->assertTrue($pageContent->error);
+ $this->assertTrue(is_string($pageContent->message));
+ }
+
+ public function testDeleteUnauthorized()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ /**
+ * I CREATE A FEED
+ * */
+ $feed = Feed_Adapter::create($appbox, self::$user_alt1, "salut", 'coucou');
+
+ $publisher = Feed_Publisher_Adapter::getPublisher($appbox, $feed, self::$user_alt1);
+ $entry = Feed_Entry_Adapter::create($appbox, $feed, $publisher, "hello", "coucou", "salut", "bonjour@phraseanet.com");
+ $item = Feed_Entry_Item::create($appbox, $entry, self::$record_1);
+
+ $crawler = $this->client->request('POST', '/feeds/entry/' . $entry->get_id() . '/delete/');
+
+ $response = $this->client->getResponse();
+
+ $pageContent = json_decode($this->client->getResponse()->getContent());
+
+ $this->assertTrue($response->isOk());
+ $this->assertEquals("application/json", $response->headers->get("content-type"));
+ $this->assertTrue(is_object($pageContent));
+ $this->assertTrue($pageContent->error);
+ $this->assertTrue(is_string($pageContent->message));
+
+ $feed->delete();
+ }
+
+ public function testRoot()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+
+ $crawler = $this->client->request('GET', '/feeds/');
+
+ $pageContent = $this->client->getResponse()->getContent();
+
+ $this->assertTrue($this->client->getResponse()->isOk());
+
+ $feeds = Feed_Collection::load_all($appbox, self::$user);
+
+ foreach ($feeds->get_feeds() as $one_feed) {
+ $path = "//div[@class='submenu']/a[@href='/prod/feeds/feed/" . $one_feed->get_id() . "/']";
+
+ $msg = sprintf("user %s has access to feed %s", self::$user->get_id(), $one_feed->get_id());
+
+ if ($one_feed->has_access(self::$user)) {
+ $this->assertEquals(1, $crawler->filterXPath($path)->count(), $msg);
+ } else {
+ $this->fail('Feed_collection::load_all should return feed where I got access');
+ }
+ }
+ }
+
+ public function testGetFeed()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+
+ $feeds = Feed_Collection::load_all($appbox, self::$user);
+
+ $crawler = $this->client->request('GET', '/feeds/feed/' . $this->feed->get_id() . "/");
+ $pageContent = $this->client->getResponse()->getContent();
+
+ foreach ($feeds->get_feeds() as $one_feed) {
+ $path = "//div[@class='submenu']/a[@href='/prod/feeds/feed/" . $one_feed->get_id() . "/']";
+
+ $msg = sprintf("user %s has access to feed %s", self::$user->get_id(), $one_feed->get_id());
+
+ if ($one_feed->has_access(self::$user)) {
+ $this->assertEquals(1, $crawler->filterXPath($path)->count(), $msg);
+ } else {
+ $this->fail('Feed_collection::load_all should return feed where I got access');
+ }
+ }
+ }
+
+ public function testSuscribeAggregate()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $feeds = Feed_Collection::load_all($appbox, self::$user);
+ $crawler = $this->client->request('GET', '/feeds/subscribe/aggregated/');
+ $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));
+ $this->assertTrue(is_string($pageContent->texte));
+ $suscribe_link = $feeds->get_aggregate()->get_user_link(registry::get_instance(), self::$user, Feed_Adapter::FORMAT_RSS, null, false)->get_href();
+ $this->assertContains($suscribe_link, $pageContent->texte);
+ }
+
+ public function testSuscribe()
+ {
+ $crawler = $this->client->request('GET', '/feeds/subscribe/' . $this->feed->get_id() . '/');
+ $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));
+ $this->assertTrue(is_string($pageContent->texte));
+ $suscribe_link = $this->feed->get_user_link(registry::get_instance(), self::$user, Feed_Adapter::FORMAT_RSS, null, false)->get_href();
+ $this->assertContains($suscribe_link, $pageContent->texte);
+ }
}
diff --git a/tests/Alchemy/Phrasea/Controller/Prod/LanguageTest.php b/tests/Alchemy/Phrasea/Controller/Prod/LanguageTest.php
index 3dce73b26a..414df7129f 100644
--- a/tests/Alchemy/Phrasea/Controller/Prod/LanguageTest.php
+++ b/tests/Alchemy/Phrasea/Controller/Prod/LanguageTest.php
@@ -1,47 +1,30 @@
client = $this->createClient();
+ }
- public function setUp()
- {
- parent::setUp();
- $this->client = $this->createClient();
- }
+ public function createApplication()
+ {
+ return require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Prod.php';
+ }
- public function createApplication()
- {
- return require __DIR__ . '/../../../../../lib/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));
- }
+ 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/tests/Alchemy/Phrasea/Controller/Prod/MoveCollectionTest.php b/tests/Alchemy/Phrasea/Controller/Prod/MoveCollectionTest.php
index 5daea7b345..509055accd 100644
--- a/tests/Alchemy/Phrasea/Controller/Prod/MoveCollectionTest.php
+++ b/tests/Alchemy/Phrasea/Controller/Prod/MoveCollectionTest.php
@@ -4,57 +4,39 @@ require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.
class ControllerMoveCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
+ protected $client;
+ protected static $need_records = 1;
- /**
- * As controllers use WebTestCase, it requires a client
- */
- protected $client;
+ public function createApplication()
+ {
+ return require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Prod.php';
+ }
- /**
- * If the controller tests require some records, specify it her
- *
- * For example, this will loacd 2 records
- * (self::$record_1 and self::$record_2) :
- *
- * $need_records = 2;
- *
- */
- protected static $need_records = 1;
+ public function setUp()
+ {
+ parent::setUp();
+ $this->client = $this->createClient();
+ }
- /**
- * The application loader
- */
- public function createApplication()
- {
- return require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Prod.php';
- }
+ /**
+ * Default route test
+ */
+ public function testRouteSlash()
+ {
+ $this->client->request('POST', '/records/movecollection/', array('lst' => self::$record_1->get_serialize_key()));
- public function setUp()
- {
- parent::setUp();
- $this->client = $this->createClient();
- }
+ $response = $this->client->getResponse();
- /**
- * Default route test
- */
- public function testRouteSlash()
- {
- $this->client->request('POST', '/records/movecollection/', array('lst' => self::$record_1->get_serialize_key()));
+ $this->assertTrue($response->isOk());
+ }
- $response = $this->client->getResponse();
+ public function testApply()
+ {
- $this->assertTrue($response->isOk());
- }
+ $this->client->request('POST', '/records/movecollection/apply/', array('lst' => self::$record_1->get_serialize_key(), 'base_id' => self::$collection->get_base_id()));
- public function testApply()
- {
-
- $this->client->request('POST', '/records/movecollection/apply/', array('lst' => self::$record_1->get_serialize_key(), 'base_id' => self::$collection->get_base_id()));
-
- $response = $this->client->getResponse();
-
- $this->assertTrue($response->isOk());
- }
+ $response = $this->client->getResponse();
+ $this->assertTrue($response->isOk());
+ }
}
diff --git a/tests/Alchemy/Phrasea/Controller/Prod/MustacheLoaderTest.php b/tests/Alchemy/Phrasea/Controller/Prod/MustacheLoaderTest.php
index 3f2a06b9e1..729a8173c7 100644
--- a/tests/Alchemy/Phrasea/Controller/Prod/MustacheLoaderTest.php
+++ b/tests/Alchemy/Phrasea/Controller/Prod/MustacheLoaderTest.php
@@ -4,54 +4,52 @@ require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.
class MustacheLoaderTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
+ protected $client;
- protected $client;
+ public function createApplication()
+ {
+ return require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Prod.php';
+ }
- public function createApplication()
- {
- return require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Prod.php';
- }
+ public function setUp()
+ {
+ parent::setUp();
+ $this->client = $this->createClient();
+ }
- public function setUp()
- {
- parent::setUp();
- $this->client = $this->createClient();
- }
+ public function testRouteSlash()
+ {
- public function testRouteSlash()
- {
+ $this->client->request('GET', '/MustacheLoader/');
- $this->client->request('GET', '/MustacheLoader/');
+ $response = $this->client->getResponse();
+ /* @var $response \Symfony\Component\HttpFoundation\Response */
- $response = $this->client->getResponse();
- /* @var $response \Symfony\Component\HttpFoundation\Response */
+ $this->assertEquals(400, $response->getStatusCode());
+ $this->assertFalse($response->isOk());
- $this->assertEquals(400, $response->getStatusCode());
- $this->assertFalse($response->isOk());
+ $this->client->request('GET', '/MustacheLoader/', array('template' => '/../../../../config/config.yml'));
- $this->client->request('GET', '/MustacheLoader/', array('template' => '/../../../../config/config.yml'));
+ $response = $this->client->getResponse();
+ /* @var $response \Symfony\Component\HttpFoundation\Response */
- $response = $this->client->getResponse();
- /* @var $response \Symfony\Component\HttpFoundation\Response */
+ $this->assertEquals(400, $response->getStatusCode());
+ $this->assertFalse($response->isOk());
- $this->assertEquals(400, $response->getStatusCode());
- $this->assertFalse($response->isOk());
+ $this->client->request('GET', '/MustacheLoader/', array('template' => 'patator_lala'));
- $this->client->request('GET', '/MustacheLoader/', array('template' => 'patator_lala'));
+ $response = $this->client->getResponse();
+ /* @var $response \Symfony\Component\HttpFoundation\Response */
- $response = $this->client->getResponse();
- /* @var $response \Symfony\Component\HttpFoundation\Response */
+ $this->assertEquals(404, $response->getStatusCode());
+ $this->assertFalse($response->isOk());
- $this->assertEquals(404, $response->getStatusCode());
- $this->assertFalse($response->isOk());
+ $this->client->request('GET', '/MustacheLoader/', array('template' => 'Feedback-Badge'));
- $this->client->request('GET', '/MustacheLoader/', array('template' => 'Feedback-Badge'));
-
- $response = $this->client->getResponse();
- /* @var $response \Symfony\Component\HttpFoundation\Response */
-
- $this->assertEquals(200, $response->getStatusCode());
- $this->assertTrue($response->isOk());
- }
+ $response = $this->client->getResponse();
+ /* @var $response \Symfony\Component\HttpFoundation\Response */
+ $this->assertEquals(200, $response->getStatusCode());
+ $this->assertTrue($response->isOk());
+ }
}
diff --git a/tests/Alchemy/Phrasea/Controller/Prod/PrinterTest.php b/tests/Alchemy/Phrasea/Controller/Prod/PrinterTest.php
index 3e0184f6be..15687a770e 100644
--- a/tests/Alchemy/Phrasea/Controller/Prod/PrinterTest.php
+++ b/tests/Alchemy/Phrasea/Controller/Prod/PrinterTest.php
@@ -4,89 +4,70 @@ require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.
class ControllerPrinterTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
+ protected $client;
+ protected static $need_records = 4;
- /**
- * As controllers use WebTestCase, it requires a client
- */
- protected $client;
-
- /**
- * If the controller tests require some records, specify it her
- *
- * For example, this will loacd 2 records
- * (self::$record_1 and self::$record_2) :
- *
- * $need_records = 2;
- *
- */
- protected static $need_records = 4;
-
- /**
- * The application loader
- */
- public function createApplication()
- {
- return require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Prod.php';
- }
-
- public function setUp()
- {
- parent::setUp();
- $this->client = $this->createClient();
- }
-
- /**
- * Default route test
- */
- public function testRouteSlash()
- {
- $records = array(
- self::$record_1->get_serialize_key(),
- self::$record_2->get_serialize_key()
- );
-
- $lst = implode(';', $records);
-
- $crawler = $this->client->request('POST', '/printer/', array('lst' => $lst));
-
- $response = $this->client->getResponse();
-
- $this->assertTrue($response->isOk());
- }
-
- public function testRoutePrintPdf()
- {
- $records = array(
- self::$record_1->get_serialize_key(),
- self::$record_2->get_serialize_key(),
- self::$record_3->get_serialize_key(),
- self::$record_4->get_serialize_key(),
- );
-
- $lst = implode(';', $records);
-
- $layouts = array(
- \Alchemy\Phrasea\Out\Module\PDF::LAYOUT_PREVIEW,
- \Alchemy\Phrasea\Out\Module\PDF::LAYOUT_PREVIEWCAPTION,
- \Alchemy\Phrasea\Out\Module\PDF::LAYOUT_PREVIEWCAPTIONTDM,
- \Alchemy\Phrasea\Out\Module\PDF::LAYOUT_THUMBNAILLIST,
- \Alchemy\Phrasea\Out\Module\PDF::LAYOUT_THUMBNAILGRID
- );
-
- foreach ($layouts as $layout)
+ public function createApplication()
{
- $crawler = $this->client->request('POST', '/printer/print.pdf', array(
- 'lst' => $lst,
- 'lay' => $layout
- )
- );
-
- $response = $this->client->getResponse();
-
- $this->assertEquals("application/pdf", $response->headers->get("content-type"));
-
- $this->assertTrue($response->isOk());
+ return require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Prod.php';
}
- }
+ public function setUp()
+ {
+ parent::setUp();
+ $this->client = $this->createClient();
+ }
+
+ /**
+ * Default route test
+ */
+ public function testRouteSlash()
+ {
+ $records = array(
+ self::$record_1->get_serialize_key(),
+ self::$record_2->get_serialize_key()
+ );
+
+ $lst = implode(';', $records);
+
+ $crawler = $this->client->request('POST', '/printer/', array('lst' => $lst));
+
+ $response = $this->client->getResponse();
+
+ $this->assertTrue($response->isOk());
+ }
+
+ public function testRoutePrintPdf()
+ {
+ $records = array(
+ self::$record_1->get_serialize_key(),
+ self::$record_2->get_serialize_key(),
+ self::$record_3->get_serialize_key(),
+ self::$record_4->get_serialize_key(),
+ );
+
+ $lst = implode(';', $records);
+
+ $layouts = array(
+ \Alchemy\Phrasea\Out\Module\PDF::LAYOUT_PREVIEW,
+ \Alchemy\Phrasea\Out\Module\PDF::LAYOUT_PREVIEWCAPTION,
+ \Alchemy\Phrasea\Out\Module\PDF::LAYOUT_PREVIEWCAPTIONTDM,
+ \Alchemy\Phrasea\Out\Module\PDF::LAYOUT_THUMBNAILLIST,
+ \Alchemy\Phrasea\Out\Module\PDF::LAYOUT_THUMBNAILGRID
+ );
+
+ foreach ($layouts as $layout) {
+ $crawler = $this->client->request('POST', '/printer/print.pdf', array(
+ 'lst' => $lst,
+ 'lay' => $layout
+ )
+ );
+
+ $response = $this->client->getResponse();
+
+ $this->assertEquals("application/pdf", $response->headers->get("content-type"));
+
+ $this->assertTrue($response->isOk());
+ }
+ }
}
diff --git a/tests/Alchemy/Phrasea/Controller/Prod/PushTest.php b/tests/Alchemy/Phrasea/Controller/Prod/PushTest.php
index e147eb995e..64f924504b 100644
--- a/tests/Alchemy/Phrasea/Controller/Prod/PushTest.php
+++ b/tests/Alchemy/Phrasea/Controller/Prod/PushTest.php
@@ -4,160 +4,142 @@ require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.
class ControllerPushTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
+ protected $client;
+ protected static $need_records = 2;
- /**
- * As controllers use WebTestCase, it requires a client
- */
- protected $client;
+ public function createApplication()
+ {
+ return require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Prod.php';
+ }
- /**
- * If the controller tests require some records, specify it her
- *
- * For example, this will loacd 2 records
- * (self::$record_1 and self::$record_2) :
- *
- * $need_records = 2;
- *
- */
- protected static $need_records = 2;
+ public function setUp()
+ {
+ parent::setUp();
+ $this->client = $this->createClient();
+ }
- /**
- * The application loader
- */
- public function createApplication()
- {
- return require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Prod.php';
- }
+ /**
+ * Default route test
+ */
+ public function testRoutePOSTSendSlash()
+ {
+ $route = '/push/sendform/';
- public function setUp()
- {
- parent::setUp();
- $this->client = $this->createClient();
- }
+ $this->client->request('POST', $route);
- /**
- * Default route test
- */
- public function testRoutePOSTSendSlash()
- {
- $route = '/push/sendform/';
+ $response = $this->client->getResponse();
- $this->client->request('POST', $route);
+ $this->assertEquals(200, $response->getStatusCode());
+ $this->assertEquals('UTF-8', $response->getCharset());
+ }
- $response = $this->client->getResponse();
+ public function testRoutePOSTValidateSlash()
+ {
+ $route = '/push/validateform/';
- $this->assertEquals(200, $response->getStatusCode());
- $this->assertEquals('UTF-8', $response->getCharset());
- }
+ $this->client->request('POST', $route);
- public function testRoutePOSTValidateSlash()
- {
- $route = '/push/validateform/';
+ $response = $this->client->getResponse();
- $this->client->request('POST', $route);
+ $this->assertEquals(200, $response->getStatusCode());
+ $this->assertEquals('UTF-8', $response->getCharset());
+ }
- $response = $this->client->getResponse();
+ public function testRoutePOSTsend()
+ {
+ $route = '/push/send/';
- $this->assertEquals(200, $response->getStatusCode());
- $this->assertEquals('UTF-8', $response->getCharset());
- }
+ $records = array(
+ self::$record_1->get_serialize_key()
+ , self::$record_2->get_serialize_key()
+ );
- public function testRoutePOSTsend()
- {
- $route = '/push/send/';
+ $receivers = array(
+ array('usr_id' => self::$user_alt1->get_id(), 'HD' => 1)
+ , array('usr_id' => self::$user_alt2->get_id(), 'HD' => 0)
+ );
- $records = array(
- self::$record_1->get_serialize_key()
- , self::$record_2->get_serialize_key()
- );
+ $params = array(
+ 'lst' => implode(';', $records)
+ , 'participants' => $receivers
+ );
- $receivers = array(
- array('usr_id'=>self::$user_alt1->get_id(), 'HD'=>1)
- , array('usr_id'=>self::$user_alt2->get_id(), 'HD'=>0)
- );
+ $this->client->request('POST', $route, $params);
- $params = array(
- 'lst' => implode(';', $records)
- , 'participants' => $receivers
- );
+ $response = $this->client->getResponse();
- $this->client->request('POST', $route, $params);
+ $this->assertEquals(200, $response->getStatusCode());
+ $this->assertEquals('UTF-8', $response->getCharset());
- $response = $this->client->getResponse();
+ $datas = (array) json_decode($response->getContent());
- $this->assertEquals(200, $response->getStatusCode());
- $this->assertEquals('UTF-8', $response->getCharset());
+ $this->assertArrayHasKey('message', $datas);
+ $this->assertArrayHasKey('success', $datas);
- $datas = (array) json_decode($response->getContent());
+ $this->assertTrue($datas['success'], 'Result is successful');
+ }
- $this->assertArrayHasKey('message', $datas);
- $this->assertArrayHasKey('success', $datas);
+ public function testRoutePOSTvalidate()
+ {
+ $route = '/push/validate/';
- $this->assertTrue($datas['success'], 'Result is successful');
- }
+ $records = array(
+ self::$record_1->get_serialize_key()
+ , self::$record_2->get_serialize_key()
+ );
- public function testRoutePOSTvalidate()
- {
- $route = '/push/validate/';
+ $participants = array(
+ array(
+ 'usr_id' => self::$user_alt1->get_id(),
+ 'agree' => 0,
+ 'see_others' => 1,
+ 'HD' => 0,
+ )
+ , array(
+ 'usr_id' => self::$user_alt2->get_id(),
+ 'agree' => 1,
+ 'see_others' => 0,
+ 'HD' => 1,
+ )
+ );
- $records = array(
- self::$record_1->get_serialize_key()
- , self::$record_2->get_serialize_key()
- );
+ $params = array(
+ 'lst' => implode(';', $records)
+ , 'participants' => $participants
+ );
- $participants = array(
- array(
- 'usr_id' => self::$user_alt1->get_id(),
- 'agree'=> 0,
- 'see_others'=> 1,
- 'HD'=> 0,
- )
- , array(
- 'usr_id' => self::$user_alt2->get_id(),
- 'agree'=> 1,
- 'see_others'=> 0,
- 'HD'=> 1,
- )
- );
+ $this->client->request('POST', $route, $params);
- $params = array(
- 'lst' => implode(';', $records)
- , 'participants' => $participants
- );
+ $response = $this->client->getResponse();
- $this->client->request('POST', $route, $params);
+ $this->assertEquals(200, $response->getStatusCode());
+ $this->assertEquals('UTF-8', $response->getCharset());
- $response = $this->client->getResponse();
+ $datas = (array) json_decode($response->getContent());
- $this->assertEquals(200, $response->getStatusCode());
- $this->assertEquals('UTF-8', $response->getCharset());
+ $this->assertArrayHasKey('message', $datas);
+ $this->assertArrayHasKey('success', $datas);
- $datas = (array) json_decode($response->getContent());
+ $this->assertTrue($datas['success'], 'Result is successful');
+ }
- $this->assertArrayHasKey('message', $datas);
- $this->assertArrayHasKey('success', $datas);
+ public function testRouteGETsearchuser()
+ {
+ $route = '/push/search-user/';
- $this->assertTrue($datas['success'], 'Result is successful');
- }
+ $params = array(
+ 'query' => ''
+ );
- public function testRouteGETsearchuser()
- {
- $route = '/push/search-user/';
+ $this->client->request('GET', $route, $params);
- $params = array(
- 'query' => ''
- );
+ $response = $this->client->getResponse();
- $this->client->request('GET', $route, $params);
+ $this->assertEquals(200, $response->getStatusCode());
+ $this->assertEquals('UTF-8', $response->getCharset());
- $response = $this->client->getResponse();
-
- $this->assertEquals(200, $response->getStatusCode());
- $this->assertEquals('UTF-8', $response->getCharset());
-
- $datas = (array) json_decode($response->getContent());
-
- $this->assertTrue(is_array($datas), 'Json is valid');
- }
+ $datas = (array) json_decode($response->getContent());
+ $this->assertTrue(is_array($datas), 'Json is valid');
+ }
}
diff --git a/tests/Alchemy/Phrasea/Controller/Prod/RootTest.php b/tests/Alchemy/Phrasea/Controller/Prod/RootTest.php
index 93924ed5bf..2641ec0f5a 100644
--- a/tests/Alchemy/Phrasea/Controller/Prod/RootTest.php
+++ b/tests/Alchemy/Phrasea/Controller/Prod/RootTest.php
@@ -4,49 +4,31 @@ require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.
class ControllerRootTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
+ protected $client;
+ protected static $need_records = false;
- /**
- * As controllers use WebTestCase, it requires a client
- */
- protected $client;
- /**
- * If the controller tests require some records, specify it her
- *
- * For example, this will loacd 2 records
- * (self::$record_1 and self::$record_2) :
- *
- * $need_records = 2;
- *
- */
- protected static $need_records = false;
+ public function createApplication()
+ {
+ return require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Prod.php';
+ }
- /**
- * The application loader
- */
- public function createApplication()
- {
- return require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Prod.php';
- }
+ public function setUp()
+ {
+ parent::setUp();
+ $this->client = $this->createClient();
+ }
- public function setUp()
- {
- parent::setUp();
- $this->client = $this->createClient();
- }
-
- /**
- * Default route test
- */
- public function testRouteSlash()
- {
- $crawler = $this->client->request('GET', '/');
+ /**
+ * Default route test
+ */
+ public function testRouteSlash()
+ {
+ $crawler = $this->client->request('GET', '/');
- $response = $this->client->getResponse();
- /* @var $response \Symfony\Component\HttpFoundation\Response */
- $this->assertEquals(200, $response->getStatusCode());
- $this->assertEquals('UTF-8', $response->getCharset());
-
- }
-
+ $response = $this->client->getResponse();
+ /* @var $response \Symfony\Component\HttpFoundation\Response */
+ $this->assertEquals(200, $response->getStatusCode());
+ $this->assertEquals('UTF-8', $response->getCharset());
+ }
}
diff --git a/tests/Alchemy/Phrasea/Controller/Prod/StoryTest.php b/tests/Alchemy/Phrasea/Controller/Prod/StoryTest.php
index 51431a8e0d..328c2cfba8 100644
--- a/tests/Alchemy/Phrasea/Controller/Prod/StoryTest.php
+++ b/tests/Alchemy/Phrasea/Controller/Prod/StoryTest.php
@@ -1,16 +1,6 @@
client = $this->createClient();
- $this->purgeDatabase();
- }
-
- public function createApplication()
- {
- return require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Prod.php';
- }
-
- public function testRootPost()
- {
- $route = "/story/";
-
- $collections = self::$core->getAuthenticatedUser()
- ->ACL()
- ->get_granted_base(array('canaddrecord'));
-
- $collection = array_shift($collections);
-
- $crawler = $this->client->request(
- 'POST', $route, array(
- 'base_id' => $collection->get_base_id(),
- 'name' => 'test story'
- )
- );
-
- $response = $this->client->getResponse();
-
- $this->assertEquals(302, $response->getStatusCode());
-
- $query = self::$core->getEntityManager()->createQuery(
- 'SELECT COUNT(w.id) FROM \Entities\StoryWZ w'
- );
-
- $count = $query->getSingleScalarResult();
-
- $this->assertEquals(1, $count);
- }
-
- public function testRootPostJSON()
- {
- $route = "/story/";
-
- $collections = self::$core->getAuthenticatedUser()
- ->ACL()
- ->get_granted_base(array('canaddrecord'));
-
- $collection = array_shift($collections);
-
- $crawler = $this->client->request(
- 'POST', $route, array(
- 'base_id' => $collection->get_base_id(),
- 'name' => 'test story'), array(), array(
- "HTTP_ACCEPT" => "application/json")
- );
-
- $response = $this->client->getResponse();
-
- $this->assertEquals(200, $response->getStatusCode());
- }
-
- public function testCreateGet()
- {
- $route = "/story/create/";
-
- $crawler = $this->client->request('GET', $route);
-
- $response = $this->client->getResponse();
-
- $this->assertEquals(200, $response->getStatusCode());
-
- $filter = "form[action='/prod/story/']";
- $this->assertEquals(1, $crawler->filter($filter)->count());
-
- $filter = "form[action='/prod/story/'] input[name='name']";
- $this->assertEquals(1, $crawler->filter($filter)->count());
-
- $filter = "form[action='/prod/story/'] select[name='base_id']";
- $this->assertEquals(1, $crawler->filter($filter)->count());
- }
-
- public function testByIds()
- {
- $story = self::$story_1;
-
- $route = sprintf("/story/%d/%d/", $story->get_sbas_id(), $story->get_record_id());
-
- $crawler = $this->client->request('GET', $route);
-
- $response = $this->client->getResponse();
-
- $this->assertEquals(200, $response->getStatusCode());
- }
-
- public function testAddElementsToStory()
- {
- $story = self::$story_1;
-
- $route = sprintf("/story/%s/%s/addElements/", $story->get_sbas_id(), $story->get_record_id());
-
- $records = array(
- self::$record_1->get_serialize_key(),
- self::$record_2->get_serialize_key()
- );
-
- $lst = implode(';', $records);
-
- $crawler = $this->client->request('POST', $route, array('lst' => $lst));
-
- $response = $this->client->getResponse();
-
- $this->assertEquals(302, $response->getStatusCode());
-
- $this->assertEquals(2, self::$story_1->get_children()->get_count());
- }
-
- public function testAddElementsToStoryJSON()
- {
- $story = self::$story_1;
-
- $route = sprintf("/story/%s/%s/addElements/", $story->get_sbas_id(), $story->get_record_id());
-
- $records = array(
- self::$record_1->get_serialize_key(),
- self::$record_2->get_serialize_key()
- );
-
- $lst = implode(';', $records);
-
- $crawler = $this->client->request('POST', $route, array('lst' => $lst)
- , array(), array(
- "HTTP_ACCEPT" => "application/json"));
-
- $response = $this->client->getResponse();
-
- $this->assertEquals(200, $response->getStatusCode());
-
- $this->assertEquals(2, self::$story_1->get_children()->get_count());
- }
-
- public function testRemoveElementFromStory()
- {
- $story = self::$story_1;
-
- $records = array(
- self::$record_1,
- self::$record_2
- );
-
- $totalRecords = count($records);
- $n = 0;
- foreach ($records as $record)
+ public function setUp()
{
- /* @var $record \record_adapter */
- $route = sprintf(
- "/story/%s/%s/delete/%s/%s/"
- , $story->get_sbas_id()
- , $story->get_record_id()
- , $record->get_sbas_id()
- , $record->get_record_id()
- );
+ parent::setUp();
+ $this->client = $this->createClient();
+ $this->purgeDatabase();
+ }
- if (($n % 2) === 0)
- {
- $crawler = $this->client->request('POST', $route);
+ public function createApplication()
+ {
+ return require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Prod.php';
+ }
+
+ public function testRootPost()
+ {
+ $route = "/story/";
+
+ $collections = self::$core->getAuthenticatedUser()
+ ->ACL()
+ ->get_granted_base(array('canaddrecord'));
+
+ $collection = array_shift($collections);
+
+ $crawler = $this->client->request(
+ 'POST', $route, array(
+ 'base_id' => $collection->get_base_id(),
+ 'name' => 'test story'
+ )
+ );
$response = $this->client->getResponse();
$this->assertEquals(302, $response->getStatusCode());
- }
- else
- {
- $crawler = $this->client->request(
- 'POST', $route, array(), array(), array(
- "HTTP_ACCEPT" => "application/json")
+
+ $query = self::$core->getEntityManager()->createQuery(
+ 'SELECT COUNT(w.id) FROM \Entities\StoryWZ w'
);
- $response = $this->client->getResponse();
+
+ $count = $query->getSingleScalarResult();
+
+ $this->assertEquals(1, $count);
+ }
+
+ public function testRootPostJSON()
+ {
+ $route = "/story/";
+
+ $collections = self::$core->getAuthenticatedUser()
+ ->ACL()
+ ->get_granted_base(array('canaddrecord'));
+
+ $collection = array_shift($collections);
+
+ $crawler = $this->client->request(
+ 'POST', $route, array(
+ 'base_id' => $collection->get_base_id(),
+ 'name' => 'test story'), array(), array(
+ "HTTP_ACCEPT" => "application/json")
+ );
+
+ $response = $this->client->getResponse();
$this->assertEquals(200, $response->getStatusCode());
- }
- $n++;
-
- $this->assertEquals($totalRecords - $n, self::$story_1->get_children()->get_count());
}
- }
+ public function testCreateGet()
+ {
+ $route = "/story/create/";
+
+ $crawler = $this->client->request('GET', $route);
+
+ $response = $this->client->getResponse();
+
+ $this->assertEquals(200, $response->getStatusCode());
+
+ $filter = "form[action='/prod/story/']";
+ $this->assertEquals(1, $crawler->filter($filter)->count());
+
+ $filter = "form[action='/prod/story/'] input[name='name']";
+ $this->assertEquals(1, $crawler->filter($filter)->count());
+
+ $filter = "form[action='/prod/story/'] select[name='base_id']";
+ $this->assertEquals(1, $crawler->filter($filter)->count());
+ }
+
+ public function testByIds()
+ {
+ $story = self::$story_1;
+
+ $route = sprintf("/story/%d/%d/", $story->get_sbas_id(), $story->get_record_id());
+
+ $crawler = $this->client->request('GET', $route);
+
+ $response = $this->client->getResponse();
+
+ $this->assertEquals(200, $response->getStatusCode());
+ }
+
+ public function testAddElementsToStory()
+ {
+ $story = self::$story_1;
+
+ $route = sprintf("/story/%s/%s/addElements/", $story->get_sbas_id(), $story->get_record_id());
+
+ $records = array(
+ self::$record_1->get_serialize_key(),
+ self::$record_2->get_serialize_key()
+ );
+
+ $lst = implode(';', $records);
+
+ $crawler = $this->client->request('POST', $route, array('lst' => $lst));
+
+ $response = $this->client->getResponse();
+
+ $this->assertEquals(302, $response->getStatusCode());
+
+ $this->assertEquals(2, self::$story_1->get_children()->get_count());
+ }
+
+ public function testAddElementsToStoryJSON()
+ {
+ $story = self::$story_1;
+
+ $route = sprintf("/story/%s/%s/addElements/", $story->get_sbas_id(), $story->get_record_id());
+
+ $records = array(
+ self::$record_1->get_serialize_key(),
+ self::$record_2->get_serialize_key()
+ );
+
+ $lst = implode(';', $records);
+
+ $crawler = $this->client->request('POST', $route, array('lst' => $lst)
+ , array(), array(
+ "HTTP_ACCEPT" => "application/json"));
+
+ $response = $this->client->getResponse();
+
+ $this->assertEquals(200, $response->getStatusCode());
+
+ $this->assertEquals(2, self::$story_1->get_children()->get_count());
+ }
+
+ public function testRemoveElementFromStory()
+ {
+ $story = self::$story_1;
+
+ $records = array(
+ self::$record_1,
+ self::$record_2
+ );
+
+ $totalRecords = count($records);
+ $n = 0;
+ foreach ($records as $record) {
+ /* @var $record \record_adapter */
+ $route = sprintf(
+ "/story/%s/%s/delete/%s/%s/"
+ , $story->get_sbas_id()
+ , $story->get_record_id()
+ , $record->get_sbas_id()
+ , $record->get_record_id()
+ );
+
+ if (($n % 2) === 0) {
+ $crawler = $this->client->request('POST', $route);
+
+ $response = $this->client->getResponse();
+
+ $this->assertEquals(302, $response->getStatusCode());
+ } else {
+ $crawler = $this->client->request(
+ 'POST', $route, array(), array(), array(
+ "HTTP_ACCEPT" => "application/json")
+ );
+ $response = $this->client->getResponse();
+
+ $this->assertEquals(200, $response->getStatusCode());
+ }
+ $n ++;
+
+ $this->assertEquals($totalRecords - $n, self::$story_1->get_children()->get_count());
+ }
+ }
}
diff --git a/tests/Alchemy/Phrasea/Controller/Prod/TooltipTest.php b/tests/Alchemy/Phrasea/Controller/Prod/TooltipTest.php
index 5c68f8e19e..d581f77386 100644
--- a/tests/Alchemy/Phrasea/Controller/Prod/TooltipTest.php
+++ b/tests/Alchemy/Phrasea/Controller/Prod/TooltipTest.php
@@ -9,188 +9,178 @@ use Symfony\Component\HttpFoundation\Response;
class ControllerTooltipTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
+ protected $client;
+ protected static $need_records = 1;
+ protected static $need_subdefs = true;
+ protected static $need_story = 1;
- protected $client;
- protected static $need_records = 1;
- protected static $need_subdefs = true;
- protected static $need_story = 1;
+ public function setUp()
+ {
+ parent::setUp();
+ $this->client = $this->createClient();
+ }
- public function setUp()
- {
- parent::setUp();
- $this->client = $this->createClient();
- }
+ public function createApplication()
+ {
+ return require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Prod.php';
+ }
- public function createApplication()
- {
- return require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Prod.php';
- }
+ public function testRouteBasket()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
- public function testRouteBasket()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
+ $basket = $this->insertOneBasket();
- $basket = $this->insertOneBasket();
+ $crawler = $this->client->request('POST', '/tooltip/basket/' . $basket->getId() . '/');
+ $pageContent = $this->client->getResponse()->getContent();
+ $this->assertTrue($this->client->getResponse()->isOk());
- $crawler = $this->client->request('POST', '/tooltip/basket/' . $basket->getId() . '/');
- $pageContent = $this->client->getResponse()->getContent();
- $this->assertTrue($this->client->getResponse()->isOk());
+ $crawler = $this->client->request('POST', '/tootltip/basket/notanid/');
+ $pageContent = $this->client->getResponse()->getContent();
+ $this->assertFalse($this->client->getResponse()->isOk());
- $crawler = $this->client->request('POST', '/tootltip/basket/notanid/');
- $pageContent = $this->client->getResponse()->getContent();
- $this->assertFalse($this->client->getResponse()->isOk());
+ $crawler = $this->client->request('POST', '/tooltip/basket/-5/');
+ $pageContent = $this->client->getResponse()->getContent();
+ $this->assertFalse($this->client->getResponse()->isOk());
+ }
- $crawler = $this->client->request('POST', '/tooltip/basket/-5/');
- $pageContent = $this->client->getResponse()->getContent();
- $this->assertFalse($this->client->getResponse()->isOk());
- }
-
- public function testRoutePreview()
- {
- $route = '/tooltip/preview/' . self::$record_1->get_sbas_id()
+ public function testRoutePreview()
+ {
+ $route = '/tooltip/preview/' . self::$record_1->get_sbas_id()
. '/' . self::$record_1->get_record_id() . '/';
- $crawler = $this->client->request('POST', $route);
- $pageContent = $this->client->getResponse()->getContent();
- $this->assertTrue($this->client->getResponse()->isOk());
- }
+ $crawler = $this->client->request('POST', $route);
+ $pageContent = $this->client->getResponse()->getContent();
+ $this->assertTrue($this->client->getResponse()->isOk());
+ }
- public function testRouteCaption()
- {
+ public function testRouteCaption()
+ {
- $route_base = '/tooltip/caption/' . self::$record_1->get_sbas_id()
+ $route_base = '/tooltip/caption/' . self::$record_1->get_sbas_id()
. '/' . self::$record_1->get_record_id() . '/%s/';
- $routes = array(
- sprintf($route_base, 'answer')
- , sprintf($route_base, 'lazaret')
- , sprintf($route_base, 'preview')
- , sprintf($route_base, 'basket')
- , sprintf($route_base, 'overview')
- );
+ $routes = array(
+ sprintf($route_base, 'answer')
+ , sprintf($route_base, 'lazaret')
+ , sprintf($route_base, 'preview')
+ , sprintf($route_base, 'basket')
+ , sprintf($route_base, 'overview')
+ );
- foreach ($routes as $route)
- {
- $crawler = $this->client->request('POST', $route);
- $pageContent = $this->client->getResponse()->getContent();
- $this->assertTrue($this->client->getResponse()->isOk());
+ foreach ($routes as $route) {
+ $crawler = $this->client->request('POST', $route);
+ $pageContent = $this->client->getResponse()->getContent();
+ $this->assertTrue($this->client->getResponse()->isOk());
+ }
}
- }
- public function testRouteCaptionSearchEngine()
- {
- $route_base = '/tooltip/caption/' . self::$record_1->get_sbas_id()
+ public function testRouteCaptionSearchEngine()
+ {
+ $route_base = '/tooltip/caption/' . self::$record_1->get_sbas_id()
. '/' . self::$record_1->get_record_id() . '/%s/';
- $routes = array(
- sprintf($route_base, 'answer')
- , sprintf($route_base, 'lazaret')
- , sprintf($route_base, 'preview')
- , sprintf($route_base, 'basket')
- , sprintf($route_base, 'overview')
- );
+ $routes = array(
+ sprintf($route_base, 'answer')
+ , sprintf($route_base, 'lazaret')
+ , sprintf($route_base, 'preview')
+ , sprintf($route_base, 'basket')
+ , sprintf($route_base, 'overview')
+ );
- foreach ($routes as $route)
- {
- $option = new \searchEngine_options();
- $crawler = $this->client->request('POST', $route, array('options_serial' => serialize($option)));
+ foreach ($routes as $route) {
+ $option = new \searchEngine_options();
+ $crawler = $this->client->request('POST', $route, array('options_serial' => serialize($option)));
- $this->assertTrue($this->client->getResponse()->isOk());
+ $this->assertTrue($this->client->getResponse()->isOk());
+ }
}
- }
- public function testRouteTCDatas()
- {
- $route = '/tooltip/tc_datas/' . self::$record_1->get_sbas_id()
+ public function testRouteTCDatas()
+ {
+ $route = '/tooltip/tc_datas/' . self::$record_1->get_sbas_id()
. '/' . self::$record_1->get_record_id() . '/';
- $crawler = $this->client->request('POST', $route);
- $pageContent = $this->client->getResponse()->getContent();
- $this->assertTrue($this->client->getResponse()->isOk());
- }
-
- public function testRouteMetasFieldInfos()
- {
- $databox = self::$record_1->get_databox();
-
- foreach ($databox->get_meta_structure() as $field)
- {
- $route = '/tooltip/metas/FieldInfos/' . $databox->get_sbas_id()
- . '/' . $field->get_id() . '/';
-
- $crawler = $this->client->request('POST', $route);
- $pageContent = $this->client->getResponse()->getContent();
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
- }
- }
-
- public function testRouteMetasDCESInfos()
- {
- $databox = self::$record_1->get_databox();
- $dces = array(
- databox_field::DCES_CONTRIBUTOR => new databox_Field_DCES_Contributor()
- , databox_field::DCES_COVERAGE => new databox_Field_DCES_Coverage()
- , databox_field::DCES_CREATOR => new databox_Field_DCES_Creator()
- , databox_field::DCES_DESCRIPTION => new databox_Field_DCES_Description()
- );
-
- foreach ($databox->get_meta_structure() as $field)
- {
- $dces_element = array_shift($dces);
- $field->set_dces_element($dces_element);
-
- $route = '/tooltip/DCESInfos/' . $databox->get_sbas_id()
- . '/' . $field->get_id() . '/';
-
- if ($field->get_dces_element() !== null)
- {
$crawler = $this->client->request('POST', $route);
- $this->assertGreaterThan(0, strlen($this->client->getResponse()->getContent()));
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
- }
- else
- {
- $crawler = $this->client->request('POST', $route);
- $this->assertEquals(0, strlen($this->client->getResponse()->getContent()));
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
- }
+ $pageContent = $this->client->getResponse()->getContent();
+ $this->assertTrue($this->client->getResponse()->isOk());
}
- }
- public function testRouteMetaRestrictions()
- {
- $databox = self::$record_1->get_databox();
-
- foreach ($databox->get_meta_structure() as $field)
+ public function testRouteMetasFieldInfos()
{
+ $databox = self::$record_1->get_databox();
- $route = '/tooltip/metas/restrictionsInfos/' . $databox->get_sbas_id()
- . '/' . $field->get_id() . '/';
+ foreach ($databox->get_meta_structure() as $field) {
+ $route = '/tooltip/metas/FieldInfos/' . $databox->get_sbas_id()
+ . '/' . $field->get_id() . '/';
- $crawler = $this->client->request('POST', $route);
- $this->assertGreaterThan(0, strlen($this->client->getResponse()->getContent()));
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $crawler = $this->client->request('POST', $route);
+ $pageContent = $this->client->getResponse()->getContent();
+ $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ }
}
- }
- public function testRouteStory()
- {
- $databox = self::$story_1->get_databox();
+ public function testRouteMetasDCESInfos()
+ {
+ $databox = self::$record_1->get_databox();
+ $dces = array(
+ databox_field::DCES_CONTRIBUTOR => new databox_Field_DCES_Contributor()
+ , databox_field::DCES_COVERAGE => new databox_Field_DCES_Coverage()
+ , databox_field::DCES_CREATOR => new databox_Field_DCES_Creator()
+ , databox_field::DCES_DESCRIPTION => new databox_Field_DCES_Description()
+ );
+
+ foreach ($databox->get_meta_structure() as $field) {
+ $dces_element = array_shift($dces);
+ $field->set_dces_element($dces_element);
+
+ $route = '/tooltip/DCESInfos/' . $databox->get_sbas_id()
+ . '/' . $field->get_id() . '/';
+
+ if ($field->get_dces_element() !== null) {
+ $crawler = $this->client->request('POST', $route);
+ $this->assertGreaterThan(0, strlen($this->client->getResponse()->getContent()));
+ $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ } else {
+ $crawler = $this->client->request('POST', $route);
+ $this->assertEquals(0, strlen($this->client->getResponse()->getContent()));
+ $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ }
+ }
+ }
+
+ public function testRouteMetaRestrictions()
+ {
+ $databox = self::$record_1->get_databox();
+
+ foreach ($databox->get_meta_structure() as $field) {
+
+ $route = '/tooltip/metas/restrictionsInfos/' . $databox->get_sbas_id()
+ . '/' . $field->get_id() . '/';
+
+ $crawler = $this->client->request('POST', $route);
+ $this->assertGreaterThan(0, strlen($this->client->getResponse()->getContent()));
+ $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ }
+ }
+
+ public function testRouteStory()
+ {
+ $databox = self::$story_1->get_databox();
- $route = '/tooltip/Story/' . $databox->get_sbas_id()
+ $route = '/tooltip/Story/' . $databox->get_sbas_id()
. '/' . self::$story_1->get_record_id() . '/';
- $this->client->request('POST', $route);
- $this->assertTrue($this->client->getResponse()->isOk());
- }
+ $this->client->request('POST', $route);
+ $this->assertTrue($this->client->getResponse()->isOk());
+ }
- public function testUser()
- {
-
- $route = '/tooltip/user/' . self::$user->get_id() . '/';
- $this->client->request('POST', $route);
- $this->assertTrue($this->client->getResponse()->isOk());
- }
+ public function testUser()
+ {
+ $route = '/tooltip/user/' . self::$user->get_id() . '/';
+ $this->client->request('POST', $route);
+ $this->assertTrue($this->client->getResponse()->isOk());
+ }
}
diff --git a/tests/Alchemy/Phrasea/Controller/Prod/UsrListsTest.php b/tests/Alchemy/Phrasea/Controller/Prod/UsrListsTest.php
index 925a39c09b..9eeb021f36 100644
--- a/tests/Alchemy/Phrasea/Controller/Prod/UsrListsTest.php
+++ b/tests/Alchemy/Phrasea/Controller/Prod/UsrListsTest.php
@@ -4,476 +4,456 @@ require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.
class ControllerUsrListsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
+ protected $client;
+ protected static $need_records = false;
- /**
- * As controllers use WebTestCase, it requires a client
- */
- protected $client;
-
- /**
- * If the controller tests require some records, specify it her
- *
- * For example, this will loacd 2 records
- * (self::$record_1 and self::$record_2) :
- *
- * $need_records = 2;
- *
- */
- protected static $need_records = false;
-
- /**
- * The application loader
- */
- public function createApplication()
- {
- return require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Prod.php';
- }
-
- public function setUp()
- {
- parent::setUp();
- $this->client = $this->createClient();
- }
-
- /**
- * Default route test
- */
- public function testRouteSlash()
- {
- $entry1 = $this->insertOneUsrListEntry(self::$user, self::$user);
- $entry2 = $this->insertOneUsrListEntry(self::$user, self::$user_alt1);
- $entry3 = $this->insertOneUsrListEntry(self::$user, self::$user);
- $entry4 = $this->insertOneUsrListEntry(self::$user, self::$user_alt1);
- $entry5 = $this->insertOneUsrListEntry(self::$user_alt1, self::$user_alt1);
- $entry6 = $this->insertOneUsrListEntry(self::$user_alt1, self::$user_alt2);
-
- $route = '/lists/all/';
-
- $this->client->request('GET', $route, array(), array(), array("HTTP_CONTENT_TYPE" => "application/json", "HTTP_ACCEPT" => "application/json"));
-
- $response = $this->client->getResponse();
-
- $this->assertEquals(200, $response->getStatusCode());
- $this->assertEquals('UTF-8', $response->getCharset());
-
- $datas = (array) json_decode($response->getContent());
-
- $this->assertEquals(4, count($datas['result']));
- }
-
- protected function checkList($list, $owners = true, $users = true)
- {
- $this->assertInstanceOf('stdClass', $list);
- $this->assertObjectHasAttribute('name', $list);
- $this->assertObjectHasAttribute('created', $list);
- $this->assertObjectHasAttribute('updated', $list);
- $this->assertObjectHasAttribute('owners', $list);
- $this->assertObjectHasAttribute('users', $list);
-
- if ($owners)
- $this->assertTrue(count($list->owners) > 0);
-
- foreach ($list->owners as $owner)
+ public function createApplication()
{
- $this->checkOwner($owner);
+ return require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Prod.php';
}
- if ($users)
- $this->assertTrue(count($list->users) > 0);
-
- foreach ($list->users as $user)
+ public function setUp()
{
- $this->checkUser($user);
+ parent::setUp();
+ $this->client = $this->createClient();
}
- }
- public function testPostList()
- {
- $route = '/lists/list/';
+ /**
+ * Default route test
+ */
+ public function testRouteSlash()
+ {
+ $entry1 = $this->insertOneUsrListEntry(self::$user, self::$user);
+ $entry2 = $this->insertOneUsrListEntry(self::$user, self::$user_alt1);
+ $entry3 = $this->insertOneUsrListEntry(self::$user, self::$user);
+ $entry4 = $this->insertOneUsrListEntry(self::$user, self::$user_alt1);
+ $entry5 = $this->insertOneUsrListEntry(self::$user_alt1, self::$user_alt1);
+ $entry6 = $this->insertOneUsrListEntry(self::$user_alt1, self::$user_alt2);
- $this->client->request('POST', $route);
+ $route = '/lists/all/';
- $response = $this->client->getResponse();
+ $this->client->request('GET', $route, array(), array(), array("HTTP_CONTENT_TYPE" => "application/json", "HTTP_ACCEPT" => "application/json"));
- $this->assertEquals(200, $response->getStatusCode());
- $this->assertEquals('UTF-8', $response->getCharset());
+ $response = $this->client->getResponse();
- $datas = (array) json_decode($response->getContent());
+ $this->assertEquals(200, $response->getStatusCode());
+ $this->assertEquals('UTF-8', $response->getCharset());
- $this->assertArrayHasKey('success', $datas);
- $this->assertArrayHasKey('message', $datas);
+ $datas = (array) json_decode($response->getContent());
- $this->assertFalse($datas['success']);
+ $this->assertEquals(4, count($datas['result']));
+ }
- $this->client->request('POST', $route, array('name' => 'New List'));
+ protected function checkList($list, $owners = true, $users = true)
+ {
+ $this->assertInstanceOf('stdClass', $list);
+ $this->assertObjectHasAttribute('name', $list);
+ $this->assertObjectHasAttribute('created', $list);
+ $this->assertObjectHasAttribute('updated', $list);
+ $this->assertObjectHasAttribute('owners', $list);
+ $this->assertObjectHasAttribute('users', $list);
- $response = $this->client->getResponse();
+ if ($owners)
+ $this->assertTrue(count($list->owners) > 0);
- $this->assertEquals(200, $response->getStatusCode());
- $this->assertEquals('UTF-8', $response->getCharset());
+ foreach ($list->owners as $owner) {
+ $this->checkOwner($owner);
+ }
- $datas = (array) json_decode($response->getContent());
+ if ($users)
+ $this->assertTrue(count($list->users) > 0);
- $this->assertArrayHasKey('success', $datas);
- $this->assertArrayHasKey('message', $datas);
+ foreach ($list->users as $user) {
+ $this->checkUser($user);
+ }
+ }
- $this->assertTrue($datas['success']);
- }
+ public function testPostList()
+ {
+ $route = '/lists/list/';
- public function testGetList()
- {
- $entry = $this->insertOneUsrListEntry(self::$user, self::$user_alt1);
- $list_id = $entry->getList()->getId();
+ $this->client->request('POST', $route);
- $route = '/lists/list/' . $list_id . '/';
+ $response = $this->client->getResponse();
- $this->client->request('GET', $route, array(), array(), array("HTTP_CONTENT_TYPE" => "application/json", "HTTP_ACCEPT" => "application/json"));
+ $this->assertEquals(200, $response->getStatusCode());
+ $this->assertEquals('UTF-8', $response->getCharset());
- $response = $this->client->getResponse();
+ $datas = (array) json_decode($response->getContent());
- $this->assertEquals(200, $response->getStatusCode());
- $this->assertEquals('UTF-8', $response->getCharset());
+ $this->assertArrayHasKey('success', $datas);
+ $this->assertArrayHasKey('message', $datas);
+
+ $this->assertFalse($datas['success']);
+
+ $this->client->request('POST', $route, array('name' => 'New List'));
+
+ $response = $this->client->getResponse();
+
+ $this->assertEquals(200, $response->getStatusCode());
+ $this->assertEquals('UTF-8', $response->getCharset());
+
+ $datas = (array) json_decode($response->getContent());
+
+ $this->assertArrayHasKey('success', $datas);
+ $this->assertArrayHasKey('message', $datas);
+
+ $this->assertTrue($datas['success']);
+ }
+
+ public function testGetList()
+ {
+ $entry = $this->insertOneUsrListEntry(self::$user, self::$user_alt1);
+ $list_id = $entry->getList()->getId();
+
+ $route = '/lists/list/' . $list_id . '/';
+
+ $this->client->request('GET', $route, array(), array(), array("HTTP_CONTENT_TYPE" => "application/json", "HTTP_ACCEPT" => "application/json"));
+
+ $response = $this->client->getResponse();
+
+ $this->assertEquals(200, $response->getStatusCode());
+ $this->assertEquals('UTF-8', $response->getCharset());
// $datas = (array) json_decode($response->getContent());
//
// $this->assertTrue(is_array($datas));
// $this->assertArrayhasKey('result', $datas);
// $this->checkList($datas['result']);
- }
+ }
- public function testPostUpdate()
- {
- $entry = $this->insertOneUsrListEntry(self::$user, self::$user_alt1);
- $list_id = $entry->getList()->getId();
+ public function testPostUpdate()
+ {
+ $entry = $this->insertOneUsrListEntry(self::$user, self::$user_alt1);
+ $list_id = $entry->getList()->getId();
- $route = '/lists/list/' . $list_id . '/update/';
+ $route = '/lists/list/' . $list_id . '/update/';
- $this->client->request('POST', $route);
+ $this->client->request('POST', $route);
- $response = $this->client->getResponse();
+ $response = $this->client->getResponse();
- $this->assertEquals(200, $response->getStatusCode());
- $this->assertEquals('UTF-8', $response->getCharset());
+ $this->assertEquals(200, $response->getStatusCode());
+ $this->assertEquals('UTF-8', $response->getCharset());
- $datas = (array) json_decode($response->getContent());
+ $datas = (array) json_decode($response->getContent());
- $this->assertArrayHasKey('success', $datas);
- $this->assertArrayHasKey('message', $datas);
+ $this->assertArrayHasKey('success', $datas);
+ $this->assertArrayHasKey('message', $datas);
- $this->assertFalse($datas['success']);
+ $this->assertFalse($datas['success']);
- $this->client->request('POST', $route, array('name' => 'New NAME'));
+ $this->client->request('POST', $route, array('name' => 'New NAME'));
- $response = $this->client->getResponse();
+ $response = $this->client->getResponse();
- $this->assertEquals(200, $response->getStatusCode());
- $this->assertEquals('UTF-8', $response->getCharset());
+ $this->assertEquals(200, $response->getStatusCode());
+ $this->assertEquals('UTF-8', $response->getCharset());
- $datas = (array) json_decode($response->getContent());
+ $datas = (array) json_decode($response->getContent());
- $this->assertArrayHasKey('success', $datas);
- $this->assertArrayHasKey('message', $datas);
+ $this->assertArrayHasKey('success', $datas);
+ $this->assertArrayHasKey('message', $datas);
- $this->assertTrue($datas['success']);
- }
+ $this->assertTrue($datas['success']);
+ }
- public function testPostDelete()
- {
- $entry = $this->insertOneUsrListEntry(self::$user, self::$user_alt1);
- $list_id = $entry->getList()->getId();
+ public function testPostDelete()
+ {
+ $entry = $this->insertOneUsrListEntry(self::$user, self::$user_alt1);
+ $list_id = $entry->getList()->getId();
- $route = '/lists/list/' . $list_id . '/delete/';
+ $route = '/lists/list/' . $list_id . '/delete/';
- $this->client->request('POST', $route);
+ $this->client->request('POST', $route);
- $response = $this->client->getResponse();
+ $response = $this->client->getResponse();
- $this->assertEquals(200, $response->getStatusCode());
- $this->assertEquals('UTF-8', $response->getCharset());
+ $this->assertEquals(200, $response->getStatusCode());
+ $this->assertEquals('UTF-8', $response->getCharset());
- $datas = (array) json_decode($response->getContent());
+ $datas = (array) json_decode($response->getContent());
- $this->assertArrayHasKey('success', $datas);
- $this->assertArrayHasKey('message', $datas);
+ $this->assertArrayHasKey('success', $datas);
+ $this->assertArrayHasKey('message', $datas);
- $this->assertTrue($datas['success']);
+ $this->assertTrue($datas['success']);
- $repository = self::$core->getEntityManager()->getRepository('Entities\UsrList');
+ $repository = self::$core->getEntityManager()->getRepository('Entities\UsrList');
- $this->assertNull($repository->find($list_id));
- }
+ $this->assertNull($repository->find($list_id));
+ }
- public function testPostRemoveEntry()
- {
- $entry = $this->insertOneUsrListEntry(self::$user, self::$user_alt1);
- $list_id = $entry->getList()->getId();
- $usr_id = $entry->getUser()->get_id();
- $entry_id = $entry->getId();
+ public function testPostRemoveEntry()
+ {
+ $entry = $this->insertOneUsrListEntry(self::$user, self::$user_alt1);
+ $list_id = $entry->getList()->getId();
+ $usr_id = $entry->getUser()->get_id();
+ $entry_id = $entry->getId();
- $route = '/lists/list/' . $list_id . '/remove/' . $usr_id . '/';
+ $route = '/lists/list/' . $list_id . '/remove/' . $usr_id . '/';
- $this->client->request('POST', $route, array(), array(), array("HTTP_CONTENT_TYPE" => "application/json", "HTTP_ACCEPT" => "application/json"));
+ $this->client->request('POST', $route, array(), array(), array("HTTP_CONTENT_TYPE" => "application/json", "HTTP_ACCEPT" => "application/json"));
- $response = $this->client->getResponse();
+ $response = $this->client->getResponse();
- $this->assertEquals(200, $response->getStatusCode());
- $this->assertEquals('UTF-8', $response->getCharset());
+ $this->assertEquals(200, $response->getStatusCode());
+ $this->assertEquals('UTF-8', $response->getCharset());
- $datas = (array) json_decode($response->getContent());
+ $datas = (array) json_decode($response->getContent());
- $this->assertArrayHasKey('success', $datas);
- $this->assertArrayHasKey('message', $datas);
+ $this->assertArrayHasKey('success', $datas);
+ $this->assertArrayHasKey('message', $datas);
- $this->assertTrue($datas['success']);
+ $this->assertTrue($datas['success']);
- $repository = self::$core->getEntityManager()->getRepository('Entities\UsrListEntry');
+ $repository = self::$core->getEntityManager()->getRepository('Entities\UsrListEntry');
- $this->assertNull($repository->find($entry_id));
- }
+ $this->assertNull($repository->find($entry_id));
+ }
- public function testPostAddEntry()
- {
- $list = $this->insertOneUsrList(self::$user);
+ public function testPostAddEntry()
+ {
+ $list = $this->insertOneUsrList(self::$user);
- $this->assertEquals(0, $list->getEntries()->count());
+ $this->assertEquals(0, $list->getEntries()->count());
- $route = '/lists/list/' . $list->getId() . '/add/';
+ $route = '/lists/list/' . $list->getId() . '/add/';
- $this->client->request('POST', $route, array('usr_ids' => array(self::$user->get_id())), array(), array("HTTP_CONTENT_TYPE" => "application/json", "HTTP_ACCEPT" => "application/json"));
+ $this->client->request('POST', $route, array('usr_ids' => array(self::$user->get_id())), array(), array("HTTP_CONTENT_TYPE" => "application/json", "HTTP_ACCEPT" => "application/json"));
- $response = $this->client->getResponse();
+ $response = $this->client->getResponse();
- $this->assertEquals(200, $response->getStatusCode());
- $this->assertEquals('UTF-8', $response->getCharset());
+ $this->assertEquals(200, $response->getStatusCode());
+ $this->assertEquals('UTF-8', $response->getCharset());
- $datas = (array) json_decode($response->getContent());
+ $datas = (array) json_decode($response->getContent());
- $this->assertArrayHasKey('success', $datas);
- $this->assertArrayHasKey('message', $datas);
+ $this->assertArrayHasKey('success', $datas);
+ $this->assertArrayHasKey('message', $datas);
- $this->assertTrue($datas['success']);
+ $this->assertTrue($datas['success']);
- $repository = self::$core->getEntityManager()->getRepository('Entities\UsrList');
+ $repository = self::$core->getEntityManager()->getRepository('Entities\UsrList');
- $list = $repository->find($list->getId());
+ $list = $repository->find($list->getId());
- $this->assertEquals(1, $list->getEntries()->count());
- }
+ $this->assertEquals(1, $list->getEntries()->count());
+ }
- public function testPostShareList()
- {
- $list = $this->insertOneUsrList(self::$user);
+ public function testPostShareList()
+ {
+ $list = $this->insertOneUsrList(self::$user);
- $this->assertEquals(1, $list->getOwners()->count());
+ $this->assertEquals(1, $list->getOwners()->count());
- $route = '/lists/list/' . $list->getId() . '/share/' . self::$user_alt1->get_id() . '/';
+ $route = '/lists/list/' . $list->getId() . '/share/' . self::$user_alt1->get_id() . '/';
- $this->client->request('POST', $route);
+ $this->client->request('POST', $route);
- $response = $this->client->getResponse();
+ $response = $this->client->getResponse();
- $this->assertEquals(400, $response->getStatusCode());
- $this->assertEquals('UTF-8', $response->getCharset());
+ $this->assertEquals(400, $response->getStatusCode());
+ $this->assertEquals('UTF-8', $response->getCharset());
- $route = '/lists/list/' . $list->getId() . '/share/' . self::$user_alt1->get_id() . '/';
+ $route = '/lists/list/' . $list->getId() . '/share/' . self::$user_alt1->get_id() . '/';
- $this->client->request('POST', $route, array('role' => 'general'));
+ $this->client->request('POST', $route, array('role' => 'general'));
- $response = $this->client->getResponse();
+ $response = $this->client->getResponse();
- $this->assertEquals(400, $response->getStatusCode());
- $this->assertEquals('UTF-8', $response->getCharset());
+ $this->assertEquals(400, $response->getStatusCode());
+ $this->assertEquals('UTF-8', $response->getCharset());
- $route = '/lists/list/' . $list->getId() . '/share/' . self::$user_alt1->get_id() . '/';
+ $route = '/lists/list/' . $list->getId() . '/share/' . self::$user_alt1->get_id() . '/';
- $this->client->request('POST', $route, array('role' => \Entities\UsrListOwner::ROLE_ADMIN));
+ $this->client->request('POST', $route, array('role' => \Entities\UsrListOwner::ROLE_ADMIN));
- $response = $this->client->getResponse();
+ $response = $this->client->getResponse();
- $this->assertEquals(200, $response->getStatusCode());
- $this->assertEquals('UTF-8', $response->getCharset());
+ $this->assertEquals(200, $response->getStatusCode());
+ $this->assertEquals('UTF-8', $response->getCharset());
- $datas = (array) json_decode($response->getContent());
+ $datas = (array) json_decode($response->getContent());
- $this->assertArrayHasKey('success', $datas);
- $this->assertArrayHasKey('message', $datas);
+ $this->assertArrayHasKey('success', $datas);
+ $this->assertArrayHasKey('message', $datas);
- $this->assertTrue($datas['success']);
+ $this->assertTrue($datas['success']);
- $repository = self::$core->getEntityManager()->getRepository('Entities\UsrList');
+ $repository = self::$core->getEntityManager()->getRepository('Entities\UsrList');
- $list = $repository->find($list->getId());
+ $list = $repository->find($list->getId());
- $this->assertEquals(2, $list->getOwners()->count());
- }
+ $this->assertEquals(2, $list->getOwners()->count());
+ }
- public function testPostUnShareList()
- {
+ public function testPostUnShareList()
+ {
- $list = $this->insertOneUsrList(self::$user);
+ $list = $this->insertOneUsrList(self::$user);
- $this->assertEquals(1, $list->getOwners()->count());
+ $this->assertEquals(1, $list->getOwners()->count());
- $route = '/lists/list/' . $list->getId() . '/share/' . self::$user_alt1->get_id() . '/';
+ $route = '/lists/list/' . $list->getId() . '/share/' . self::$user_alt1->get_id() . '/';
- $this->client->request('POST', $route, array('role' => \Entities\UsrListOwner::ROLE_ADMIN));
+ $this->client->request('POST', $route, array('role' => \Entities\UsrListOwner::ROLE_ADMIN));
- $response = $this->client->getResponse();
+ $response = $this->client->getResponse();
- $this->assertEquals(200, $response->getStatusCode());
- $this->assertEquals('UTF-8', $response->getCharset());
+ $this->assertEquals(200, $response->getStatusCode());
+ $this->assertEquals('UTF-8', $response->getCharset());
- $datas = (array) json_decode($response->getContent());
+ $datas = (array) json_decode($response->getContent());
- $this->assertArrayHasKey('success', $datas);
- $this->assertArrayHasKey('message', $datas);
+ $this->assertArrayHasKey('success', $datas);
+ $this->assertArrayHasKey('message', $datas);
- $this->assertTrue($datas['success']);
+ $this->assertTrue($datas['success']);
- $repository = self::$core->getEntityManager()->getRepository('Entities\UsrList');
+ $repository = self::$core->getEntityManager()->getRepository('Entities\UsrList');
- $list = $repository->find($list->getId());
+ $list = $repository->find($list->getId());
- $this->assertEquals(2, $list->getOwners()->count());
+ $this->assertEquals(2, $list->getOwners()->count());
- $route = '/lists/list/' . $list->getId() . '/unshare/' . self::$user_alt1->get_id() . '/';
+ $route = '/lists/list/' . $list->getId() . '/unshare/' . self::$user_alt1->get_id() . '/';
- $this->client->request('POST', $route);
+ $this->client->request('POST', $route);
- $response = $this->client->getResponse();
+ $response = $this->client->getResponse();
- $this->assertEquals(200, $response->getStatusCode());
- $this->assertEquals('UTF-8', $response->getCharset());
+ $this->assertEquals(200, $response->getStatusCode());
+ $this->assertEquals('UTF-8', $response->getCharset());
- $datas = (array) json_decode($response->getContent());
+ $datas = (array) json_decode($response->getContent());
- $this->assertTrue($datas['success']);
+ $this->assertTrue($datas['success']);
- $repository = self::$core->getEntityManager()->getRepository('Entities\UsrList');
+ $repository = self::$core->getEntityManager()->getRepository('Entities\UsrList');
- $list = $repository->find($list->getId());
+ $list = $repository->find($list->getId());
- self::$core->getEntityManager()->refresh($list);
+ self::$core->getEntityManager()->refresh($list);
- $this->assertEquals(1, $list->getOwners()->count());
- }
+ $this->assertEquals(1, $list->getOwners()->count());
+ }
- public function testPostUnShareFail()
- {
+ public function testPostUnShareFail()
+ {
- $list = $this->insertOneUsrList(self::$user);
+ $list = $this->insertOneUsrList(self::$user);
- $this->assertEquals(1, $list->getOwners()->count());
+ $this->assertEquals(1, $list->getOwners()->count());
- $route = '/lists/list/' . $list->getId() . '/share/' . self::$user_alt1->get_id() . '/';
+ $route = '/lists/list/' . $list->getId() . '/share/' . self::$user_alt1->get_id() . '/';
- $this->client->request('POST', $route, array('role' => \Entities\UsrListOwner::ROLE_ADMIN));
+ $this->client->request('POST', $route, array('role' => \Entities\UsrListOwner::ROLE_ADMIN));
- $response = $this->client->getResponse();
+ $response = $this->client->getResponse();
- $this->assertEquals(200, $response->getStatusCode());
- $this->assertEquals('UTF-8', $response->getCharset());
+ $this->assertEquals(200, $response->getStatusCode());
+ $this->assertEquals('UTF-8', $response->getCharset());
- $datas = (array) json_decode($response->getContent());
+ $datas = (array) json_decode($response->getContent());
- $this->assertArrayHasKey('success', $datas);
- $this->assertArrayHasKey('message', $datas);
+ $this->assertArrayHasKey('success', $datas);
+ $this->assertArrayHasKey('message', $datas);
- $this->assertTrue($datas['success']);
+ $this->assertTrue($datas['success']);
- $route = '/lists/list/' . $list->getId() . '/share/' . self::$user->get_id() . '/';
+ $route = '/lists/list/' . $list->getId() . '/share/' . self::$user->get_id() . '/';
- $this->client->request('POST', $route, array('role' => \Entities\UsrListOwner::ROLE_USER));
+ $this->client->request('POST', $route, array('role' => \Entities\UsrListOwner::ROLE_USER));
- $response = $this->client->getResponse();
+ $response = $this->client->getResponse();
- $this->assertEquals(200, $response->getStatusCode());
- $this->assertEquals('UTF-8', $response->getCharset());
+ $this->assertEquals(200, $response->getStatusCode());
+ $this->assertEquals('UTF-8', $response->getCharset());
- $datas = (array) json_decode($response->getContent());
+ $datas = (array) json_decode($response->getContent());
- $this->assertArrayHasKey('success', $datas);
- $this->assertArrayHasKey('message', $datas);
+ $this->assertArrayHasKey('success', $datas);
+ $this->assertArrayHasKey('message', $datas);
- $this->assertFalse($datas['success']);
+ $this->assertFalse($datas['success']);
- $route = '/lists/list/' . $list->getId() . '/share/' . self::$user_alt1->get_id() . '/';
+ $route = '/lists/list/' . $list->getId() . '/share/' . self::$user_alt1->get_id() . '/';
- $this->client->request('POST', $route, array('role' => \Entities\UsrListOwner::ROLE_USER));
+ $this->client->request('POST', $route, array('role' => \Entities\UsrListOwner::ROLE_USER));
- $response = $this->client->getResponse();
+ $response = $this->client->getResponse();
- $this->assertEquals(200, $response->getStatusCode());
- $this->assertEquals('UTF-8', $response->getCharset());
+ $this->assertEquals(200, $response->getStatusCode());
+ $this->assertEquals('UTF-8', $response->getCharset());
- $datas = (array) json_decode($response->getContent());
+ $datas = (array) json_decode($response->getContent());
- $this->assertArrayHasKey('success', $datas);
- $this->assertArrayHasKey('message', $datas);
+ $this->assertArrayHasKey('success', $datas);
+ $this->assertArrayHasKey('message', $datas);
- $this->assertTrue($datas['success']);
+ $this->assertTrue($datas['success']);
- $repository = self::$core->getEntityManager()->getRepository('Entities\UsrList');
+ $repository = self::$core->getEntityManager()->getRepository('Entities\UsrList');
- $list = $repository->find($list->getId());
+ $list = $repository->find($list->getId());
- $this->assertEquals(2, $list->getOwners()->count());
+ $this->assertEquals(2, $list->getOwners()->count());
- $route = '/lists/list/' . $list->getId() . '/unshare/' . self::$user_alt1->get_id() . '/';
+ $route = '/lists/list/' . $list->getId() . '/unshare/' . self::$user_alt1->get_id() . '/';
- $this->client->request('POST', $route);
+ $this->client->request('POST', $route);
- $response = $this->client->getResponse();
+ $response = $this->client->getResponse();
- $this->assertEquals(200, $response->getStatusCode());
- $this->assertEquals('UTF-8', $response->getCharset());
+ $this->assertEquals(200, $response->getStatusCode());
+ $this->assertEquals('UTF-8', $response->getCharset());
- $datas = (array) json_decode($response->getContent());
+ $datas = (array) json_decode($response->getContent());
- $this->assertTrue($datas['success']);
- }
+ $this->assertTrue($datas['success']);
+ }
- protected function checkOwner($owner)
- {
- $this->assertInstanceOf('stdClass', $owner);
- $this->assertObjectHasAttribute('usr_id', $owner);
- $this->assertObjectHasAttribute('display_name', $owner);
- $this->assertObjectHasAttribute('position', $owner);
- $this->assertObjectHasAttribute('job', $owner);
- $this->assertObjectHasAttribute('company', $owner);
- $this->assertObjectHasAttribute('email', $owner);
- $this->assertObjectHasAttribute('role', $owner);
- $this->assertTrue(ctype_digit($owner->role));
- }
-
- protected function checkUser($user)
- {
- $this->assertInstanceOf('stdClass', $user);
- $this->assertObjectHasAttribute('usr_id', $user);
- $this->assertObjectHasAttribute('display_name', $user);
- $this->assertObjectHasAttribute('position', $user);
- $this->assertObjectHasAttribute('job', $user);
- $this->assertObjectHasAttribute('company', $user);
- $this->assertObjectHasAttribute('email', $user);
- }
+ protected function checkOwner($owner)
+ {
+ $this->assertInstanceOf('stdClass', $owner);
+ $this->assertObjectHasAttribute('usr_id', $owner);
+ $this->assertObjectHasAttribute('display_name', $owner);
+ $this->assertObjectHasAttribute('position', $owner);
+ $this->assertObjectHasAttribute('job', $owner);
+ $this->assertObjectHasAttribute('company', $owner);
+ $this->assertObjectHasAttribute('email', $owner);
+ $this->assertObjectHasAttribute('role', $owner);
+ $this->assertTrue(ctype_digit($owner->role));
+ }
+ protected function checkUser($user)
+ {
+ $this->assertInstanceOf('stdClass', $user);
+ $this->assertObjectHasAttribute('usr_id', $user);
+ $this->assertObjectHasAttribute('display_name', $user);
+ $this->assertObjectHasAttribute('position', $user);
+ $this->assertObjectHasAttribute('job', $user);
+ $this->assertObjectHasAttribute('company', $user);
+ $this->assertObjectHasAttribute('email', $user);
+ }
}
diff --git a/tests/Alchemy/Phrasea/Controller/Prod/WorkZoneTest.php b/tests/Alchemy/Phrasea/Controller/Prod/WorkZoneTest.php
index bfa9c4e485..607720124c 100644
--- a/tests/Alchemy/Phrasea/Controller/Prod/WorkZoneTest.php
+++ b/tests/Alchemy/Phrasea/Controller/Prod/WorkZoneTest.php
@@ -1,213 +1,196 @@
client = $this->createClient();
+ $this->purgeDatabase();
+ }
- public function setUp()
- {
- parent::setUp();
- $this->client = $this->createClient();
- $this->purgeDatabase();
- }
+ public function createApplication()
+ {
+ return require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Prod.php';
+ }
- public function createApplication()
- {
- return require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Prod.php';
- }
+ public function testRootGet()
+ {
- public function testRootGet()
- {
+ $this->insertOneWZ();
- $this->insertOneWZ();
+ $route = "/WorkZone/";
- $route = "/WorkZone/";
+ $this->client->request('GET', $route);
- $this->client->request('GET', $route);
+ $response = $this->client->getResponse();
- $response = $this->client->getResponse();
+ $this->assertEquals(200, $response->getStatusCode());
+ }
- $this->assertEquals(200, $response->getStatusCode());
- }
+ public function testAttachStoryToWZ()
+ {
+ $story = self::$story_1;
+ /* @var $story \Record_Adapter */
+ $route = sprintf("/WorkZone/attachStories/");
- public function testAttachStoryToWZ()
- {
- $story = self::$story_1;
- /* @var $story \Record_Adapter */
- $route = sprintf("/WorkZone/attachStories/");
+ $this->client->request('POST', $route);
+ $response = $this->client->getResponse();
- $this->client->request('POST', $route);
- $response = $this->client->getResponse();
+ $this->assertEquals(400, $response->getStatusCode());
+ $this->assertFalse($response->isOk());
- $this->assertEquals(400, $response->getStatusCode());
- $this->assertFalse($response->isOk());
+ $this->client->request('POST', $route, array('stories' => array($story->get_serialize_key())));
+ $response = $this->client->getResponse();
- $this->client->request('POST', $route, array('stories' => array($story->get_serialize_key())));
- $response = $this->client->getResponse();
+ $this->assertEquals(302, $response->getStatusCode());
- $this->assertEquals(302, $response->getStatusCode());
-
- $em = self::$core->getEntityManager();
- /* @var $em \Doctrine\ORM\EntityManager */
- $query = $em->createQuery(
+ $em = self::$core->getEntityManager();
+ /* @var $em \Doctrine\ORM\EntityManager */
+ $query = $em->createQuery(
'SELECT COUNT(w.id) FROM \Entities\StoryWZ w'
- );
+ );
- $count = $query->getSingleScalarResult();
+ $count = $query->getSingleScalarResult();
- $this->assertEquals(1, $count);
+ $this->assertEquals(1, $count);
- $story2 = self::$story_2;
+ $story2 = self::$story_2;
- $stories = array($story->get_serialize_key(), $story2->get_serialize_key());
+ $stories = array($story->get_serialize_key(), $story2->get_serialize_key());
- $this->client->request('POST', $route, array('stories' => $stories));
- $response = $this->client->getResponse();
+ $this->client->request('POST', $route, array('stories' => $stories));
+ $response = $this->client->getResponse();
- $this->assertEquals(302, $response->getStatusCode());
+ $this->assertEquals(302, $response->getStatusCode());
- $em = self::$core->getEntityManager();
- /* @var $em \Doctrine\ORM\EntityManager */
- $query = $em->createQuery(
+ $em = self::$core->getEntityManager();
+ /* @var $em \Doctrine\ORM\EntityManager */
+ $query = $em->createQuery(
'SELECT COUNT(w.id) FROM \Entities\StoryWZ w'
- );
+ );
- $count = $query->getSingleScalarResult();
+ $count = $query->getSingleScalarResult();
- $this->assertEquals(2, $count);
+ $this->assertEquals(2, $count);
- $query = $em->createQuery(
+ $query = $em->createQuery(
'SELECT w FROM \Entities\StoryWZ w'
- );
+ );
- $storyWZ = $query->getResult();
- $em->remove(array_shift($storyWZ));
+ $storyWZ = $query->getResult();
+ $em->remove(array_shift($storyWZ));
- $em->flush();
+ $em->flush();
- //attach JSON
- $this->client->request('POST', $route, array('stories' => $story->get_serialize_key()), array(), array(
- "HTTP_ACCEPT" => "application/json")
- );
+ //attach JSON
+ $this->client->request('POST', $route, array('stories' => $story->get_serialize_key()), array(), array(
+ "HTTP_ACCEPT" => "application/json")
+ );
- $response = $this->client->getResponse();
+ $response = $this->client->getResponse();
- $this->assertEquals(200, $response->getStatusCode());
+ $this->assertEquals(200, $response->getStatusCode());
- //test already attached
- $this->client->request('POST', $route, array('stories' => $story->get_serialize_key()), array(), array(
- "HTTP_ACCEPT" => "application/json")
- );
+ //test already attached
+ $this->client->request('POST', $route, array('stories' => $story->get_serialize_key()), array(), array(
+ "HTTP_ACCEPT" => "application/json")
+ );
- $response = $this->client->getResponse();
+ $response = $this->client->getResponse();
- $this->assertEquals(200, $response->getStatusCode());
- }
+ $this->assertEquals(200, $response->getStatusCode());
+ }
- public function testDetachStoryFromWZ()
- {
- $story = self::$story_1;
+ public function testDetachStoryFromWZ()
+ {
+ $story = self::$story_1;
- $route = sprintf("/WorkZone/detachStory/%s/%s/", $story->get_sbas_id(), $story->get_record_id());
- //story not yet Attched
+ $route = sprintf("/WorkZone/detachStory/%s/%s/", $story->get_sbas_id(), $story->get_record_id());
+ //story not yet Attched
- $this->client->request('POST', $route);
- $response = $this->client->getResponse();
+ $this->client->request('POST', $route);
+ $response = $this->client->getResponse();
- $this->assertEquals(404, $response->getStatusCode());
- $this->assertFalse($response->isOk());
+ $this->assertEquals(404, $response->getStatusCode());
+ $this->assertFalse($response->isOk());
- //attach
- $attachRoute = sprintf("/WorkZone/attachStories/");
- $this->client->request('POST', $attachRoute, array('stories' => array($story->get_serialize_key())));
+ //attach
+ $attachRoute = sprintf("/WorkZone/attachStories/");
+ $this->client->request('POST', $attachRoute, array('stories' => array($story->get_serialize_key())));
- $query = self::$core->getEntityManager()->createQuery(
+ $query = self::$core->getEntityManager()->createQuery(
'SELECT COUNT(w.id) FROM \Entities\StoryWZ w'
- );
+ );
- $count = $query->getSingleScalarResult();
+ $count = $query->getSingleScalarResult();
- $this->assertEquals(1, $count);
+ $this->assertEquals(1, $count);
- //detach
- $this->client->request('POST', $route);
- $response = $this->client->getResponse();
- $this->assertEquals(302, $response->getStatusCode());
+ //detach
+ $this->client->request('POST', $route);
+ $response = $this->client->getResponse();
+ $this->assertEquals(302, $response->getStatusCode());
- $query = self::$core->getEntityManager()->createQuery(
+ $query = self::$core->getEntityManager()->createQuery(
'SELECT COUNT(w.id) FROM \Entities\StoryWZ w'
- );
+ );
- $count = $query->getSingleScalarResult();
+ $count = $query->getSingleScalarResult();
- $this->assertEquals(0, $count);
+ $this->assertEquals(0, $count);
- //attach
- $this->client->request('POST', $attachRoute, array('stories' => array($story->get_serialize_key())));
+ //attach
+ $this->client->request('POST', $attachRoute, array('stories' => array($story->get_serialize_key())));
- //detach JSON
- $this->client->request('POST', $route, array(), array(), array(
- "HTTP_ACCEPT" => "application/json")
- );
- $response = $this->client->getResponse();
- $this->assertEquals(200, $response->getStatusCode());
- }
+ //detach JSON
+ $this->client->request('POST', $route, array(), array(), array(
+ "HTTP_ACCEPT" => "application/json")
+ );
+ $response = $this->client->getResponse();
+ $this->assertEquals(200, $response->getStatusCode());
+ }
- public function testBrowse()
- {
- $this->client->request("GET", "/WorkZone/Browse/");
- $response = $this->client->getResponse();
- $this->assertTrue($response->isOk());
- }
+ public function testBrowse()
+ {
+ $this->client->request("GET", "/WorkZone/Browse/");
+ $response = $this->client->getResponse();
+ $this->assertTrue($response->isOk());
+ }
- public function testBrowseSearch()
- {
- $this->client->request("GET", "/WorkZone/Browse/Search/");
- $response = $this->client->getResponse();
- $this->assertTrue($response->isOk());
- }
+ public function testBrowseSearch()
+ {
+ $this->client->request("GET", "/WorkZone/Browse/Search/");
+ $response = $this->client->getResponse();
+ $this->assertTrue($response->isOk());
+ }
- public function testBrowseBasket()
- {
- $basket = $this->insertOneBasket();
- $this->client->request("GET", "/WorkZone/Browse/Basket/" . $basket->getId() . "/");
- $response = $this->client->getResponse();
- $this->assertTrue($response->isOk());
- }
+ public function testBrowseBasket()
+ {
+ $basket = $this->insertOneBasket();
+ $this->client->request("GET", "/WorkZone/Browse/Basket/" . $basket->getId() . "/");
+ $response = $this->client->getResponse();
+ $this->assertTrue($response->isOk());
+ }
- public function testDetachStoryFromWZNotFound()
- {
- $story = self::$story_1;
-
- $route = sprintf("/WorkZone/detachStory/%s/%s/", $story->get_sbas_id(), 'unknow');
- //story not yet Attched
- }
+ public function testDetachStoryFromWZNotFound()
+ {
+ $story = self::$story_1;
+ $route = sprintf("/WorkZone/detachStory/%s/%s/", $story->get_sbas_id(), 'unknow');
+ //story not yet Attched
+ }
}
diff --git a/tests/Alchemy/Phrasea/Controller/Root/RSSFeedTest.php b/tests/Alchemy/Phrasea/Controller/Root/RSSFeedTest.php
index 1aa90b9c51..635e66a9d3 100644
--- a/tests/Alchemy/Phrasea/Controller/Root/RSSFeedTest.php
+++ b/tests/Alchemy/Phrasea/Controller/Root/RSSFeedTest.php
@@ -11,879 +11,825 @@ use Symfony\Component\DomCrawler\Crawler;
class ControllerRssFeedTest extends \PhraseanetWebTestCaseAbstract
{
-
- /**
- *
- * @var Feed_Adapter
- */
- public static $feed;
-
- /**
- *
- * @var Feed_Adapter_Entry
- */
- public static $entry;
- public static $publisher;
-
- /**
- *
- * @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()
- {
- parent::setUp();
- $this->client = $this->createClient();
- self::$feed = Feed_Adapter::create(appbox::get_instance(\bootstrap::getCore()), self::$user, 'title', 'subtitle');
- self::$publisher = Feed_Publisher_Adapter::getPublisher(appbox::get_instance(\bootstrap::getCore()), self::$feed, self::$user);
- self::$entry = Feed_Entry_Adapter::create(appbox::get_instance(\bootstrap::getCore()), self::$feed, self::$publisher, 'title_entry', 'subtitle', 'hello', "test@mail.com");
- Feed_Entry_Item::create(appbox::get_instance(\bootstrap::getCore()), self::$entry, self::$record_1);
- Feed_Entry_Item::create(appbox::get_instance(\bootstrap::getCore()), self::$entry, self::$record_2);
- self::$feed->set_public(true);
- }
-
- public function tearDown()
- {
- if (self::$publisher instanceof Feed_Publisher_Adapter)
- {
- self::$publisher->delete();
- }
- if (self::$entry instanceof Feed_Entry_Adapter)
- {
- self::$entry->delete();
- }
- if (self::$feed instanceof Feed_Adapter)
- {
- self::$feed->delete();
- }
- parent::tearDown();
- }
-
- public static function setUpBeforeClass()
- {
- parent::setUpBeforeClass();
-
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $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(__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(__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__ . '/../../../../../lib/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();
- $dom_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(\bootstrap::getCore());
- $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(\bootstrap::getCore());
- $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(\bootstrap::getCore());
- $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(\bootstrap::getCore()));
- $feed = array_shift($feeds->get_feeds());
-
- $crawler = $this->client->request("GET", "/feeds/feed/" . $feed->get_id() . "/rss/");
- $this->assertEquals("application/rss+xml", $this->client->getResponse()->headers->get("content-type"));
- $xml = $this->client->getResponse()->getContent();
-
- $this->verifyXML($xml);
- $this->verifyRSS($feed, $xml);
-
- $crawler = $this->client->request("GET", "/feeds/feed/" . $feed->get_id() . "/atom/");
- $this->assertEquals("application/atom+xml", $this->client->getResponse()->headers->get("content-type"));
- $xml = $this->client->getResponse()->getContent();
- $this->verifyXML($xml);
- $this->verifyATOM($feed, $xml);
- }
-
- public function testCooliris()
- {
- $crawler = $this->client->request("GET", "/feeds/cooliris/");
- $this->assertTrue($this->client->getResponse()->isOk());
- $this->assertEquals("application/rss+xml", $this->client->getResponse()->headers->get("content-type"));
- $xml = $this->client->getResponse()->getContent();
- $this->verifyXML($xml);
- }
-
- public function testAggregatedRss()
- {
- $feeds = Feed_Collection::load_public_feeds(appbox::get_instance(\bootstrap::getCore()));
- $all_feeds = $feeds->get_feeds();
- foreach ($all_feeds as $feed)
- {
- $this->assertTrue($feed->is_public());
- }
- $crawler = $this->client->request("GET", "/feeds/aggregated/rss/");
- $this->assertTrue($this->client->getResponse()->isOk());
- $this->assertEquals("application/rss+xml", $this->client->getResponse()->headers->get("content-type"));
- $xml = $this->client->getResponse()->getContent();
- $this->verifyXML($xml);
- }
-
- public function testAggregatedAtom()
- {
- $feeds = Feed_Collection::load_public_feeds(appbox::get_instance(\bootstrap::getCore()));
- $all_feeds = $feeds->get_feeds();
- foreach ($all_feeds as $feed)
- {
- $this->assertTrue($feed->is_public());
- }
- $crawler = $this->client->request("GET", "/feeds/aggregated/atom/");
- $this->assertTrue($this->client->getResponse()->isOk());
- $this->assertEquals("application/atom+xml", $this->client->getResponse()->headers->get("content-type"));
- $xml = $this->client->getResponse()->getContent();
- $this->verifyXML($xml);
- }
-
- public function testUnknowFeedId()
- {
- $crawler = $this->client->request("GET", "/feeds/feed/0/");
- $this->assertFalse($this->client->getResponse()->isOk());
- $this->assertEquals(404, $this->client->getResponse()->getStatusCode());
- $crawler = $this->client->request("GET", "/feeds/feed/titi/");
- $this->assertFalse($this->client->getResponse()->isOk());
- $this->assertEquals(404, $this->client->getResponse()->getStatusCode());
- }
-
- public function testGetFeedId()
- {
- $feeds = Feed_Collection::load_public_feeds(appbox::get_instance(\bootstrap::getCore()));
- $all_feeds = $feeds->get_feeds();
- $feed = array_shift($all_feeds);
-
- $crawler = $this->client->request("GET", "/feeds/feed/" . $feed->get_id() . "/rss/");
- $this->assertTrue($this->client->getResponse()->isOk());
- $xml = $this->client->getResponse()->getContent();
- $this->verifyXML($xml);
- $this->verifyRSS($feed, $xml);
-
- $crawler = $this->client->request("GET", "/feeds/feed/" . $feed->get_id() . "/atom/");
- $this->assertTrue($this->client->getResponse()->isOk());
- $xml = $this->client->getResponse()->getContent();
- $this->verifyATOM($feed, $xml);
- }
-
- public function testPrivateFeedAccess()
- {
- $private_feed = Feed_Adapter::create(appbox::get_instance(\bootstrap::getCore()), self::$user, 'title', 'subtitle');
- $private_feed->set_public(false);
- $this->client->request("GET", "/feeds/feed/" . $private_feed->get_id() . "/rss/");
- $this->assertFalse($this->client->getResponse()->isOk());
- $this->assertEquals(403, $this->client->getResponse()->getStatusCode());
- $private_feed->delete();
- }
-
- public function verifyXML($xml)
- {
/**
- * XML is not verified due to Validator Service bug
+ *
+ * @var Feed_Adapter
*/
+ public static $feed;
- return;
+ /**
+ *
+ * @var Feed_Adapter_Entry
+ */
+ public static $entry;
+ public static $publisher;
- try
+ /**
+ *
+ * @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()
{
- $validator = new W3CFeedRawValidator($xml);
- $response = $validator->validate();
-
- $this->assertTrue($response->isValid(), $xml . "\n" . $response);
+ parent::setUp();
+ $this->client = $this->createClient();
+ self::$feed = Feed_Adapter::create(appbox::get_instance(\bootstrap::getCore()), self::$user, 'title', 'subtitle');
+ self::$publisher = Feed_Publisher_Adapter::getPublisher(appbox::get_instance(\bootstrap::getCore()), self::$feed, self::$user);
+ self::$entry = Feed_Entry_Adapter::create(appbox::get_instance(\bootstrap::getCore()), self::$feed, self::$publisher, 'title_entry', 'subtitle', 'hello', "test@mail.com");
+ Feed_Entry_Item::create(appbox::get_instance(\bootstrap::getCore()), self::$entry, self::$record_1);
+ Feed_Entry_Item::create(appbox::get_instance(\bootstrap::getCore()), self::$entry, self::$record_2);
+ self::$feed->set_public(true);
}
- catch (W3CFeedValidatorException $e)
+
+ public function tearDown()
{
- print "\nCould not use W3C FEED VALIDATOR API : " . $e->getMessage() . "\n";
- }
- }
-
- function verifyRSS(Feed_Adapter $feed, $xml_string)
- {
- $dom_doc = new DOMDocument();
- $dom_doc->loadXML($xml_string);
-
- $xpath = new DOMXPath($dom_doc);
- $xpath->registerNamespace("media", "http://search.yahoo.com/mrss/");
- $xpath->registerNamespace("atom", "http://www.w3.org/2005/Atom");
- $xpath->registerNamespace("dc", "http://purl.org/dc/elements/1.1/");
- $this->checkRSSRootNode($xpath, $feed);
- $this->checkRSSEntryNode($xpath, $feed);
- }
-
- function checkRSSRootNode(DOMXPath $xpath, Feed_Adapter $feed)
- {
- $channel = $xpath->query("/rss/channel");
- foreach ($channel->item(0)->childNodes as $child)
- {
- if ($child->nodeType !== XML_TEXT_NODE)
- {
- switch ($child->nodeName)
- {
- case 'title':
- $this->assertEquals($feed->get_title(), $child->nodeValue);
- break;
- case 'dc:title':
- $this->assertEquals($feed->get_title(), $child->nodeValue);
- break;
- case 'description':
- $this->assertEquals($feed->get_subtitle(), $child->nodeValue);
- break;
- case 'link':
- $this->assertEquals($feed->get_homepage_link(registry::get_instance(), Feed_Adapter::FORMAT_RSS, 1)->get_href(), $child->nodeValue);
- break;
- case 'pubDate':
- $this->assertTrue(new DateTime() >= new DateTime($child->nodeValue));
- break;
- case 'generator':
- $this->assertEquals("Phraseanet", $child->nodeValue);
- break;
- case 'docs':
- $this->assertEquals("http://blogs.law.harvard.edu/tech/rss", $child->nodeValue);
- break;
- case 'atom:link':
- foreach ($child->attributes as $attribute)
- {
- if ($attribute->name == "href")
- {
- $this->assertEquals($feed->get_homepage_link(registry::get_instance(), Feed_Adapter::FORMAT_RSS, 1)->get_href(), $attribute->value);
- break;
- }
- }
- break;
+ if (self::$publisher instanceof Feed_Publisher_Adapter) {
+ self::$publisher->delete();
}
- }
+ if (self::$entry instanceof Feed_Entry_Adapter) {
+ self::$entry->delete();
+ }
+ if (self::$feed instanceof Feed_Adapter) {
+ self::$feed->delete();
+ }
+ parent::tearDown();
}
- }
- function checkRSSEntryNode(DOMXPath $xpath, Feed_Adapter $feed)
- {
- $list_entries = $xpath->query("/rss/channel/item");
- $count = 0;
- $offset_start = 0;
- $n_entries = 20;
- $collection = $feed->get_entries($offset_start, $n_entries);
- $entries = $collection->get_entries();
-
- foreach ($list_entries as $node)
+ public static function setUpBeforeClass()
{
- if (sizeof($entries) == 0)
- {
- $offset_start = ($offset_start++) * $n_entries;
+ parent::setUpBeforeClass();
+
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $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(__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(__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__ . '/../../../../../lib/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();
+ $dom_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');
+ }
+
+ public function testPublicFeed()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $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);
+ }
+
+ public function testUserFeedAggregated()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $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);
+ }
+
+ public function testUserFeed()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $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(\bootstrap::getCore()));
+ $feed = array_shift($feeds->get_feeds());
+
+ $crawler = $this->client->request("GET", "/feeds/feed/" . $feed->get_id() . "/rss/");
+ $this->assertEquals("application/rss+xml", $this->client->getResponse()->headers->get("content-type"));
+ $xml = $this->client->getResponse()->getContent();
+
+ $this->verifyXML($xml);
+ $this->verifyRSS($feed, $xml);
+
+ $crawler = $this->client->request("GET", "/feeds/feed/" . $feed->get_id() . "/atom/");
+ $this->assertEquals("application/atom+xml", $this->client->getResponse()->headers->get("content-type"));
+ $xml = $this->client->getResponse()->getContent();
+ $this->verifyXML($xml);
+ $this->verifyATOM($feed, $xml);
+ }
+
+ public function testCooliris()
+ {
+ $crawler = $this->client->request("GET", "/feeds/cooliris/");
+ $this->assertTrue($this->client->getResponse()->isOk());
+ $this->assertEquals("application/rss+xml", $this->client->getResponse()->headers->get("content-type"));
+ $xml = $this->client->getResponse()->getContent();
+ $this->verifyXML($xml);
+ }
+
+ public function testAggregatedRss()
+ {
+ $feeds = Feed_Collection::load_public_feeds(appbox::get_instance(\bootstrap::getCore()));
+ $all_feeds = $feeds->get_feeds();
+ foreach ($all_feeds as $feed) {
+ $this->assertTrue($feed->is_public());
+ }
+ $crawler = $this->client->request("GET", "/feeds/aggregated/rss/");
+ $this->assertTrue($this->client->getResponse()->isOk());
+ $this->assertEquals("application/rss+xml", $this->client->getResponse()->headers->get("content-type"));
+ $xml = $this->client->getResponse()->getContent();
+ $this->verifyXML($xml);
+ }
+
+ public function testAggregatedAtom()
+ {
+ $feeds = Feed_Collection::load_public_feeds(appbox::get_instance(\bootstrap::getCore()));
+ $all_feeds = $feeds->get_feeds();
+ foreach ($all_feeds as $feed) {
+ $this->assertTrue($feed->is_public());
+ }
+ $crawler = $this->client->request("GET", "/feeds/aggregated/atom/");
+ $this->assertTrue($this->client->getResponse()->isOk());
+ $this->assertEquals("application/atom+xml", $this->client->getResponse()->headers->get("content-type"));
+ $xml = $this->client->getResponse()->getContent();
+ $this->verifyXML($xml);
+ }
+
+ public function testUnknowFeedId()
+ {
+ $crawler = $this->client->request("GET", "/feeds/feed/0/");
+ $this->assertFalse($this->client->getResponse()->isOk());
+ $this->assertEquals(404, $this->client->getResponse()->getStatusCode());
+ $crawler = $this->client->request("GET", "/feeds/feed/titi/");
+ $this->assertFalse($this->client->getResponse()->isOk());
+ $this->assertEquals(404, $this->client->getResponse()->getStatusCode());
+ }
+
+ public function testGetFeedId()
+ {
+ $feeds = Feed_Collection::load_public_feeds(appbox::get_instance(\bootstrap::getCore()));
+ $all_feeds = $feeds->get_feeds();
+ $feed = array_shift($all_feeds);
+
+ $crawler = $this->client->request("GET", "/feeds/feed/" . $feed->get_id() . "/rss/");
+ $this->assertTrue($this->client->getResponse()->isOk());
+ $xml = $this->client->getResponse()->getContent();
+ $this->verifyXML($xml);
+ $this->verifyRSS($feed, $xml);
+
+ $crawler = $this->client->request("GET", "/feeds/feed/" . $feed->get_id() . "/atom/");
+ $this->assertTrue($this->client->getResponse()->isOk());
+ $xml = $this->client->getResponse()->getContent();
+ $this->verifyATOM($feed, $xml);
+ }
+
+ public function testPrivateFeedAccess()
+ {
+ $private_feed = Feed_Adapter::create(appbox::get_instance(\bootstrap::getCore()), self::$user, 'title', 'subtitle');
+ $private_feed->set_public(false);
+ $this->client->request("GET", "/feeds/feed/" . $private_feed->get_id() . "/rss/");
+ $this->assertFalse($this->client->getResponse()->isOk());
+ $this->assertEquals(403, $this->client->getResponse()->getStatusCode());
+ $private_feed->delete();
+ }
+
+ public function verifyXML($xml)
+ {
+ /**
+ * XML is not verified due to Validator Service bug
+ */
+ return;
+
+ try {
+ $validator = new W3CFeedRawValidator($xml);
+ $response = $validator->validate();
+
+ $this->assertTrue($response->isValid(), $xml . "\n" . $response);
+ } catch (W3CFeedValidatorException $e) {
+ print "\nCould not use W3C FEED VALIDATOR API : " . $e->getMessage() . "\n";
+ }
+ }
+
+ function verifyRSS(Feed_Adapter $feed, $xml_string)
+ {
+ $dom_doc = new DOMDocument();
+ $dom_doc->loadXML($xml_string);
+
+ $xpath = new DOMXPath($dom_doc);
+ $xpath->registerNamespace("media", "http://search.yahoo.com/mrss/");
+ $xpath->registerNamespace("atom", "http://www.w3.org/2005/Atom");
+ $xpath->registerNamespace("dc", "http://purl.org/dc/elements/1.1/");
+ $this->checkRSSRootNode($xpath, $feed);
+ $this->checkRSSEntryNode($xpath, $feed);
+ }
+
+ function checkRSSRootNode(DOMXPath $xpath, Feed_Adapter $feed)
+ {
+ $channel = $xpath->query("/rss/channel");
+ foreach ($channel->item(0)->childNodes as $child) {
+ if ($child->nodeType !== XML_TEXT_NODE) {
+ switch ($child->nodeName) {
+ case 'title':
+ $this->assertEquals($feed->get_title(), $child->nodeValue);
+ break;
+ case 'dc:title':
+ $this->assertEquals($feed->get_title(), $child->nodeValue);
+ break;
+ case 'description':
+ $this->assertEquals($feed->get_subtitle(), $child->nodeValue);
+ break;
+ case 'link':
+ $this->assertEquals($feed->get_homepage_link(registry::get_instance(), Feed_Adapter::FORMAT_RSS, 1)->get_href(), $child->nodeValue);
+ break;
+ case 'pubDate':
+ $this->assertTrue(new DateTime() >= new DateTime($child->nodeValue));
+ break;
+ case 'generator':
+ $this->assertEquals("Phraseanet", $child->nodeValue);
+ break;
+ case 'docs':
+ $this->assertEquals("http://blogs.law.harvard.edu/tech/rss", $child->nodeValue);
+ break;
+ case 'atom:link':
+ foreach ($child->attributes as $attribute) {
+ if ($attribute->name == "href") {
+ $this->assertEquals($feed->get_homepage_link(registry::get_instance(), Feed_Adapter::FORMAT_RSS, 1)->get_href(), $attribute->value);
+ break;
+ }
+ }
+ break;
+ }
+ }
+ }
+ }
+
+ function checkRSSEntryNode(DOMXPath $xpath, Feed_Adapter $feed)
+ {
+ $list_entries = $xpath->query("/rss/channel/item");
+ $count = 0;
+ $offset_start = 0;
+ $n_entries = 20;
$collection = $feed->get_entries($offset_start, $n_entries);
$entries = $collection->get_entries();
- if (sizeof($entries) == 0) //no more
- break;
- }
- $feed_entry = array_shift($entries);
- switch ($node->nodeName)
- {
- case 'title':
- $this->assertEquals($feed_entry->get_title(), $node->nodeValue);
- break;
- case 'description':
- $this->assertEquals($feed_entry->get_subtitle(), $node->nodeValue);
- break;
- case 'author':
- $author = sprintf(
- '%s (%s)'
- , $feed_entry->get_author_email()
- , $feed_entry->get_author_name()
- );
- $this->assertEquals($author, $node->nodeValue);
- break;
- case 'pubDate':
- $this->assertEquals($feed_entry->get_created_on()->format(DATE_RFC2822), $node->nodeValue);
- break;
- case 'guid':
- $this->assertEquals($feed_entry->get_link()->get_href(), $node->nodeValue);
- break;
- case 'link':
- $this->assertEquals($feed_entry->get_link()->get_href(), $node->nodeValue);
- break;
- }
- $count++;
- $this->checkRSSEntryItemsNode($xpath, $feed_entry, $count);
- }
- $this->assertEquals($feed->get_count_total_entries(), $count);
- }
- function checkRSSEntryItemsNode(DOMXPath $xpath, Feed_Entry_Adapter $entry, $count)
- {
- $content = $entry->get_content();
- $available_medium = array('image', 'audio', 'video');
- array_walk($content, $this->removeBadItems($content, $available_medium));
- $media_group = $xpath->query("/rss/channel/item[" . $count . "]/media:group");
- $this->assertEquals(sizeof($content), $media_group->length);
-
- foreach ($media_group as $media)
- {
- $entry_item = array_shift($content);
- $this->verifyMediaItem($entry_item, $media);
- }
- }
-
- public function verifyMediaItem(Feed_Entry_Item $item, DOMNode $node)
- {
- foreach ($node->childNodes as $node)
- {
- if ($node->nodeType !== XML_TEXT_NODE)
- {
- switch ($node->nodeName)
- {
- case 'media:content' :
- $this->checkMediaContentAttributes($item, $node);
- break;
- case 'media:thumbnail':
- default :
- $this->checkOptionnalMediaGroupNode($node, $item);
- break;
- }
- }
- }
- }
-
- public function parseAttributes(DOMNode $node)
- {
- $current_attributes = array();
- foreach ($node->attributes as $attribute)
- {
- $current_attributes[$attribute->name] = $attribute->value;
- }
-
- return $current_attributes;
- }
-
- public function checkMediaContentAttributes(Feed_Entry_Item $entry_item, DOMNode $node)
- {
- $current_attributes = $this->parseAttributes($node);
- $is_thumbnail = false;
- $record = $entry_item->get_record();
-
- if (substr($current_attributes["url"], 0 - strlen("/preview/")) == "/preview/")
- {
- $ressource = $record->get_subdef('preview');
- }
- else
- {
- $ressource = $record->get_thumbnail();
- $is_thumbnail = true;
- }
-
- $permalink = $ressource->get_permalink();
-
- foreach ($current_attributes as $attribute => $value)
- {
- switch ($attribute)
- {
- case "url":
- $this->assertEquals($permalink->get_url(), $value);
- break;
- case "fileSize":
- $this->assertEquals($ressource->get_size(), $value);
- break;
- case "type":
- $this->assertEquals($ressource->get_mime(), $value);
- break;
- case "medium":
- $this->assertEquals(strtolower($record->get_type()), $value);
- break;
- case "isDefault":
- !$is_thumbnail ? $this->assertEquals("true", $value) : $this->assertEquals("false", $value);
- break;
- case "expression":
- $this->assertEquals("full", $value);
- break;
- case "bitrate":
- $this->assertEquals($value);
- break;
- case "height":
- $this->assertEquals($ressource->get_height(), $value);
- break;
- case "width":
- $this->assertEquals($ressource->get_width(), $value);
- break;
- case "duration" :
- $this->assertEquals($record->get_duration(), $value);
- break;
- case "framerate":
- case "samplingrate":
- case "channels":
- case "lang":
- break;
- default:
- $this->fail($attribute . " is not valid");
- break;
- }
- }
- }
-
- public function checkOptionnalMediaGroupNode(DOMNode $node, Feed_Entry_Item $entry_item)
- {
- $fields = array(
- 'title' => array(
- 'dc_field' => databox_Field_DCESAbstract::Title,
- 'media_field' => array(
- 'name' => 'media:title',
- 'attributes' => array(
- 'type' => 'plain'
- )
- ),
- 'separator' => ' '
- )
- , 'description' => array(
- 'dc_field' => databox_Field_DCESAbstract::Description,
- 'media_field' => array(
- 'name' => 'media:description',
- 'attributes' => array()
- ),
- 'separator' => ' '
- )
- , 'contributor' => array(
- 'dc_field' => databox_Field_DCESAbstract::Contributor,
- 'media_field' => array(
- 'name' => 'media:credit',
- 'attributes' => array(
- 'role' => 'contributor',
- 'scheme' => 'urn:ebu'
- )
- ),
- 'separator' => ' '
- )
- , 'director' => array(
- 'dc_field' => databox_Field_DCESAbstract::Creator,
- 'media_field' => array(
- 'name' => 'media:credit',
- 'attributes' => array(
- 'role' => 'creator',
- 'scheme' => 'urn:ebu'
- )
- ),
- 'separator' => ' '
- )
- , 'publisher' => array(
- 'dc_field' => databox_Field_DCESAbstract::Publisher,
- 'media_field' => array(
- 'name' => 'media:credit',
- 'attributes' => array(
- 'role' => 'publisher',
- 'scheme' => 'urn:ebu'
- )
- ),
- 'separator' => ' '
- )
- , 'rights' => array(
- 'dc_field' => databox_Field_DCESAbstract::Rights,
- 'media_field' => array(
- 'name' => 'media:copyright',
- 'attributes' => array()
- ),
- 'separator' => ' '
- )
- , 'keywords' => array(
- 'dc_field' => databox_Field_DCESAbstract::Subject,
- 'media_field' => array(
- 'name' => 'media:keywords',
- 'attributes' => array()
- ),
- 'separator' => ', '
- )
- );
-
-
- foreach ($fields as $key_field => $field)
- {
- if ($field["media_field"]["name"] == $node->nodeName)
- {
- if ($p4field = $entry_item->get_record()->get_caption()->get_dc_field($field["dc_field"]))
- {
- $this->assertEquals($p4field->get_serialized_values($field["separator"]), $node->nodeValue
- , sprintf('Asserting good value for DC %s', $field["dc_field"]));
- if (sizeof($field["media_field"]["attributes"]) > 0)
- {
- 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']);
+ foreach ($list_entries as $node) {
+ if (sizeof($entries) == 0) {
+ $offset_start = ($offset_start ++ ) * $n_entries;
+ $collection = $feed->get_entries($offset_start, $n_entries);
+ $entries = $collection->get_entries();
+ if (sizeof($entries) == 0) //no more
+ break;
}
- }
+ $feed_entry = array_shift($entries);
+ switch ($node->nodeName) {
+ case 'title':
+ $this->assertEquals($feed_entry->get_title(), $node->nodeValue);
+ break;
+ case 'description':
+ $this->assertEquals($feed_entry->get_subtitle(), $node->nodeValue);
+ break;
+ case 'author':
+ $author = sprintf(
+ '%s (%s)'
+ , $feed_entry->get_author_email()
+ , $feed_entry->get_author_name()
+ );
+ $this->assertEquals($author, $node->nodeValue);
+ break;
+ case 'pubDate':
+ $this->assertEquals($feed_entry->get_created_on()->format(DATE_RFC2822), $node->nodeValue);
+ break;
+ case 'guid':
+ $this->assertEquals($feed_entry->get_link()->get_href(), $node->nodeValue);
+ break;
+ case 'link':
+ $this->assertEquals($feed_entry->get_link()->get_href(), $node->nodeValue);
+ break;
+ }
+ $count ++;
+ $this->checkRSSEntryItemsNode($xpath, $feed_entry, $count);
}
- else
- {
- $this->fail("Missing media:entry");
- }
- break;
- }
+ $this->assertEquals($feed->get_count_total_entries(), $count);
}
- }
- public function removeBadItems(Array &$item_entries, Array $available_medium)
- {
- $remove = function($entry_item, $key) use (&$item_entries, $available_medium)
- {
- $preview_sd = $entry_item->get_record()->get_subdef('preview');
- $url_preview = $preview_sd->get_permalink();
- $thumbnail_sd = $entry_item->get_record()->get_thumbnail();
- $url_thumb = $thumbnail_sd->get_permalink();
+ function checkRSSEntryItemsNode(DOMXPath $xpath, Feed_Entry_Adapter $entry, $count)
+ {
+ $content = $entry->get_content();
+ $available_medium = array('image', 'audio', 'video');
+ array_walk($content, $this->removeBadItems($content, $available_medium));
+ $media_group = $xpath->query("/rss/channel/item[" . $count . "]/media:group");
+ $this->assertEquals(sizeof($content), $media_group->length);
- if (!in_array(strtolower($entry_item->get_record()->get_type()), $available_medium))
- {
- unset($item_entries[$key]); //remove
- }
+ foreach ($media_group as $media) {
+ $entry_item = array_shift($content);
+ $this->verifyMediaItem($entry_item, $media);
+ }
+ }
- if (!$url_thumb || !$url_preview)
- {
- unset($item_entries[$key]); //remove
- }
+ public function verifyMediaItem(Feed_Entry_Item $item, DOMNode $node)
+ {
+ foreach ($node->childNodes as $node) {
+ if ($node->nodeType !== XML_TEXT_NODE) {
+ switch ($node->nodeName) {
+ case 'media:content' :
+ $this->checkMediaContentAttributes($item, $node);
+ break;
+ case 'media:thumbnail':
+ default :
+ $this->checkOptionnalMediaGroupNode($node, $item);
+ break;
+ }
+ }
+ }
+ }
+
+ public function parseAttributes(DOMNode $node)
+ {
+ $current_attributes = array();
+ foreach ($node->attributes as $attribute) {
+ $current_attributes[$attribute->name] = $attribute->value;
+ }
+
+ return $current_attributes;
+ }
+
+ public function checkMediaContentAttributes(Feed_Entry_Item $entry_item, DOMNode $node)
+ {
+ $current_attributes = $this->parseAttributes($node);
+ $is_thumbnail = false;
+ $record = $entry_item->get_record();
+
+ if (substr($current_attributes["url"], 0 - strlen("/preview/")) == "/preview/") {
+ $ressource = $record->get_subdef('preview');
+ } else {
+ $ressource = $record->get_thumbnail();
+ $is_thumbnail = true;
+ }
+
+ $permalink = $ressource->get_permalink();
+
+ foreach ($current_attributes as $attribute => $value) {
+ switch ($attribute) {
+ case "url":
+ $this->assertEquals($permalink->get_url(), $value);
+ break;
+ case "fileSize":
+ $this->assertEquals($ressource->get_size(), $value);
+ break;
+ case "type":
+ $this->assertEquals($ressource->get_mime(), $value);
+ break;
+ case "medium":
+ $this->assertEquals(strtolower($record->get_type()), $value);
+ break;
+ case "isDefault":
+ ! $is_thumbnail ? $this->assertEquals("true", $value) : $this->assertEquals("false", $value);
+ break;
+ case "expression":
+ $this->assertEquals("full", $value);
+ break;
+ case "bitrate":
+ $this->assertEquals($value);
+ break;
+ case "height":
+ $this->assertEquals($ressource->get_height(), $value);
+ break;
+ case "width":
+ $this->assertEquals($ressource->get_width(), $value);
+ break;
+ case "duration" :
+ $this->assertEquals($record->get_duration(), $value);
+ break;
+ case "framerate":
+ case "samplingrate":
+ case "channels":
+ case "lang":
+ break;
+ default:
+ $this->fail($attribute . " is not valid");
+ break;
+ }
+ }
+ }
+
+ public function checkOptionnalMediaGroupNode(DOMNode $node, Feed_Entry_Item $entry_item)
+ {
+ $fields = array(
+ 'title' => array(
+ 'dc_field' => databox_Field_DCESAbstract::Title,
+ 'media_field' => array(
+ 'name' => 'media:title',
+ 'attributes' => array(
+ 'type' => 'plain'
+ )
+ ),
+ 'separator' => ' '
+ )
+ , 'description' => array(
+ 'dc_field' => databox_Field_DCESAbstract::Description,
+ 'media_field' => array(
+ 'name' => 'media:description',
+ 'attributes' => array()
+ ),
+ 'separator' => ' '
+ )
+ , 'contributor' => array(
+ 'dc_field' => databox_Field_DCESAbstract::Contributor,
+ 'media_field' => array(
+ 'name' => 'media:credit',
+ 'attributes' => array(
+ 'role' => 'contributor',
+ 'scheme' => 'urn:ebu'
+ )
+ ),
+ 'separator' => ' '
+ )
+ , 'director' => array(
+ 'dc_field' => databox_Field_DCESAbstract::Creator,
+ 'media_field' => array(
+ 'name' => 'media:credit',
+ 'attributes' => array(
+ 'role' => 'creator',
+ 'scheme' => 'urn:ebu'
+ )
+ ),
+ 'separator' => ' '
+ )
+ , 'publisher' => array(
+ 'dc_field' => databox_Field_DCESAbstract::Publisher,
+ 'media_field' => array(
+ 'name' => 'media:credit',
+ 'attributes' => array(
+ 'role' => 'publisher',
+ 'scheme' => 'urn:ebu'
+ )
+ ),
+ 'separator' => ' '
+ )
+ , 'rights' => array(
+ 'dc_field' => databox_Field_DCESAbstract::Rights,
+ 'media_field' => array(
+ 'name' => 'media:copyright',
+ 'attributes' => array()
+ ),
+ 'separator' => ' '
+ )
+ , 'keywords' => array(
+ 'dc_field' => databox_Field_DCESAbstract::Subject,
+ 'media_field' => array(
+ 'name' => 'media:keywords',
+ 'attributes' => array()
+ ),
+ 'separator' => ', '
+ )
+ );
+
+
+ foreach ($fields as $key_field => $field) {
+ if ($field["media_field"]["name"] == $node->nodeName) {
+ if ($p4field = $entry_item->get_record()->get_caption()->get_dc_field($field["dc_field"])) {
+ $this->assertEquals($p4field->get_serialized_values($field["separator"]), $node->nodeValue
+ , sprintf('Asserting good value for DC %s', $field["dc_field"]));
+ if (sizeof($field["media_field"]["attributes"]) > 0) {
+ 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']);
+ }
+ }
+ } else {
+ $this->fail("Missing media:entry");
+ }
+ break;
+ }
+ }
+ }
+
+ public function removeBadItems(Array &$item_entries, Array $available_medium)
+ {
+ $remove = function($entry_item, $key) use (&$item_entries, $available_medium) {
+ $preview_sd = $entry_item->get_record()->get_subdef('preview');
+ $url_preview = $preview_sd->get_permalink();
+ $thumbnail_sd = $entry_item->get_record()->get_thumbnail();
+ $url_thumb = $thumbnail_sd->get_permalink();
+
+ if ( ! in_array(strtolower($entry_item->get_record()->get_type()), $available_medium)) {
+ unset($item_entries[$key]); //remove
+ }
+
+ if ( ! $url_thumb || ! $url_preview) {
+ unset($item_entries[$key]); //remove
+ }
};
- return $remove;
- }
+ return $remove;
+ }
- public function verifyATOM(Feed_Adapter $feed, $xml_string)
- {
- $this->verifyXML($xml_string);
- $dom_doc = new DOMDocument();
- $dom_doc->loadXML($xml_string);
-
- $xpath = new DOMXPath($dom_doc);
- $xpath->registerNamespace("media", "http://search.yahoo.com/mrss/");
- $xpath->registerNamespace("Atom", "http://www.w3.org/2005/Atom");
-
- $this->checkATOMRootNode($dom_doc, $xpath, $feed);
- }
-
- public function checkATOMRootNode(DOMDocument $dom_doc, DOMXPath $xpath, Feed_Adapter $feed)
- {
- $ids = $xpath->query('/Atom:feed/Atom:id');
- $this->assertEquals($feed->get_homepage_link(registry::get_instance(), Feed_Adapter::FORMAT_ATOM, 1)->get_href(), $ids->item(0)->nodeValue);
-
- $titles = $xpath->query('/Atom:feed/Atom:title');
- $this->assertEquals($feed->get_title(), $titles->item(0)->nodeValue);
-
- $subtitles = $xpath->query('/Atom:feed/Atom:subtitle');
- if ($subtitles->length > 0)
- $this->assertEquals($feed->get_subtitle(), $subtitles->item(0)->nodeValue);
-
- $updateds = $xpath->query('/Atom:feed/Atom:updated');
- $this->assertTrue(new DateTime() >= new DateTime($updateds->item(0)->nodeValue));
-
- $entries_item = $xpath->query('/Atom:feed/Atom:entry');
-
- $count = 0;
- $offset_start = 0;
- $n_entries = 20;
- $collection = $feed->get_entries($offset_start, $n_entries);
- $entries = $collection->get_entries();
-
- foreach ($entries_item as $entry)
+ public function verifyATOM(Feed_Adapter $feed, $xml_string)
{
- if (sizeof($entries) == 0)
- {
- $offset_start = ($offset_start++) * $n_entries;
+ $this->verifyXML($xml_string);
+ $dom_doc = new DOMDocument();
+ $dom_doc->loadXML($xml_string);
+
+ $xpath = new DOMXPath($dom_doc);
+ $xpath->registerNamespace("media", "http://search.yahoo.com/mrss/");
+ $xpath->registerNamespace("Atom", "http://www.w3.org/2005/Atom");
+
+ $this->checkATOMRootNode($dom_doc, $xpath, $feed);
+ }
+
+ public function checkATOMRootNode(DOMDocument $dom_doc, DOMXPath $xpath, Feed_Adapter $feed)
+ {
+ $ids = $xpath->query('/Atom:feed/Atom:id');
+ $this->assertEquals($feed->get_homepage_link(registry::get_instance(), Feed_Adapter::FORMAT_ATOM, 1)->get_href(), $ids->item(0)->nodeValue);
+
+ $titles = $xpath->query('/Atom:feed/Atom:title');
+ $this->assertEquals($feed->get_title(), $titles->item(0)->nodeValue);
+
+ $subtitles = $xpath->query('/Atom:feed/Atom:subtitle');
+ if ($subtitles->length > 0)
+ $this->assertEquals($feed->get_subtitle(), $subtitles->item(0)->nodeValue);
+
+ $updateds = $xpath->query('/Atom:feed/Atom:updated');
+ $this->assertTrue(new DateTime() >= new DateTime($updateds->item(0)->nodeValue));
+
+ $entries_item = $xpath->query('/Atom:feed/Atom:entry');
+
+ $count = 0;
+ $offset_start = 0;
+ $n_entries = 20;
$collection = $feed->get_entries($offset_start, $n_entries);
$entries = $collection->get_entries();
- if (sizeof($entries) == 0) //no more
- break;
- }
- $feed_entry = array_shift($entries);
- $this->checkATOMEntryNode($entry, $xpath, $feed, $feed_entry);
- $count++;
- }
- $this->assertEquals($feed->get_count_total_entries(), $count);
- }
- public function checkATOMEntryNode(DOMNode $node, DOMXPath $xpath, Feed_Adapter $feed, Feed_Entry_Adapter $entry)
- {
- foreach ($node->childNodes as $child)
- {
- if ($child->nodeType !== XML_TEXT_NODE)
- {
- switch ($child->nodeName)
- {
- case 'id':
- $this->assertEquals(sprintf('%sentry/%d/', $feed->get_homepage_link(registry::get_instance(), Feed_Adapter::FORMAT_ATOM, 1)->get_href(), $entry->get_id()), $child->nodeValue);
- break;
- case 'link':
- foreach ($child->attributes as $attribute)
- {
- if ($attribute->name == "href")
- {
- $this->assertEquals(sprintf('%sentry/%d/', $feed->get_homepage_link(registry::get_instance(), Feed_Adapter::FORMAT_ATOM, 1)->get_href(), $entry->get_id()), $attribute->value);
- break;
- }
+ foreach ($entries_item as $entry) {
+ if (sizeof($entries) == 0) {
+ $offset_start = ($offset_start ++ ) * $n_entries;
+ $collection = $feed->get_entries($offset_start, $n_entries);
+ $entries = $collection->get_entries();
+ if (sizeof($entries) == 0) //no more
+ break;
}
- break;
- case 'updated':
- $this->assertEquals($entry->get_updated_on()->format(DATE_ATOM), $child->nodeValue);
- break;
- case 'published':
- $this->assertEquals($entry->get_created_on()->format(DATE_ATOM), $child->nodeValue);
- break;
- case 'title':
- $this->assertEquals($entry->get_title(), $child->nodeValue);
- break;
- case 'content':
- $this->assertEquals($entry->get_subtitle(), $child->nodeValue);
- break;
- case 'author':
- foreach ($node->childNodes as $child)
- {
- if ($child->nodeType !== XML_TEXT_NODE && $child->nodeName == "email")
- $this->assertEquals($entry->get_author_email(), $child->nodeValue);
- if ($child->nodeType !== XML_TEXT_NODE && $child->nodeName == "name")
- $this->assertEquals($entry->get_author_name(), $child->nodeValue);
- }
- break;
+ $feed_entry = array_shift($entries);
+ $this->checkATOMEntryNode($entry, $xpath, $feed, $feed_entry);
+ $count ++;
}
- }
+ $this->assertEquals($feed->get_count_total_entries(), $count);
}
- $content = $entry->get_content();
-
-
- $available_medium = array('image', 'audio', 'video');
-
- array_walk($content, $this->removeBadItems($content, $available_medium));
-
-
- $media_group = $xpath->query("/Atom:feed/Atom:entry[0]/media:group");
-
- if ($media_group->length > 0)
+ public function checkATOMEntryNode(DOMNode $node, DOMXPath $xpath, Feed_Adapter $feed, Feed_Entry_Adapter $entry)
{
- foreach ($media_group as $media)
- {
-
- $entry_item = array_shift($content);
- if ($entry_item instanceof Feed_Entry_Item)
- {
- $this->verifyMediaItem($entry_item, $media);
+ foreach ($node->childNodes as $child) {
+ if ($child->nodeType !== XML_TEXT_NODE) {
+ switch ($child->nodeName) {
+ case 'id':
+ $this->assertEquals(sprintf('%sentry/%d/', $feed->get_homepage_link(registry::get_instance(), Feed_Adapter::FORMAT_ATOM, 1)->get_href(), $entry->get_id()), $child->nodeValue);
+ break;
+ case 'link':
+ foreach ($child->attributes as $attribute) {
+ if ($attribute->name == "href") {
+ $this->assertEquals(sprintf('%sentry/%d/', $feed->get_homepage_link(registry::get_instance(), Feed_Adapter::FORMAT_ATOM, 1)->get_href(), $entry->get_id()), $attribute->value);
+ break;
+ }
+ }
+ break;
+ case 'updated':
+ $this->assertEquals($entry->get_updated_on()->format(DATE_ATOM), $child->nodeValue);
+ break;
+ case 'published':
+ $this->assertEquals($entry->get_created_on()->format(DATE_ATOM), $child->nodeValue);
+ break;
+ case 'title':
+ $this->assertEquals($entry->get_title(), $child->nodeValue);
+ break;
+ case 'content':
+ $this->assertEquals($entry->get_subtitle(), $child->nodeValue);
+ break;
+ case 'author':
+ foreach ($node->childNodes as $child) {
+ if ($child->nodeType !== XML_TEXT_NODE && $child->nodeName == "email")
+ $this->assertEquals($entry->get_author_email(), $child->nodeValue);
+ if ($child->nodeType !== XML_TEXT_NODE && $child->nodeName == "name")
+ $this->assertEquals($entry->get_author_name(), $child->nodeValue);
+ }
+ break;
+ }
+ }
}
- }
- }
- }
+ $content = $entry->get_content();
+
+
+ $available_medium = array('image', 'audio', 'video');
+
+ array_walk($content, $this->removeBadItems($content, $available_medium));
+
+
+ $media_group = $xpath->query("/Atom:feed/Atom:entry[0]/media:group");
+
+ if ($media_group->length > 0) {
+ foreach ($media_group as $media) {
+
+ $entry_item = array_shift($content);
+ if ($entry_item instanceof Feed_Entry_Item) {
+ $this->verifyMediaItem($entry_item, $media);
+ }
+ }
+ }
+ }
}
diff --git a/tests/Alchemy/Phrasea/Controller/Setup/FakeSetupApplication.inc b/tests/Alchemy/Phrasea/Controller/Setup/FakeSetupApplication.inc
index ef94e897eb..af952c1707 100644
--- a/tests/Alchemy/Phrasea/Controller/Setup/FakeSetupApplication.inc
+++ b/tests/Alchemy/Phrasea/Controller/Setup/FakeSetupApplication.inc
@@ -7,28 +7,25 @@ use Symfony\Component\HttpFoundation\Request;
use Alchemy\Phrasea\Controller\Setup as Controller;
use Alchemy\Phrasea\Controller\Utils as ControllerUtils;
+return call_user_func(function() {
+ $app = new \Silex\Application();
-return call_user_func(function()
- {
- $app = new \Silex\Application();
+ $app['Core'] = \bootstrap::getCore();
- $app['Core'] = \bootstrap::getCore();
+ $app['install'] = true;
- $app['install'] = true;
+ $app->get('/', function() use ($app) {
+ return $app->redirect('/setup/installer/');
+ });
- $app->get('/', function() use ($app)
- {
- return $app->redirect('/setup/installer/');
+ $app->mount('/installer/', new Controller\Installer());
+ $app->mount('/test', new ControllerUtils\PathFileTest());
+ $app->mount('/connection_test', new ControllerUtils\ConnectionTest());
+
+
+ $app->error(function($e) {
+
+ });
+
+ return $app;
});
-
- $app->mount('/installer/', new Controller\Installer());
- $app->mount('/test', new ControllerUtils\PathFileTest());
- $app->mount('/connection_test', new ControllerUtils\ConnectionTest());
-
-
- $app->error(function($e){
-
- });
-
- return $app;
- });
diff --git a/tests/Alchemy/Phrasea/Controller/Setup/FakeUpgradeApplication.inc b/tests/Alchemy/Phrasea/Controller/Setup/FakeUpgradeApplication.inc
index 1e26903014..fb6971dbdb 100644
--- a/tests/Alchemy/Phrasea/Controller/Setup/FakeUpgradeApplication.inc
+++ b/tests/Alchemy/Phrasea/Controller/Setup/FakeUpgradeApplication.inc
@@ -7,28 +7,26 @@ use Symfony\Component\HttpFoundation\Request;
use Alchemy\Phrasea\Controller\Setup as Controller;
use Alchemy\Phrasea\Controller\Utils as ControllerUtils;
+return call_user_func(function() {
+ $app = new \Silex\Application();
-return call_user_func(function()
- {
- $app = new \Silex\Application();
+ $app['Core'] = \bootstrap::getCore();
- $app['Core'] = \bootstrap::getCore();
+ $app['upgrade'] = true;
- $app['upgrade'] = true;
+ $app->get('/', function() use ($app) {
+ return $app->redirect('/setup/upgrader/');
+ });
- $app->get('/', function() use ($app)
- {
- return $app->redirect('/setup/upgrader/');
+ $app->mount('/upgrader/', new Controller\Upgrader());
+ $app->mount('/test', new ControllerUtils\PathFileTest());
+ $app->mount('/connection_test', new ControllerUtils\ConnectionTest());
+
+
+ $app->error(function($e) {
+
+ });
+
+
+ return $app;
});
-
- $app->mount('/upgrader/', new Controller\Upgrader());
- $app->mount('/test', new ControllerUtils\PathFileTest());
- $app->mount('/connection_test', new ControllerUtils\ConnectionTest());
-
-
- $app->error(function($e){
- });
-
-
- return $app;
- });
diff --git a/tests/Alchemy/Phrasea/Controller/Setup/InstallerTest.php b/tests/Alchemy/Phrasea/Controller/Setup/InstallerTest.php
index 62e879679c..c5370e88f8 100644
--- a/tests/Alchemy/Phrasea/Controller/Setup/InstallerTest.php
+++ b/tests/Alchemy/Phrasea/Controller/Setup/InstallerTest.php
@@ -4,70 +4,69 @@ require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAbstract.class.inc';
class ControllerInstallerTest extends \PhraseanetWebTestCaseAbstract
{
+ /**
+ * As controllers use WebTestCase, it requires a client
+ */
+ protected $client;
- /**
- * As controllers use WebTestCase, it requires a client
- */
- protected $client;
- /**
- * If the controller tests require some records, specify it her
- *
- * For example, this will loacd 2 records
- * (self::$record_1 and self::$record_2) :
- *
- * $need_records = 2;
- *
- */
- protected static $need_records = false;
+ /**
+ * If the controller tests require some records, specify it her
+ *
+ * For example, this will loacd 2 records
+ * (self::$record_1 and self::$record_2) :
+ *
+ * $need_records = 2;
+ *
+ */
+ protected static $need_records = false;
- /**
- * The application loader
- */
- public function createApplication()
- {
- return require __DIR__ . '/FakeSetupApplication.inc';
- }
+ /**
+ * The application loader
+ */
+ public function createApplication()
+ {
+ return require __DIR__ . '/FakeSetupApplication.inc';
+ }
- public function setUp()
- {
- parent::setUp();
- $this->client = $this->createClient();
- }
+ public function setUp()
+ {
+ parent::setUp();
+ $this->client = $this->createClient();
+ }
- /**
- * Default route test
- */
- public function testRouteSlash()
- {
- $this->client->request('GET', '/');
+ /**
+ * Default route test
+ */
+ public function testRouteSlash()
+ {
+ $this->client->request('GET', '/');
- $response = $this->client->getResponse();
- /* @var $response \Symfony\Component\HttpFoundation\Response */
+ $response = $this->client->getResponse();
+ /* @var $response \Symfony\Component\HttpFoundation\Response */
- $this->assertEquals(302, $response->getStatusCode());
- $this->assertEquals('/setup/installer/', $response->headers->get('location'));
- }
+ $this->assertEquals(302, $response->getStatusCode());
+ $this->assertEquals('/setup/installer/', $response->headers->get('location'));
+ }
- public function testRouteInstaller()
- {
- $this->client->request('GET', '/installer/');
+ public function testRouteInstaller()
+ {
+ $this->client->request('GET', '/installer/');
- $response = $this->client->getResponse();
- /* @var $response \Symfony\Component\HttpFoundation\Response */
+ $response = $this->client->getResponse();
+ /* @var $response \Symfony\Component\HttpFoundation\Response */
- $this->assertEquals(302, $response->getStatusCode(), "test that response is a redirection " . $this->client->getResponse()->getContent());
- $this->assertEquals('/setup/installer/step2/', $response->headers->get('location'));
- }
+ $this->assertEquals(302, $response->getStatusCode(), "test that response is a redirection " . $this->client->getResponse()->getContent());
+ $this->assertEquals('/setup/installer/step2/', $response->headers->get('location'));
+ }
- public function testRouteInstallerStep2()
- {
- $this->client->request('GET', '/installer/step2/');
+ public function testRouteInstallerStep2()
+ {
+ $this->client->request('GET', '/installer/step2/');
- $response = $this->client->getResponse();
- /* @var $response \Symfony\Component\HttpFoundation\Response */
-
- $this->assertEquals(200, $response->getStatusCode());
- $this->assertTrue($response->isOk());
- }
+ $response = $this->client->getResponse();
+ /* @var $response \Symfony\Component\HttpFoundation\Response */
+ $this->assertEquals(200, $response->getStatusCode());
+ $this->assertTrue($response->isOk());
+ }
}
diff --git a/tests/Alchemy/Phrasea/Controller/Setup/UpgraderTest.php b/tests/Alchemy/Phrasea/Controller/Setup/UpgraderTest.php
index a45a1810ba..255c294991 100644
--- a/tests/Alchemy/Phrasea/Controller/Setup/UpgraderTest.php
+++ b/tests/Alchemy/Phrasea/Controller/Setup/UpgraderTest.php
@@ -4,85 +4,86 @@ require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAbstract.class.inc';
class ControllerUpgraderTest extends \PhraseanetWebTestCaseAbstract
{
+ /**
+ * As controllers use WebTestCase, it requires a client
+ */
+ protected $client;
- /**
- * As controllers use WebTestCase, it requires a client
- */
- protected $client;
- /**
- * If the controller tests require some records, specify it her
- *
- * For example, this will loacd 2 records
- * (self::$record_1 and self::$record_2) :
- *
- * $need_records = 2;
- *
- */
- protected static $need_records = false;
+ /**
+ * If the controller tests require some records, specify it her
+ *
+ * For example, this will loacd 2 records
+ * (self::$record_1 and self::$record_2) :
+ *
+ * $need_records = 2;
+ *
+ */
+ protected static $need_records = false;
- /**
- * The application loader
- */
- public function createApplication()
- {
- return require __DIR__ . '/FakeUpgradeApplication.inc';
- }
+ /**
+ * The application loader
+ */
+ public function createApplication()
+ {
+ return require __DIR__ . '/FakeUpgradeApplication.inc';
+ }
- public function setUp()
- {
- parent::setUp();
- $this->client = $this->createClient();
- }
+ public function setUp()
+ {
+ parent::setUp();
+ $this->client = $this->createClient();
+ }
- /**
- * Default route test
- */
- public function testRouteSlash()
- {
- $this->client->request('GET', '/');
+ /**
+ * Default route test
+ */
+ public function testRouteSlash()
+ {
+ $this->client->request('GET', '/');
- $response = $this->client->getResponse();
- /* @var $response \Symfony\Component\HttpFoundation\Response */
+ $response = $this->client->getResponse();
+ /* @var $response \Symfony\Component\HttpFoundation\Response */
- $this->assertEquals(302, $response->getStatusCode());
- $this->assertEquals('/setup/upgrader/', $response->headers->get('location'));
- }
+ $this->assertEquals(302, $response->getStatusCode());
+ $this->assertEquals('/setup/upgrader/', $response->headers->get('location'));
+ }
- /**
- * Default route test
- */
- public function testRouteUpgrader()
- {
- $this->client->request('GET', '/upgrader/');
+ /**
+ * Default route test
+ */
+ public function testRouteUpgrader()
+ {
+ $this->client->request('GET', '/upgrader/');
- $response = $this->client->getResponse();
- /* @var $response \Symfony\Component\HttpFoundation\Response */
+ $response = $this->client->getResponse();
+ /* @var $response \Symfony\Component\HttpFoundation\Response */
- $this->assertEquals(200, $response->getStatusCode());
- }
- /**
- * Default route test
- */
- public function testRouteStatus()
- {
- $this->client->request('GET', '/upgrader/status/');
+ $this->assertEquals(200, $response->getStatusCode());
+ }
- $response = $this->client->getResponse();
- /* @var $response \Symfony\Component\HttpFoundation\Response */
+ /**
+ * Default route test
+ */
+ public function testRouteStatus()
+ {
+ $this->client->request('GET', '/upgrader/status/');
- $this->assertEquals(200, $response->getStatusCode());
- }
- /**
- * Default route test
- */
- public function testRouteExecute()
- {
- $this->client->request('POST', '/upgrader/execute/');
+ $response = $this->client->getResponse();
+ /* @var $response \Symfony\Component\HttpFoundation\Response */
- $response = $this->client->getResponse();
- /* @var $response \Symfony\Component\HttpFoundation\Response */
- $this->assertEquals(302, $response->getStatusCode());
- $this->assertEquals('/', $response->headers->get('location'));
- }
+ $this->assertEquals(200, $response->getStatusCode());
+ }
+ /**
+ * Default route test
+ */
+ public function testRouteExecute()
+ {
+ $this->client->request('POST', '/upgrader/execute/');
+
+ $response = $this->client->getResponse();
+ /* @var $response \Symfony\Component\HttpFoundation\Response */
+ $this->assertEquals(302, $response->getStatusCode());
+ $this->assertEquals('/', $response->headers->get('location'));
+ }
}
diff --git a/tests/Alchemy/Phrasea/Controller/Utils/ConnectionTestTest.php b/tests/Alchemy/Phrasea/Controller/Utils/ConnectionTestTest.php
index aea7bf70f8..ea06da8ecd 100644
--- a/tests/Alchemy/Phrasea/Controller/Utils/ConnectionTestTest.php
+++ b/tests/Alchemy/Phrasea/Controller/Utils/ConnectionTestTest.php
@@ -4,120 +4,118 @@ require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAbstract.class.inc';
class ControllerConnectionTestTest extends \PhraseanetWebTestCaseAbstract
{
+ /**
+ * As controllers use WebTestCase, it requires a client
+ */
+ protected $client;
- /**
- * As controllers use WebTestCase, it requires a client
- */
- protected $client;
+ /**
+ * If the controller tests require some records, specify it her
+ *
+ * For example, this will loacd 2 records
+ * (self::$record_1 and self::$record_2) :
+ *
+ * $need_records = 2;
+ *
+ */
+ protected static $need_records = false;
- /**
- * If the controller tests require some records, specify it her
- *
- * For example, this will loacd 2 records
- * (self::$record_1 and self::$record_2) :
- *
- * $need_records = 2;
- *
- */
- protected static $need_records = false;
+ /**
+ * The application loader
+ */
+ public function createApplication()
+ {
+ return require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Admin.php';
+ }
- /**
- * The application loader
- */
- public function createApplication()
- {
- return require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Admin.php';
- }
+ public function setUp()
+ {
+ parent::setUp();
+ $this->client = $this->createClient();
+ }
- public function setUp()
- {
- parent::setUp();
- $this->client = $this->createClient();
- }
+ /**
+ * Default route test
+ */
+ public function testRouteMysql()
+ {
+ $configuration = \Alchemy\Phrasea\Core\Configuration::build();
- /**
- * Default route test
- */
- public function testRouteMysql()
- {
- $configuration = \Alchemy\Phrasea\Core\Configuration::build();
+ $chooseConnexion = $configuration->getPhraseanet()->get('database');
- $chooseConnexion = $configuration->getPhraseanet()->get('database');
+ $connexion = $configuration->getConnexion($chooseConnexion);
- $connexion = $configuration->getConnexion($chooseConnexion);
+ $params = array(
+ "hostname" => $connexion->get('host'),
+ "port" => $connexion->get('port'),
+ "user" => $connexion->get('user'),
+ "password" => $connexion->get('password'),
+ "dbname" => $connexion->get('dbname')
+ );
- $params = array(
- "hostname" => $connexion->get('host'),
- "port" => $connexion->get('port'),
- "user" => $connexion->get('user'),
- "password" => $connexion->get('password'),
- "dbname" => $connexion->get('dbname')
- );
+ $this->client->request("GET", "/tests/connection/mysql/", $params);
+ $response = $this->client->getResponse();
+ $this->assertTrue($response->isOk());
+ }
- $this->client->request("GET", "/tests/connection/mysql/", $params);
- $response = $this->client->getResponse();
- $this->assertTrue($response->isOk());
- }
+ public function testRouteMysqlFailed()
+ {
+ $configuration = \Alchemy\Phrasea\Core\Configuration::build();
- public function testRouteMysqlFailed()
- {
- $configuration = \Alchemy\Phrasea\Core\Configuration::build();
+ $chooseConnexion = $configuration->getPhraseanet()->get('database');
- $chooseConnexion = $configuration->getPhraseanet()->get('database');
+ $connexion = $configuration->getConnexion($chooseConnexion);
- $connexion = $configuration->getConnexion($chooseConnexion);
+ $params = array(
+ "hostname" => $connexion->get('host'),
+ "port" => $connexion->get('port'),
+ "user" => $connexion->get('user'),
+ "password" => "fakepassword",
+ "dbname" => $connexion->get('dbname')
+ );
- $params = array(
- "hostname" => $connexion->get('host'),
- "port" => $connexion->get('port'),
- "user" => $connexion->get('user'),
- "password" => "fakepassword",
- "dbname" => $connexion->get('dbname')
- );
-
- $this->client->request("GET", "/tests/connection/mysql/", $params);
- $response = $this->client->getResponse();
- $content = json_decode($this->client->getResponse()->getContent());
- $this->assertEquals("application/json", $this->client->getResponse()->headers->get("content-type"));
- $this->assertTrue($response->isOk());
- $this->assertTrue(is_object($content));
- $this->assertObjectHasAttribute('connection', $content);
- $this->assertObjectHasAttribute('database', $content);
- $this->assertObjectHasAttribute('is_empty', $content);
- $this->assertObjectHasAttribute('is_appbox', $content);
- $this->assertObjectHasAttribute('is_databox', $content);
- $this->assertFalse($content->connection);
- }
+ $this->client->request("GET", "/tests/connection/mysql/", $params);
+ $response = $this->client->getResponse();
+ $content = json_decode($this->client->getResponse()->getContent());
+ $this->assertEquals("application/json", $this->client->getResponse()->headers->get("content-type"));
+ $this->assertTrue($response->isOk());
+ $this->assertTrue(is_object($content));
+ $this->assertObjectHasAttribute('connection', $content);
+ $this->assertObjectHasAttribute('database', $content);
+ $this->assertObjectHasAttribute('is_empty', $content);
+ $this->assertObjectHasAttribute('is_appbox', $content);
+ $this->assertObjectHasAttribute('is_databox', $content);
+ $this->assertFalse($content->connection);
+ }
public function testRouteMysqlDbFailed()
- {
- $configuration = \Alchemy\Phrasea\Core\Configuration::build();
+ {
+ $configuration = \Alchemy\Phrasea\Core\Configuration::build();
- $chooseConnexion = $configuration->getPhraseanet()->get('database');
+ $chooseConnexion = $configuration->getPhraseanet()->get('database');
- $connexion = $configuration->getConnexion($chooseConnexion);
+ $connexion = $configuration->getConnexion($chooseConnexion);
- $params = array(
- "hostname" => $connexion->get('host'),
- "port" => $connexion->get('port'),
- "user" => $connexion->get('user'),
- "password" => $connexion->get('password'),
- "dbname" => "fake-DTABASE-name"
- );
-
- $this->client->request("GET", "/tests/connection/mysql/", $params);
- $response = $this->client->getResponse();
- $content = json_decode($this->client->getResponse()->getContent());
- $this->assertEquals("application/json", $this->client->getResponse()->headers->get("content-type"));
- $this->assertTrue($response->isOk());
- $this->assertTrue(is_object($content));
- $this->assertObjectHasAttribute('connection', $content);
- $this->assertObjectHasAttribute('database', $content);
- $this->assertObjectHasAttribute('is_empty', $content);
- $this->assertObjectHasAttribute('is_appbox', $content);
- $this->assertObjectHasAttribute('is_databox', $content);
- $this->assertFalse($content->database);
- }
+ $params = array(
+ "hostname" => $connexion->get('host'),
+ "port" => $connexion->get('port'),
+ "user" => $connexion->get('user'),
+ "password" => $connexion->get('password'),
+ "dbname" => "fake-DTABASE-name"
+ );
+ $this->client->request("GET", "/tests/connection/mysql/", $params);
+ $response = $this->client->getResponse();
+ $content = json_decode($this->client->getResponse()->getContent());
+ $this->assertEquals("application/json", $this->client->getResponse()->headers->get("content-type"));
+ $this->assertTrue($response->isOk());
+ $this->assertTrue(is_object($content));
+ $this->assertObjectHasAttribute('connection', $content);
+ $this->assertObjectHasAttribute('database', $content);
+ $this->assertObjectHasAttribute('is_empty', $content);
+ $this->assertObjectHasAttribute('is_appbox', $content);
+ $this->assertObjectHasAttribute('is_databox', $content);
+ $this->assertFalse($content->database);
+ }
}
diff --git a/tests/Alchemy/Phrasea/Controller/Utils/PathFileTestTest.php b/tests/Alchemy/Phrasea/Controller/Utils/PathFileTestTest.php
index cb7aaa7b1f..95c71ced87 100644
--- a/tests/Alchemy/Phrasea/Controller/Utils/PathFileTestTest.php
+++ b/tests/Alchemy/Phrasea/Controller/Utils/PathFileTestTest.php
@@ -4,66 +4,64 @@ require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAbstract.class.inc';
class ControllerPathFileTestTest extends \PhraseanetWebTestCaseAbstract
{
+ /**
+ * As controllers use WebTestCase, it requires a client
+ */
+ protected $client;
- /**
- * As controllers use WebTestCase, it requires a client
- */
- protected $client;
+ /**
+ * If the controller tests require some records, specify it her
+ *
+ * For example, this will loacd 2 records
+ * (self::$record_1 and self::$record_2) :
+ *
+ * $need_records = 2;
+ *
+ */
+ protected static $need_records = false;
- /**
- * If the controller tests require some records, specify it her
- *
- * For example, this will loacd 2 records
- * (self::$record_1 and self::$record_2) :
- *
- * $need_records = 2;
- *
- */
- protected static $need_records = false;
+ /**
+ * The application loader
+ */
+ public function createApplication()
+ {
+ return require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Admin.php';
+ }
- /**
- * The application loader
- */
- public function createApplication()
- {
- return require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Admin.php';
- }
+ public function setUp()
+ {
+ parent::setUp();
+ $this->client = $this->createClient();
+ }
- public function setUp()
- {
- parent::setUp();
- $this->client = $this->createClient();
- }
+ /**
+ * Default route test
+ */
+ public function testRoutePath()
+ {
+ $file = new \SplFileObject(__DIR__ . '/../../../../testfiles/cestlafete.jpg');
+ $this->client->request("GET", "/tests/pathurl/path/", array('path' => $file->getPathname()));
- /**
- * Default route test
- */
- public function testRoutePath()
- {
- $file = new \SplFileObject(__DIR__ . '/../../../../testfiles/cestlafete.jpg');
- $this->client->request("GET", "/tests/pathurl/path/", array('path' => $file->getPathname()));
+ $response = $this->client->getResponse();
+ $this->assertTrue($response->isOk());
+ $this->assertEquals("application/json", $this->client->getResponse()->headers->get("content-type"));
+ $content = json_decode($this->client->getResponse()->getContent());
+ $this->assertTrue(is_object($content));
+ $this->assertObjectHasAttribute('exists', $content);
+ $this->assertObjectHasAttribute('file', $content);
+ $this->assertObjectHasAttribute('dir', $content);
+ $this->assertObjectHasAttribute('readable', $content);
+ $this->assertObjectHasAttribute('executable', $content);
+ }
- $response = $this->client->getResponse();
- $this->assertTrue($response->isOk());
- $this->assertEquals("application/json", $this->client->getResponse()->headers->get("content-type"));
- $content = json_decode($this->client->getResponse()->getContent());
- $this->assertTrue(is_object($content));
- $this->assertObjectHasAttribute('exists', $content);
- $this->assertObjectHasAttribute('file', $content);
- $this->assertObjectHasAttribute('dir', $content);
- $this->assertObjectHasAttribute('readable', $content);
- $this->assertObjectHasAttribute('executable', $content);
- }
-
- public function testRouteUrl()
- {
- $this->client->request("GET", "/tests/pathurl/url/", array('url' => "www.google.com"));
-
- $response = $this->client->getResponse();
- $this->assertTrue($response->isOk());
- $this->assertEquals("application/json", $this->client->getResponse()->headers->get("content-type"));
- $content = json_decode($this->client->getResponse()->getContent());
- $this->assertTrue(is_object($content));
- }
+ public function testRouteUrl()
+ {
+ $this->client->request("GET", "/tests/pathurl/url/", array('url' => "www.google.com"));
+ $response = $this->client->getResponse();
+ $this->assertTrue($response->isOk());
+ $this->assertEquals("application/json", $this->client->getResponse()->headers->get("content-type"));
+ $content = json_decode($this->client->getResponse()->getContent());
+ $this->assertTrue(is_object($content));
+ }
}
diff --git a/tests/Alchemy/Phrasea/Core/Configuration/ConfigurationTest.php b/tests/Alchemy/Phrasea/Core/Configuration/ConfigurationTest.php
index 1e66ff0262..3f0422e207 100644
--- a/tests/Alchemy/Phrasea/Core/Configuration/ConfigurationTest.php
+++ b/tests/Alchemy/Phrasea/Core/Configuration/ConfigurationTest.php
@@ -1,500 +1,453 @@
markTestSkipped('To rewrite');
- parent::setUp();
-
- $specNotInstalled = $this->getMock(
- '\Alchemy\Phrasea\Core\Configuration\Application'
- , array('getConfigurationsFile')
- );
-
- $specNotInstalled->expects($this->any())
- ->method('getConfigurationsFile')
- ->will(
- $this->throwException(new Exception)
- );
-
- $specExperience = $this->getMock(
- '\Alchemy\Phrasea\Core\Configuration\Application'
- , array('getConfigurationsFile')
- );
-
- $specExperience->expects($this->any())
- ->method('getConfigurationsFile')
- ->will(
- $this->returnValue(
- new \SplFileObject(__DIR__ . '/confTestFiles/config.yml')
- )
- );
-
- $handler = new Configuration\Handler($specNotInstalled);
- $this->confNotInstalled = new PhraseaCore\Configuration($handler);
-
-
- $handler = new Configuration\Handler($specExperience);
- $this->object = new PhraseaCore\Configuration($handler);
- }
-
- public function testGetEnvironment()
- {
- $this->assertEquals("dev", $this->object->getEnvironnement());
- $this->assertEquals(null, $this->confNotInstalled->getEnvironnement());
- }
-
- public function testSetEnvironment()
- {
- $this->object->setEnvironnement("test");
- $this->assertEquals("test", $this->object->getEnvironnement());
- $this->confNotInstalled->setEnvironnement("prod");
- $this->assertEquals("prod", $this->confNotInstalled->getEnvironnement());
-
- try
- {
- $this->object->setEnvironnement("unknow");
- $this->fail("should raise exception");
- }
- catch (\Exception $e)
+ public function setUp()
{
+ $this->markTestSkipped('To rewrite');
+ parent::setUp();
- }
- }
+ $specNotInstalled = $this->getMock(
+ '\Alchemy\Phrasea\Core\Configuration\Application'
+ , array('getConfigurationsFile')
+ );
- public function testIsDebug()
- {
- $this->object->setEnvironnement("test");
- $this->assertTrue($this->object->isDebug());
- $this->object->setEnvironnement("dev");
- $this->assertTrue($this->object->isDebug());
- $this->object->setEnvironnement("prod");
- $this->assertFalse($this->object->isDebug());
- $this->object->setEnvironnement("no_debug");
- $this->assertFalse($this->object->isDebug());
- }
+ $specNotInstalled->expects($this->any())
+ ->method('getConfigurationsFile')
+ ->will(
+ $this->throwException(new Exception)
+ );
- public function testIsMaintened()
- {
- $this->object->setEnvironnement("test");
- $this->assertFalse($this->object->isMaintained());
- $this->object->setEnvironnement("dev");
- $this->assertFalse($this->object->isMaintained());
- $this->object->setEnvironnement("prod");
- $this->assertFalse($this->object->isMaintained());
- $this->object->setEnvironnement("no_maintenance");
- $this->assertFalse($this->object->isMaintained());
- }
+ $specExperience = $this->getMock(
+ '\Alchemy\Phrasea\Core\Configuration\Application'
+ , array('getConfigurationsFile')
+ );
- public function testIsDisplayingErrors()
- {
- $this->object->setEnvironnement("test");
- $this->assertTrue($this->object->isDisplayingErrors());
- $this->object->setEnvironnement("dev");
- $this->assertTrue($this->object->isDisplayingErrors());
- $this->object->setEnvironnement("prod");
- $this->assertFalse($this->object->isDisplayingErrors());
- $this->object->setEnvironnement("no_display_errors");
- $this->assertFalse($this->object->isDisplayingErrors());
- }
+ $specExperience->expects($this->any())
+ ->method('getConfigurationsFile')
+ ->will(
+ $this->returnValue(
+ new \SplFileObject(__DIR__ . '/confTestFiles/config.yml')
+ )
+ );
- public function testGetPhraseanet()
- {
- $this->object->setEnvironnement("test");
- $this->assertInstanceOf("\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag", $this->object->getPhraseanet());
- $this->object->setEnvironnement("dev");
- $this->assertInstanceOf("\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag", $this->object->getPhraseanet());
- $this->object->setEnvironnement("prod");
- $this->assertInstanceOf("\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag", $this->object->getPhraseanet());
- $this->object->setEnvironnement("missing_phraseanet");
- try
- {
- $this->object->getPhraseanet();
- $this->fail("should raise an exeception");
- }
- catch (\Exception $e)
- {
+ $handler = new Configuration\Handler($specNotInstalled);
+ $this->confNotInstalled = new PhraseaCore\Configuration($handler);
- }
- }
-
- public function testisInstalled()
- {
- $this->assertFalse($this->confNotInstalled->isInstalled());
- $this->assertTrue($this->object->isInstalled());
- }
-
- public function testGetConfiguration()
- {
- $config = $this->object->getConfiguration();
- $this->assertInstanceOf("\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag", $config);
- $this->assertNotEmpty($config->all());
- $config = $this->confNotInstalled->getConfiguration();
- $this->assertEmpty($config->all());
- }
-
- public function testGetConnexions()
- {
- $connexions = $this->object->getConnexions();
- $this->assertInstanceOf("\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag", $connexions);
- $this->assertGreaterThan(0, sizeof($connexions->all()));
- }
-
- public function testGetConnexion()
- {
- $connexion = $this->object->getConnexion();
- $this->assertInstanceOf("\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag", $connexion);
- $this->assertGreaterThan(0, sizeof($connexion->all()));
- }
-
- public function testGetConnexionException()
- {
- try
- {
- $this->object->getConnexion('unknow_connexion');
- $this->fail('should raise an exception');
- }
- catch (\Exception $e)
- {
-
- }
- }
-
- public function testGetFile()
- {
- $this->assertInstanceOf("\SplFileObject", $this->object->getFile());
- }
-
- public function testGetFileExeption()
- {
- try
- {
- $this->assertInstanceOf("\SplFileObject", $this->confNotInstalled->getFile());
- $this->fail("should raise an excpetion");
- }
- catch (\Exception $e)
- {
-
- }
- }
-
- public function testAll()
- {
- $all = $this->object->all();
- $this->assertTrue(is_array($all));
- $this->assertArrayHasKey("test", $all);
- $this->assertArrayHasKey("dev", $all);
- $this->assertArrayHasKey("prod", $all);
- $this->assertArrayHasKey("environment", $all);
- }
-
- public function testGetServices()
- {
- $services = $this->object->getServices();
- $this->assertInstanceOf("\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag", $services);
- $this->assertGreaterThan(0, sizeof($services->all()));
- }
-
- public function testGetService()
- {
- $services = $this->object->getService('TemplateEngine\Twig');
- $this->assertInstanceOf("\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag", $services);
- $this->assertGreaterThan(0, sizeof($services->all()));
- }
-
- public function testGetServiceException()
- {
- try
- {
- $this->object->getService('unknow_service');
- $this->fail('should raise an exception');
- }
- catch (\Exception $e)
- {
-
- }
- }
-
- public function testWrite()
- {
- touch(__DIR__ . "/confTestFiles/yamlWriteTest.yml");
-
- $stub = $this->getMock(
- '\Alchemy\Phrasea\Core\Configuration\Application'
- , array('getConfigurationPathName')
- );
-
- $file = new \SplFileObject(__DIR__ . "/confTestFiles/yamlWriteTest.yml");
-
- $stub->expects($this->any())
- ->method('getConfigurationPathName')
- ->will(
- $this->returnValue($file->getPathname())
- );
-
- $handler = new Configuration\Handler($stub);
-
- $configuration = new PhraseaCore\Configuration($handler);
-
- $arrayToBeWritten = array(
- 'hello' => 'world'
- , 'key' => array(
- 'keyone' => 'valueone'
- , 'keytwo' => 'valuetwo'
- )
- );
-
- $configuration->write($arrayToBeWritten, 0, true);
-
- $all = $configuration->all();
-
- $this->assertArrayHasKey("hello", $all);
- $this->assertArrayHasKey("key", $all);
- $this->assertTrue(is_array($all["key"]));
- }
-
- public function testWriteException()
- {
- touch(__DIR__ . "/confTestFiles/yamlWriteTest.yml");
-
- $stub = $this->getMock(
- '\Alchemy\Phrasea\Core\Configuration\Application'
- , array('getConfigurationPathName')
- );
-
- $file = new \SplFileObject(__DIR__ . "/confTestFiles/yamlWriteTest.yml");
-
- $stub->expects($this->any())
- ->method('getConfigurationPathName')
- ->will(
- $this->returnValue("unknow_path")
- );
-
- $handler = new Configuration\Handler($stub);
-
- $configuration = new PhraseaCore\Configuration($handler);
-
- $arrayToBeWritten = array(
- 'hello' => 'world'
- , 'key' => array(
- 'keyone' => 'valueone'
- , 'keytwo' => 'valuetwo'
- )
- );
-
- try
- {
- $configuration->write($arrayToBeWritten);
- $this->fail("should raise an exception");
- }
- catch (\exception $e)
- {
-
- }
- }
-
- public function testDelete()
- {
- touch(__DIR__ . "/confTestFiles/yamlWriteTest.yml");
-
- $stub = $this->getMock(
- '\Alchemy\Phrasea\Core\Configuration\Application'
- , array('getConfigurationPathName')
- );
-
- $file = new \SplFileObject(__DIR__ . "/confTestFiles/yamlWriteTest.yml");
-
- $stub->expects($this->any())
- ->method('getConfigurationPathName')
- ->will(
- $this->returnValue($file->getPathname())
- );
-
- $handler = new Configuration\Handler($stub);
-
- $configuration = new PhraseaCore\Configuration($handler);
-
- $configuration->delete();
-
- $this->assertFileNotExists($file->getPathname());
- }
-
- public function testDeleteException()
- {
- touch(__DIR__ . "/confTestFiles/yamlWriteTest.yml");
-
- $stub = $this->getMock(
- '\Alchemy\Phrasea\Core\Configuration\Application'
- , array('getConfigurationPathName')
- );
-
- $file = new \SplFileObject(__DIR__ . "/confTestFiles/yamlWriteTest.yml");
-
- $stub->expects($this->any())
- ->method('getConfigurationPathName')
- ->will(
- $this->returnValue("unknow_path")
- );
-
- $handler = new Configuration\Handler($stub);
-
- $configuration = new PhraseaCore\Configuration($handler);
-
- try
- {
- $configuration->delete();
- $this->fail("should raise an exception");
- }
- catch (\Exception $e)
- {
+ $handler = new Configuration\Handler($specExperience);
+ $this->object = new PhraseaCore\Configuration($handler);
}
- $this->assertFileExists($file->getPathname());
-
- unlink(__DIR__ . "/confTestFiles/yamlWriteTest.yml");
- }
-
- public function testGetTemplating()
- {
- try
+ public function testGetEnvironment()
{
- $templating = $this->object->getTemplating();
- }
- catch (\Exception $e)
- {
- $this->fail("not template_engine provided");
- }
- $this->assertTrue(is_string($templating));
- }
-
- public function testGetOrm()
- {
- try
- {
- $orm = $this->object->getOrm();
- }
- catch (\Exception $e)
- {
- $this->fail("not template_engine provided");
- }
- $this->assertTrue(is_string($orm));
- }
-
- public function testGetServiceFile()
- {
- $this->assertInstanceOf("\SplFileObject", $this->object->getServiceFile());
- }
-
- public function testGetConnexionFile()
- {
- $this->assertInstanceOf("\SplFileObject", $this->object->getConnexionFile());
- }
-
- public function testRefresh()
- {
- $this->confNotInstalled->refresh();
- $this->assertFalse($this->confNotInstalled->isInstalled());
- $this->assertInstanceOf("\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag", $this->confNotInstalled->getConfiguration());
-
- touch(__DIR__ . "/confTestFiles/yamlWriteTest.yml");
-
- $stub = $this->getMock(
- '\Alchemy\Phrasea\Core\Configuration\Application'
- , array('getConfigurationPathName')
- );
-
- $file = new \SplFileObject(__DIR__ . "/confTestFiles/yamlWriteTest.yml");
-
- $stub->expects($this->any())
- ->method('getConfigurationPathName')
- ->will(
- $this->returnValue($file->getPathname())
- );
-
- $handler = new Configuration\Handler($stub);
-
- $configuration = new PhraseaCore\Configuration($handler);
-
- $newScope = array("prod" => array('key' => 'value', 'key2' => 'value2'));
-
- //append new conf
- $configuration->write($newScope, FILE_APPEND);
-
- try
- {
- $configuration->getConfiguration(); //it is not loaded
- $this->fail("should raise an exception");
- }
- catch (\Exception $e)
- {
-
+ $this->assertEquals("dev", $this->object->getEnvironnement());
+ $this->assertEquals(null, $this->confNotInstalled->getEnvironnement());
}
- $configuration->refresh(); //reload conf
- $prod = $configuration->getConfiguration();
- $this->assertInstanceOf("\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag", $prod);
+ public function testSetEnvironment()
+ {
+ $this->object->setEnvironnement("test");
+ $this->assertEquals("test", $this->object->getEnvironnement());
+ $this->confNotInstalled->setEnvironnement("prod");
+ $this->assertEquals("prod", $this->confNotInstalled->getEnvironnement());
- unlink(__DIR__ . "/confTestFiles/yamlWriteTest.yml");
- }
+ try {
+ $this->object->setEnvironnement("unknow");
+ $this->fail("should raise exception");
+ } catch (\Exception $e) {
+ }
+ }
+
+ public function testIsDebug()
+ {
+ $this->object->setEnvironnement("test");
+ $this->assertTrue($this->object->isDebug());
+ $this->object->setEnvironnement("dev");
+ $this->assertTrue($this->object->isDebug());
+ $this->object->setEnvironnement("prod");
+ $this->assertFalse($this->object->isDebug());
+ $this->object->setEnvironnement("no_debug");
+ $this->assertFalse($this->object->isDebug());
+ }
+
+ public function testIsMaintened()
+ {
+ $this->object->setEnvironnement("test");
+ $this->assertFalse($this->object->isMaintained());
+ $this->object->setEnvironnement("dev");
+ $this->assertFalse($this->object->isMaintained());
+ $this->object->setEnvironnement("prod");
+ $this->assertFalse($this->object->isMaintained());
+ $this->object->setEnvironnement("no_maintenance");
+ $this->assertFalse($this->object->isMaintained());
+ }
+
+ public function testIsDisplayingErrors()
+ {
+ $this->object->setEnvironnement("test");
+ $this->assertTrue($this->object->isDisplayingErrors());
+ $this->object->setEnvironnement("dev");
+ $this->assertTrue($this->object->isDisplayingErrors());
+ $this->object->setEnvironnement("prod");
+ $this->assertFalse($this->object->isDisplayingErrors());
+ $this->object->setEnvironnement("no_display_errors");
+ $this->assertFalse($this->object->isDisplayingErrors());
+ }
+
+ public function testGetPhraseanet()
+ {
+ $this->object->setEnvironnement("test");
+ $this->assertInstanceOf("\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag", $this->object->getPhraseanet());
+ $this->object->setEnvironnement("dev");
+ $this->assertInstanceOf("\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag", $this->object->getPhraseanet());
+ $this->object->setEnvironnement("prod");
+ $this->assertInstanceOf("\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag", $this->object->getPhraseanet());
+ $this->object->setEnvironnement("missing_phraseanet");
+ try {
+ $this->object->getPhraseanet();
+ $this->fail("should raise an exeception");
+ } catch (\Exception $e) {
+
+ }
+ }
+
+ public function testisInstalled()
+ {
+ $this->assertFalse($this->confNotInstalled->isInstalled());
+ $this->assertTrue($this->object->isInstalled());
+ }
+
+ public function testGetConfiguration()
+ {
+ $config = $this->object->getConfiguration();
+ $this->assertInstanceOf("\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag", $config);
+ $this->assertNotEmpty($config->all());
+ $config = $this->confNotInstalled->getConfiguration();
+ $this->assertEmpty($config->all());
+ }
+
+ public function testGetConnexions()
+ {
+ $connexions = $this->object->getConnexions();
+ $this->assertInstanceOf("\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag", $connexions);
+ $this->assertGreaterThan(0, sizeof($connexions->all()));
+ }
+
+ public function testGetConnexion()
+ {
+ $connexion = $this->object->getConnexion();
+ $this->assertInstanceOf("\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag", $connexion);
+ $this->assertGreaterThan(0, sizeof($connexion->all()));
+ }
+
+ public function testGetConnexionException()
+ {
+ try {
+ $this->object->getConnexion('unknow_connexion');
+ $this->fail('should raise an exception');
+ } catch (\Exception $e) {
+
+ }
+ }
+
+ public function testGetFile()
+ {
+ $this->assertInstanceOf("\SplFileObject", $this->object->getFile());
+ }
+
+ public function testGetFileExeption()
+ {
+ try {
+ $this->assertInstanceOf("\SplFileObject", $this->confNotInstalled->getFile());
+ $this->fail("should raise an excpetion");
+ } catch (\Exception $e) {
+
+ }
+ }
+
+ public function testAll()
+ {
+ $all = $this->object->all();
+ $this->assertTrue(is_array($all));
+ $this->assertArrayHasKey("test", $all);
+ $this->assertArrayHasKey("dev", $all);
+ $this->assertArrayHasKey("prod", $all);
+ $this->assertArrayHasKey("environment", $all);
+ }
+
+ public function testGetServices()
+ {
+ $services = $this->object->getServices();
+ $this->assertInstanceOf("\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag", $services);
+ $this->assertGreaterThan(0, sizeof($services->all()));
+ }
+
+ public function testGetService()
+ {
+ $services = $this->object->getService('TemplateEngine\Twig');
+ $this->assertInstanceOf("\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag", $services);
+ $this->assertGreaterThan(0, sizeof($services->all()));
+ }
+
+ public function testGetServiceException()
+ {
+ try {
+ $this->object->getService('unknow_service');
+ $this->fail('should raise an exception');
+ } catch (\Exception $e) {
+
+ }
+ }
+
+ public function testWrite()
+ {
+ touch(__DIR__ . "/confTestFiles/yamlWriteTest.yml");
+
+ $stub = $this->getMock(
+ '\Alchemy\Phrasea\Core\Configuration\Application'
+ , array('getConfigurationPathName')
+ );
+
+ $file = new \SplFileObject(__DIR__ . "/confTestFiles/yamlWriteTest.yml");
+
+ $stub->expects($this->any())
+ ->method('getConfigurationPathName')
+ ->will(
+ $this->returnValue($file->getPathname())
+ );
+
+ $handler = new Configuration\Handler($stub);
+
+ $configuration = new PhraseaCore\Configuration($handler);
+
+ $arrayToBeWritten = array(
+ 'hello' => 'world'
+ , 'key' => array(
+ 'keyone' => 'valueone'
+ , 'keytwo' => 'valuetwo'
+ )
+ );
+
+ $configuration->write($arrayToBeWritten, 0, true);
+
+ $all = $configuration->all();
+
+ $this->assertArrayHasKey("hello", $all);
+ $this->assertArrayHasKey("key", $all);
+ $this->assertTrue(is_array($all["key"]));
+ }
+
+ public function testWriteException()
+ {
+ touch(__DIR__ . "/confTestFiles/yamlWriteTest.yml");
+
+ $stub = $this->getMock(
+ '\Alchemy\Phrasea\Core\Configuration\Application'
+ , array('getConfigurationPathName')
+ );
+
+ $file = new \SplFileObject(__DIR__ . "/confTestFiles/yamlWriteTest.yml");
+
+ $stub->expects($this->any())
+ ->method('getConfigurationPathName')
+ ->will(
+ $this->returnValue("unknow_path")
+ );
+
+ $handler = new Configuration\Handler($stub);
+
+ $configuration = new PhraseaCore\Configuration($handler);
+
+ $arrayToBeWritten = array(
+ 'hello' => 'world'
+ , 'key' => array(
+ 'keyone' => 'valueone'
+ , 'keytwo' => 'valuetwo'
+ )
+ );
+
+ try {
+ $configuration->write($arrayToBeWritten);
+ $this->fail("should raise an exception");
+ } catch (\exception $e) {
+
+ }
+ }
+
+ public function testDelete()
+ {
+ touch(__DIR__ . "/confTestFiles/yamlWriteTest.yml");
+
+ $stub = $this->getMock(
+ '\Alchemy\Phrasea\Core\Configuration\Application'
+ , array('getConfigurationPathName')
+ );
+
+ $file = new \SplFileObject(__DIR__ . "/confTestFiles/yamlWriteTest.yml");
+
+ $stub->expects($this->any())
+ ->method('getConfigurationPathName')
+ ->will(
+ $this->returnValue($file->getPathname())
+ );
+
+ $handler = new Configuration\Handler($stub);
+
+ $configuration = new PhraseaCore\Configuration($handler);
+
+ $configuration->delete();
+
+ $this->assertFileNotExists($file->getPathname());
+ }
+
+ public function testDeleteException()
+ {
+ touch(__DIR__ . "/confTestFiles/yamlWriteTest.yml");
+
+ $stub = $this->getMock(
+ '\Alchemy\Phrasea\Core\Configuration\Application'
+ , array('getConfigurationPathName')
+ );
+
+ $file = new \SplFileObject(__DIR__ . "/confTestFiles/yamlWriteTest.yml");
+
+ $stub->expects($this->any())
+ ->method('getConfigurationPathName')
+ ->will(
+ $this->returnValue("unknow_path")
+ );
+
+ $handler = new Configuration\Handler($stub);
+
+ $configuration = new PhraseaCore\Configuration($handler);
+
+ try {
+ $configuration->delete();
+ $this->fail("should raise an exception");
+ } catch (\Exception $e) {
+
+ }
+
+ $this->assertFileExists($file->getPathname());
+
+ unlink(__DIR__ . "/confTestFiles/yamlWriteTest.yml");
+ }
+
+ public function testGetTemplating()
+ {
+ try {
+ $templating = $this->object->getTemplating();
+ } catch (\Exception $e) {
+ $this->fail("not template_engine provided");
+ }
+ $this->assertTrue(is_string($templating));
+ }
+
+ public function testGetOrm()
+ {
+ try {
+ $orm = $this->object->getOrm();
+ } catch (\Exception $e) {
+ $this->fail("not template_engine provided");
+ }
+ $this->assertTrue(is_string($orm));
+ }
+
+ public function testGetServiceFile()
+ {
+ $this->assertInstanceOf("\SplFileObject", $this->object->getServiceFile());
+ }
+
+ public function testGetConnexionFile()
+ {
+ $this->assertInstanceOf("\SplFileObject", $this->object->getConnexionFile());
+ }
+
+ public function testRefresh()
+ {
+ $this->confNotInstalled->refresh();
+ $this->assertFalse($this->confNotInstalled->isInstalled());
+ $this->assertInstanceOf("\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag", $this->confNotInstalled->getConfiguration());
+
+ touch(__DIR__ . "/confTestFiles/yamlWriteTest.yml");
+
+ $stub = $this->getMock(
+ '\Alchemy\Phrasea\Core\Configuration\Application'
+ , array('getConfigurationPathName')
+ );
+
+ $file = new \SplFileObject(__DIR__ . "/confTestFiles/yamlWriteTest.yml");
+
+ $stub->expects($this->any())
+ ->method('getConfigurationPathName')
+ ->will(
+ $this->returnValue($file->getPathname())
+ );
+
+ $handler = new Configuration\Handler($stub);
+
+ $configuration = new PhraseaCore\Configuration($handler);
+
+ $newScope = array("prod" => array('key' => 'value', 'key2' => 'value2'));
+
+ //append new conf
+ $configuration->write($newScope, FILE_APPEND);
+
+ try {
+ $configuration->getConfiguration(); //it is not loaded
+ $this->fail("should raise an exception");
+ } catch (\Exception $e) {
+
+ }
+
+ $configuration->refresh(); //reload conf
+ $prod = $configuration->getConfiguration();
+ $this->assertInstanceOf("\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag", $prod);
+
+ unlink(__DIR__ . "/confTestFiles/yamlWriteTest.yml");
+ }
}
diff --git a/tests/Alchemy/Phrasea/Core/Service/Cache/ApcCacheTest.php b/tests/Alchemy/Phrasea/Core/Service/Cache/ApcCacheTest.php
index 051234b261..484f333fe8 100644
--- a/tests/Alchemy/Phrasea/Core/Service/Cache/ApcCacheTest.php
+++ b/tests/Alchemy/Phrasea/Core/Service/Cache/ApcCacheTest.php
@@ -1,74 +1,49 @@
getDriver();
- $this->assertTrue($service instanceof \Doctrine\Common\Cache\CacheProvider);
+ $cache = new \Alchemy\Phrasea\Core\Service\Cache\ApcCache(
+ self::$core, array()
+ );
+
+ if (extension_loaded('apc')) {
+ $service = $cache->getDriver();
+ $this->assertTrue($service instanceof \Doctrine\Common\Cache\CacheProvider);
+ } else {
+ try {
+ $cache->getDriver();
+ $this->fail("should raise an exception");
+ } catch (\Exception $e) {
+
+ }
+ }
}
- else
+
+ public function testServiceException()
{
- try
- {
- $cache->getDriver();
- $this->fail("should raise an exception");
- }
- catch (\Exception $e)
- {
+ $cache = new \Alchemy\Phrasea\Core\Service\Cache\ApcCache(
+ self::$core, array()
+ );
- }
+ try {
+ $cache->getDriver();
+ $this->fail("should raise an exception");
+ } catch (\Exception $e) {
+
+ }
}
- }
- public function testServiceException()
- {
- $cache = new \Alchemy\Phrasea\Core\Service\Cache\ApcCache(
- self::$core, array()
- );
-
- try
+ public function testType()
{
- $cache->getDriver();
- $this->fail("should raise an exception");
+ $cache = new \Alchemy\Phrasea\Core\Service\Cache\ApcCache(
+ self::$core, array()
+ );
+
+ $this->assertEquals("apc", $cache->getType());
}
- catch (\Exception $e)
- {
-
- }
- }
-
- public function testType()
- {
- $cache = new \Alchemy\Phrasea\Core\Service\Cache\ApcCache(
- self::$core, array()
- );
-
- $this->assertEquals("apc", $cache->getType());
- }
-
}
diff --git a/tests/Alchemy/Phrasea/Core/Service/Cache/ArrayCacheTest.php b/tests/Alchemy/Phrasea/Core/Service/Cache/ArrayCacheTest.php
index 3b76d13503..7fe4066de1 100644
--- a/tests/Alchemy/Phrasea/Core/Service/Cache/ArrayCacheTest.php
+++ b/tests/Alchemy/Phrasea/Core/Service/Cache/ArrayCacheTest.php
@@ -1,59 +1,40 @@
getDriver();
- $this->assertTrue($service instanceof \Doctrine\Common\Cache\CacheProvider);
- }
-
- public function testServiceException()
- {
- $cache = new \Alchemy\Phrasea\Core\Service\Cache\ArrayCache(
- self::$core, array()
- );
-
- try
+ public function testService()
{
- $cache->getDriver();
- $this->fail("should raise an exception");
+ $cache = new \Alchemy\Phrasea\Core\Service\Cache\ArrayCache(
+ self::$core, array()
+ );
+
+ $service = $cache->getDriver();
+ $this->assertTrue($service instanceof \Doctrine\Common\Cache\CacheProvider);
}
- catch (\Exception $e)
+
+ public function testServiceException()
{
+ $cache = new \Alchemy\Phrasea\Core\Service\Cache\ArrayCache(
+ self::$core, array()
+ );
+ try {
+ $cache->getDriver();
+ $this->fail("should raise an exception");
+ } catch (\Exception $e) {
+
+ }
}
- }
- public function testType()
- {
- $cache = new \Alchemy\Phrasea\Core\Service\Cache\ArrayCache(
- self::$core, array()
- );
-
- $this->assertEquals("array", $cache->getType());
- }
+ public function testType()
+ {
+ $cache = new \Alchemy\Phrasea\Core\Service\Cache\ArrayCache(
+ self::$core, array()
+ );
+ $this->assertEquals("array", $cache->getType());
+ }
}
diff --git a/tests/Alchemy/Phrasea/Core/Service/Cache/MemcacheCacheTest.php b/tests/Alchemy/Phrasea/Core/Service/Cache/MemcacheCacheTest.php
index 60c2b9750f..f129d3c890 100644
--- a/tests/Alchemy/Phrasea/Core/Service/Cache/MemcacheCacheTest.php
+++ b/tests/Alchemy/Phrasea/Core/Service/Cache/MemcacheCacheTest.php
@@ -1,92 +1,67 @@
getDriver();
- $this->assertTrue($service instanceof \Doctrine\Common\Cache\CacheProvider);
+ $cache = new \Alchemy\Phrasea\Core\Service\Cache\MemcacheCache(
+ self::$core, array()
+ );
+
+ if (extension_loaded('memcache')) {
+ $service = $cache->getDriver();
+ $this->assertTrue($service instanceof \Doctrine\Common\Cache\CacheProvider);
+ } else {
+ try {
+ $cache->getDriver();
+ $this->fail("should raise an exception");
+ } catch (\Exception $e) {
+
+ }
+ }
}
- else
+
+ public function testServiceException()
{
- try
- {
- $cache->getDriver();
- $this->fail("should raise an exception");
- }
- catch (\Exception $e)
- {
+ $cache = new \Alchemy\Phrasea\Core\Service\Cache\MemcacheCache(
+ self::$core, array()
+ );
- }
+ try {
+ $cache->getDriver();
+ $this->fail("should raise an exception");
+ } catch (\Exception $e) {
+
+ }
}
- }
- public function testServiceException()
- {
- $cache = new \Alchemy\Phrasea\Core\Service\Cache\MemcacheCache(
- self::$core, array()
- );
-
- try
+ public function testType()
{
- $cache->getDriver();
- $this->fail("should raise an exception");
+ $cache = new \Alchemy\Phrasea\Core\Service\Cache\MemcacheCache(
+ self::$core, array()
+ );
+
+ $this->assertEquals("memcache", $cache->getType());
}
- catch (\Exception $e)
+
+ public function testHost()
{
+ $cache = new \Alchemy\Phrasea\Core\Service\Cache\MemcacheCache(
+ self::$core, array()
+ );
+ $this->assertEquals(\Alchemy\Phrasea\Core\Service\Cache\MemcacheCache::DEFAULT_HOST, $cache->getHost());
}
- }
- public function testType()
- {
- $cache = new \Alchemy\Phrasea\Core\Service\Cache\MemcacheCache(
- self::$core, array()
- );
-
- $this->assertEquals("memcache", $cache->getType());
- }
-
- public function testHost()
- {
- $cache = new \Alchemy\Phrasea\Core\Service\Cache\MemcacheCache(
- self::$core, array()
- );
-
- $this->assertEquals(\Alchemy\Phrasea\Core\Service\Cache\MemcacheCache::DEFAULT_HOST, $cache->getHost());
- }
-
- public function testPort()
- {
- $cache = new \Alchemy\Phrasea\Core\Service\Cache\MemcacheCache(
- self::$core, array()
- );
-
- $this->assertEquals(\Alchemy\Phrasea\Core\Service\Cache\MemcacheCache::DEFAULT_PORT, $cache->getPort());
- }
+ public function testPort()
+ {
+ $cache = new \Alchemy\Phrasea\Core\Service\Cache\MemcacheCache(
+ self::$core, array()
+ );
+ $this->assertEquals(\Alchemy\Phrasea\Core\Service\Cache\MemcacheCache::DEFAULT_PORT, $cache->getPort());
+ }
}
diff --git a/tests/Alchemy/Phrasea/Core/Service/Cache/XcacheCacheTest.php b/tests/Alchemy/Phrasea/Core/Service/Cache/XcacheCacheTest.php
index af18fd919b..3f5cf0dded 100644
--- a/tests/Alchemy/Phrasea/Core/Service/Cache/XcacheCacheTest.php
+++ b/tests/Alchemy/Phrasea/Core/Service/Cache/XcacheCacheTest.php
@@ -1,74 +1,49 @@
getDriver();
- $this->assertTrue($service instanceof \Doctrine\Common\Cache\CacheProvider);
+ $cache = new \Alchemy\Phrasea\Core\Service\Cache\XcacheCache(
+ self::$core, array()
+ );
+
+ if (extension_loaded('xcache')) {
+ $service = $cache->getDriver();
+ $this->assertTrue($service instanceof \Doctrine\Common\Cache\CacheProvider);
+ } else {
+ try {
+ $cache->getDriver();
+ $this->fail("should raise an exception");
+ } catch (\Exception $e) {
+
+ }
+ }
}
- else
+
+ public function testServiceException()
{
- try
- {
- $cache->getDriver();
- $this->fail("should raise an exception");
- }
- catch(\Exception $e)
- {
+ $cache = new \Alchemy\Phrasea\Core\Service\Cache\XcacheCache(
+ self::$core, array()
+ );
- }
+ try {
+ $cache->getDriver();
+ $this->fail("should raise an exception");
+ } catch (\Exception $e) {
+
+ }
}
- }
- public function testServiceException()
- {
- $cache = new \Alchemy\Phrasea\Core\Service\Cache\XcacheCache(
- self::$core, array()
- );
-
- try
+ public function testType()
{
- $cache->getDriver();
- $this->fail("should raise an exception");
+ $cache = new \Alchemy\Phrasea\Core\Service\Cache\XcacheCache(
+ self::$core, array()
+ );
+
+ $this->assertEquals("xcache", $cache->getType());
}
- catch (\Exception $e)
- {
-
- }
- }
-
- public function testType()
- {
- $cache = new \Alchemy\Phrasea\Core\Service\Cache\XcacheCache(
- self::$core, array()
- );
-
- $this->assertEquals("xcache", $cache->getType());
- }
-
}
diff --git a/tests/Alchemy/Phrasea/Core/Service/Log/Doctrine/MonologTest.php b/tests/Alchemy/Phrasea/Core/Service/Log/Doctrine/MonologTest.php
index 20c2829939..a675246208 100644
--- a/tests/Alchemy/Phrasea/Core/Service/Log/Doctrine/MonologTest.php
+++ b/tests/Alchemy/Phrasea/Core/Service/Log/Doctrine/MonologTest.php
@@ -1,71 +1,46 @@
"rotate"
- , "filename" => "test"
- , 'output' => 'json'
- , 'channel' => 'test'
+ protected $options = array(
+ "handler" => "rotate"
+ , "filename" => "test"
+ , 'output' => 'json'
+ , 'channel' => 'test'
);
- public function setUp()
- {
- parent::setUp();
- }
-
- public function testService()
- {
-
- $log = new \Alchemy\Phrasea\Core\Service\Log\Doctrine\Monolog(
- self::$core, $this->options
- );
-
- $this->assertInstanceOf("\Doctrine\Logger\MonologSQLLogger", $log->getDriver());
- }
-
- public function testType()
- {
- $log = new \Alchemy\Phrasea\Core\Service\Log\Doctrine\Monolog(
- self::$core, $this->options
- );
-
- $this->assertEquals("doctrine_monolog", $log->getType());
- }
-
- public function testExceptionBadOutput()
- {
- try
- {
- $this->options["output"] = "unknowOutput";
- $log = new \Alchemy\Phrasea\Core\Service\Log\Doctrine\Monolog(
- self::$core, $this->options
- );
- $log->getDriver();
- $this->fail("should raise an exception");
- }
- catch (\Exception $e)
+ public function testService()
{
- }
- }
+ $log = new \Alchemy\Phrasea\Core\Service\Log\Doctrine\Monolog(
+ self::$core, $this->options
+ );
+ $this->assertInstanceOf("\Doctrine\Logger\MonologSQLLogger", $log->getDriver());
+ }
+
+ public function testType()
+ {
+ $log = new \Alchemy\Phrasea\Core\Service\Log\Doctrine\Monolog(
+ self::$core, $this->options
+ );
+
+ $this->assertEquals("doctrine_monolog", $log->getType());
+ }
+
+ public function testExceptionBadOutput()
+ {
+ try {
+ $this->options["output"] = "unknowOutput";
+ $log = new \Alchemy\Phrasea\Core\Service\Log\Doctrine\Monolog(
+ self::$core, $this->options
+ );
+ $log->getDriver();
+ $this->fail("should raise an exception");
+ } catch (\Exception $e) {
+
+ }
+ }
}
diff --git a/tests/Alchemy/Phrasea/Core/Service/Log/Doctrine/PhpechoTest.php b/tests/Alchemy/Phrasea/Core/Service/Log/Doctrine/PhpechoTest.php
index ebb4b9f950..676e6aabae 100644
--- a/tests/Alchemy/Phrasea/Core/Service/Log/Doctrine/PhpechoTest.php
+++ b/tests/Alchemy/Phrasea/Core/Service/Log/Doctrine/PhpechoTest.php
@@ -1,42 +1,25 @@
assertInstanceOf("\Doctrine\DBAL\Logging\EchoSQLLogger", $log->getDriver());
+ }
- $this->assertInstanceOf("\Doctrine\DBAL\Logging\EchoSQLLogger", $log->getDriver());
- }
-
- public function testType()
- {
- $log = new \Alchemy\Phrasea\Core\Service\Log\Doctrine\Phpecho(
- self::$core, array()
- );
-
- $this->assertEquals("phpecho", $log->getType());
- }
+ public function testType()
+ {
+ $log = new \Alchemy\Phrasea\Core\Service\Log\Doctrine\Phpecho(
+ self::$core, array()
+ );
+ $this->assertEquals("phpecho", $log->getType());
+ }
}
diff --git a/tests/Alchemy/Phrasea/Core/Service/Log/MonologTest.php b/tests/Alchemy/Phrasea/Core/Service/Log/MonologTest.php
index 4ce16b5aae..8a097d41a1 100644
--- a/tests/Alchemy/Phrasea/Core/Service/Log/MonologTest.php
+++ b/tests/Alchemy/Phrasea/Core/Service/Log/MonologTest.php
@@ -1,127 +1,97 @@
options = array(
- "handler" => "rotate"
- , "filename" => "test"
- , "channel" => "test"
- );
- }
-
-
- public function testService()
- {
- $log = new \Alchemy\Phrasea\Core\Service\Log\Monolog(
- self::$core, $this->options
- );
-
- $this->assertInstanceOf("\Monolog\Logger", $log->getDriver());
- }
-
- public function testType()
- {
- $log = new \Alchemy\Phrasea\Core\Service\Log\Monolog(
- self::$core, $this->options
- );
-
- $this->assertEquals("monolog", $log->getType());
- }
-
- public function testExceptionMissingOptions()
- {
- try
+ public function setUp()
{
- $log = new \Alchemy\Phrasea\Core\Service\Log\Monolog(
- self::$core, $this->options
- );
- $this->fail("should raise an exception");
+ parent::setUp();
+ $this->options = array(
+ "handler" => "rotate"
+ , "filename" => "test"
+ , "channel" => "test"
+ );
}
- catch (\Exception $e)
+
+ public function testService()
+ {
+ $log = new \Alchemy\Phrasea\Core\Service\Log\Monolog(
+ self::$core, $this->options
+ );
+
+ $this->assertInstanceOf("\Monolog\Logger", $log->getDriver());
+ }
+
+ public function testType()
+ {
+ $log = new \Alchemy\Phrasea\Core\Service\Log\Monolog(
+ self::$core, $this->options
+ );
+
+ $this->assertEquals("monolog", $log->getType());
+ }
+
+ public function testExceptionMissingOptions()
+ {
+ try {
+ $log = new \Alchemy\Phrasea\Core\Service\Log\Monolog(
+ self::$core, $this->options
+ );
+ $this->fail("should raise an exception");
+ } catch (\Exception $e) {
+
+ }
+ }
+
+ public function testExceptionMissingHandler()
+ {
+ try {
+ unset($this->options["handler"]);
+ $log = new \Alchemy\Phrasea\Core\Service\Log\Monolog(
+ self::$core, $this->options
+ );
+ $this->fail("should raise an exception");
+ } catch (\Exception $e) {
+
+ }
+ }
+
+ public function testExceptionUnknowHandler()
+ {
+ try {
+ $this->options["handler"] = "unknowHandler";
+ $log = new \Alchemy\Phrasea\Core\Service\Log\Monolog(
+ self::$core, $this->options
+ );
+ $this->fail("should raise an exception");
+ } catch (\Exception $e) {
+
+ }
+ }
+
+ public function testMissingFile()
+ {
+ try {
+ unset($this->options["filename"]);
+ $log = new \Alchemy\Phrasea\Core\Service\Log\Monolog(
+ self::$core, $this->options
+ );
+ $this->fail("should raise an exception");
+ } catch (\Exception $e) {
+
+ }
+ }
+
+ public function testStreamLogger()
{
+ $this->options["handler"] = "stream";
+ $log = new \Alchemy\Phrasea\Core\Service\Log\Monolog(
+ self::$core, $this->options
+ );
+ $this->assertInstanceOf("\Monolog\Logger", $log->getDriver());
}
- }
-
- public function testExceptionMissingHandler()
- {
- try
- {
- unset($this->options["handler"]);
- $log = new \Alchemy\Phrasea\Core\Service\Log\Monolog(
- self::$core, $this->options
- );
- $this->fail("should raise an exception");
- }
- catch (\Exception $e)
- {
-
- }
- }
-
- public function testExceptionUnknowHandler()
- {
- try
- {
- $this->options["handler"] = "unknowHandler";
- $log = new \Alchemy\Phrasea\Core\Service\Log\Monolog(
- self::$core, $this->options
- );
- $this->fail("should raise an exception");
- }
- catch (\Exception $e)
- {
-
- }
- }
-
- public function testMissingFile()
- {
- try
- {
- unset($this->options["filename"]);
- $log = new \Alchemy\Phrasea\Core\Service\Log\Monolog(
- self::$core, $this->options
- );
- $this->fail("should raise an exception");
- }
- catch (\Exception $e)
- {
-
- }
- }
-
- public function testStreamLogger()
- {
-
- $this->options["handler"] = "stream";
- $log = new \Alchemy\Phrasea\Core\Service\Log\Monolog(
- self::$core, $this->options
- );
- $this->assertInstanceOf("\Monolog\Logger", $log->getDriver());
- }
-
}
diff --git a/tests/Alchemy/Phrasea/Core/Service/Orm/DoctrineTest.php b/tests/Alchemy/Phrasea/Core/Service/Orm/DoctrineTest.php
index 3f732cb07e..59f03e8601 100644
--- a/tests/Alchemy/Phrasea/Core/Service/Orm/DoctrineTest.php
+++ b/tests/Alchemy/Phrasea/Core/Service/Orm/DoctrineTest.php
@@ -1,222 +1,182 @@
options = array(
- "debug" => false
- , "log" => array('service' => "Log\\sql_logger")
- , "dbal" => "main_connexion"
- , "cache" => array(
- "metadata" => array('service' => "Cache\\array_cache")
- , "query" => array('service' => "Cache\\array_cache")
- , "result" => array('service' => "Cache\\array_cache")
- )
- );
- }
-
- public function testService()
- {
- $doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
- self::$core, $this->options
- );
-
- $this->assertInstanceOf("\Doctrine\ORM\EntityManager", $doctrine->getDriver());
- }
-
- public function testType()
- {
- $doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
- self::$core, $this->options
- );
-
- $this->assertEquals("doctrine", $doctrine->getType());
- }
-
- public function testExceptionMissingOptions()
- {
- try
+ public function setUp()
{
- $doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
- self::$core, $this->options
- );
- $this->fail("should raise an exception");
- }
- catch (\Exception $e)
- {
-
- }
- }
-
- public function testNoCacheInOptions()
- {
- $this->markTestSkipped('To rewrite');
- unset($this->options["cache"]);
- $doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
- self::$core, $this->options
- );
-
- foreach ($doctrine->getCacheServices()->all() as $service)
- {
- $this->assertEquals("array", $service->getType());
- }
- }
-
- public function testUnknowCache()
- {
- $this->options["cache"]["result"] = "unknowCache";
-
- try
- {
- $doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
- self::$core, $this->options
- );
- $this->fail("An exception should be raised");
- }
- catch (\Exception $e)
- {
-
- }
- }
-
- public function testIsDebug()
- {
- $doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
- self::$core, $this->options
- );
-
- $this->assertFalse($doctrine->isDebug());
-
- $this->options['debug'] = true;
- $doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
- self::$core, $this->options
- );
-
- $this->assertTrue($doctrine->isDebug());
- }
-
- public function testGetCacheServices()
- {
- $this->markTestSkipped('To rewrite');
- $doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
- self::$core, $this->options
- );
- $this->assertInstanceOf("\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag"
- , $doctrine->getCacheServices());
-
- foreach ($doctrine->getCacheServices()->all() as $service)
- {
- $this->assertEquals("array", $service->getType());
- }
-
- $this->options['orm']["cache"] = array(
- "metadata" => "array_cache"
- , "query" => "apc_cache"
- , "result" => "xcache_cache"
- );
-
- if (extension_loaded("apc") && extension_loaded("xcache"))
- {
- $doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
- self::$core, $this->options
- );
- $this->assertInstanceOf("\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag"
- , $doctrine->getCacheServices());
-
- foreach ($doctrine->getCacheServices()->all() as $key => $service)
- {
- if ($key === "metadata")
- $this->assertEquals("array", $service->getType());
- elseif ($key === "query")
- $this->assertEquals("apc", $service->getType());
- elseif ($key === "result")
- $this->assertEquals("xcache", $service->getType());
- }
- }
- else
- {
- try
- {
- $doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
- self::$core, $this->options
+ parent::setUp();
+ $this->options = array(
+ "debug" => false
+ , "log" => array('service' => "Log\\sql_logger")
+ , "dbal" => "main_connexion"
+ , "cache" => array(
+ "metadata" => array('service' => "Cache\\array_cache")
+ , "query" => array('service' => "Cache\\array_cache")
+ , "result" => array('service' => "Cache\\array_cache")
+ )
);
- $this->fail("An exception should be raised");
- }
- catch (\Exception $e)
- {
-
- }
}
- }
- public function testExceptionUnknowLogService()
- {
- try
+ public function testService()
{
- $this->options["log"] = "unknowLogger";
- $doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
- self::$core, $this->options
- );
- $this->fail("should raise an exception");
+ $doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
+ self::$core, $this->options
+ );
+
+ $this->assertInstanceOf("\Doctrine\ORM\EntityManager", $doctrine->getDriver());
}
- catch (\Exception $e)
+
+ public function testType()
{
+ $doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
+ self::$core, $this->options
+ );
+ $this->assertEquals("doctrine", $doctrine->getType());
}
- }
- public function testExceptionMissingDbal()
- {
- try
+ public function testExceptionMissingOptions()
{
- unset($this->options["dbal"]);
- $doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
- self::$core, $this->options
- );
- $this->fail("should raise an exception");
+ try {
+ $doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
+ self::$core, $this->options
+ );
+ $this->fail("should raise an exception");
+ } catch (\Exception $e) {
+
+ }
}
- catch (\Exception $e)
+
+ public function testNoCacheInOptions()
{
+ $this->markTestSkipped('To rewrite');
+ unset($this->options["cache"]);
+ $doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
+ self::$core, $this->options
+ );
+ foreach ($doctrine->getCacheServices()->all() as $service) {
+ $this->assertEquals("array", $service->getType());
+ }
}
- }
- public function testExceptionUnknowDbal()
- {
- try
+ public function testUnknowCache()
{
- $this->options["dbal"] = "unknowDbal";
- $doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
- self::$core, $this->options
- );
- $this->fail("should raise an exception");
+ $this->options["cache"]["result"] = "unknowCache";
+
+ try {
+ $doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
+ self::$core, $this->options
+ );
+ $this->fail("An exception should be raised");
+ } catch (\Exception $e) {
+
+ }
}
- catch (\Exception $e)
+
+ public function testIsDebug()
{
+ $doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
+ self::$core, $this->options
+ );
+ $this->assertFalse($doctrine->isDebug());
+
+ $this->options['debug'] = true;
+ $doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
+ self::$core, $this->options
+ );
+
+ $this->assertTrue($doctrine->isDebug());
}
- }
+ public function testGetCacheServices()
+ {
+ $this->markTestSkipped('To rewrite');
+ $doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
+ self::$core, $this->options
+ );
+ $this->assertInstanceOf("\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag"
+ , $doctrine->getCacheServices());
+
+ foreach ($doctrine->getCacheServices()->all() as $service) {
+ $this->assertEquals("array", $service->getType());
+ }
+
+ $this->options['orm']["cache"] = array(
+ "metadata" => "array_cache"
+ , "query" => "apc_cache"
+ , "result" => "xcache_cache"
+ );
+
+ if (extension_loaded("apc") && extension_loaded("xcache")) {
+ $doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
+ self::$core, $this->options
+ );
+ $this->assertInstanceOf("\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag"
+ , $doctrine->getCacheServices());
+
+ foreach ($doctrine->getCacheServices()->all() as $key => $service) {
+ if ($key === "metadata")
+ $this->assertEquals("array", $service->getType());
+ elseif ($key === "query")
+ $this->assertEquals("apc", $service->getType());
+ elseif ($key === "result")
+ $this->assertEquals("xcache", $service->getType());
+ }
+ }
+ else {
+ try {
+ $doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
+ self::$core, $this->options
+ );
+ $this->fail("An exception should be raised");
+ } catch (\Exception $e) {
+
+ }
+ }
+ }
+
+ public function testExceptionUnknowLogService()
+ {
+ try {
+ $this->options["log"] = "unknowLogger";
+ $doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
+ self::$core, $this->options
+ );
+ $this->fail("should raise an exception");
+ } catch (\Exception $e) {
+
+ }
+ }
+
+ public function testExceptionMissingDbal()
+ {
+ try {
+ unset($this->options["dbal"]);
+ $doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
+ self::$core, $this->options
+ );
+ $this->fail("should raise an exception");
+ } catch (\Exception $e) {
+
+ }
+ }
+
+ public function testExceptionUnknowDbal()
+ {
+ try {
+ $this->options["dbal"] = "unknowDbal";
+ $doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
+ self::$core, $this->options
+ );
+ $this->fail("should raise an exception");
+ } catch (\Exception $e) {
+
+ }
+ }
}
diff --git a/tests/Alchemy/Phrasea/Core/Service/ServiceAbtractTest.php b/tests/Alchemy/Phrasea/Core/Service/ServiceAbtractTest.php
index 4eda06158e..34320db7c6 100644
--- a/tests/Alchemy/Phrasea/Core/Service/ServiceAbtractTest.php
+++ b/tests/Alchemy/Phrasea/Core/Service/ServiceAbtractTest.php
@@ -1,49 +1,32 @@
getMockForAbstractClass(
+ public function setUp()
+ {
+ parent::setUp();
+ $stub = $this->getMockForAbstractClass(
"\Alchemy\Phrasea\Core\Service\ServiceAbstract"
, array(
- self::$core
- , array('option' => 'my_options')
+ self::$core
+ , array('option' => 'my_options')
)
- );
+ );
- $this->object = $stub;
- }
-
- public function testGetOptions()
- {
- $this->assertTrue(is_array($this->object->getOptions()));
- $this->assertEquals(array('option' => 'my_options'), $this->object->getOptions());
- }
+ $this->object = $stub;
+ }
+ public function testGetOptions()
+ {
+ $this->assertTrue(is_array($this->object->getOptions()));
+ $this->assertEquals(array('option' => 'my_options'), $this->object->getOptions());
+ }
}
diff --git a/tests/Alchemy/Phrasea/Core/Service/TemplateEngine/TwigTest.php b/tests/Alchemy/Phrasea/Core/Service/TemplateEngine/TwigTest.php
index 49fc8de7c4..7c8aa30e1c 100644
--- a/tests/Alchemy/Phrasea/Core/Service/TemplateEngine/TwigTest.php
+++ b/tests/Alchemy/Phrasea/Core/Service/TemplateEngine/TwigTest.php
@@ -1,64 +1,47 @@
options = array(
+ 'debug' => true
+ , 'charset' => 'utf-8'
+ , 'strict_variables' => true
+ , 'autoescape' => true
+ , 'optimizer' => true
+ );
+ }
- public function setUp()
- {
- parent::setUp();
- $this->options = array(
- 'debug' => true
- ,'charset' => 'utf-8'
- ,'strict_variables' => true
- ,'autoescape' => true
- ,'optimizer' => true
- );
- }
+ public function testService()
+ {
+ $doctrine = new \Alchemy\Phrasea\Core\Service\TemplateEngine\Twig(
+ self::$core, $this->options
+ );
- public function testService()
- {
- $doctrine = new \Alchemy\Phrasea\Core\Service\TemplateEngine\Twig(
- self::$core, $this->options
- );
+ $this->assertInstanceOf("\Twig_Environment", $doctrine->getDriver());
+ }
- $this->assertInstanceOf("\Twig_Environment", $doctrine->getDriver());
- }
+ public function testServiceExcpetion()
+ {
+ $doctrine = new \Alchemy\Phrasea\Core\Service\TemplateEngine\Twig(
+ self::$core, $this->options
+ );
- public function testServiceExcpetion()
- {
- $doctrine = new \Alchemy\Phrasea\Core\Service\TemplateEngine\Twig(
- self::$core, $this->options
- );
+ $this->assertInstanceOf("\Twig_Environment", $doctrine->getDriver());
+ }
- $this->assertInstanceOf("\Twig_Environment", $doctrine->getDriver());
- }
-
- public function testType()
- {
- $doctrine = new \Alchemy\Phrasea\Core\Service\TemplateEngine\Twig(
- self::$core, $this->options
- );
-
- $this->assertEquals("twig", $doctrine->getType());
- }
+ public function testType()
+ {
+ $doctrine = new \Alchemy\Phrasea\Core\Service\TemplateEngine\Twig(
+ self::$core, $this->options
+ );
+ $this->assertEquals("twig", $doctrine->getType());
+ }
}
diff --git a/tests/Alchemy/Phrasea/Core/ServiceBuilder/AbstractBuilderTest.php b/tests/Alchemy/Phrasea/Core/ServiceBuilder/AbstractBuilderTest.php
index 5c4978e67a..35c3141f1c 100644
--- a/tests/Alchemy/Phrasea/Core/ServiceBuilder/AbstractBuilderTest.php
+++ b/tests/Alchemy/Phrasea/Core/ServiceBuilder/AbstractBuilderTest.php
@@ -1,63 +1,41 @@
getMock(
- "\Alchemy\Phrasea\Core\Service\Builder"
- , array(
- self::$core
- , ''
- , new \Symfony\Component\DependencyInjection\ParameterBag\ParameterBag()
- )
- );
- $this->fail("should raise an exception");
+ try {
+ $stub = $this->getMock(
+ "\Alchemy\Phrasea\Core\Service\Builder"
+ , array(
+ self::$core
+ , ''
+ , new \Symfony\Component\DependencyInjection\ParameterBag\ParameterBag()
+ )
+ );
+ $this->fail("should raise an exception");
+ } catch (\Exception $e) {
+
+ }
}
- catch (\Exception $e)
+
+ public function testConstructExceptionCreate()
{
+ try {
+ $stub = $this->getMock(
+ "\\Alchemy\\Phrasea\\Core\\Service\\Builder"
+ , array(
+ self::$core,
+ 'test',
+ new \Symfony\Component\DependencyInjection\ParameterBag\ParameterBag(),
+ )
+ );
+ $this->fail("should raise an exception");
+ } catch (\Exception $e) {
+ }
}
- }
-
- public function testConstructExceptionCreate()
- {
- try
- {
- $stub = $this->getMock(
- "\\Alchemy\\Phrasea\\Core\\Service\\Builder"
- , array(
- self::$core,
- 'test',
- new \Symfony\Component\DependencyInjection\ParameterBag\ParameterBag(),
- )
- );
- $this->fail("should raise an exception");
- }
- catch (\Exception $e)
- {
-
- }
- }
-
}
diff --git a/tests/Alchemy/Phrasea/Core/ServiceBuilder/CacheBuilderTest.php b/tests/Alchemy/Phrasea/Core/ServiceBuilder/CacheBuilderTest.php
index b72c3a89af..ea12becd15 100644
--- a/tests/Alchemy/Phrasea/Core/ServiceBuilder/CacheBuilderTest.php
+++ b/tests/Alchemy/Phrasea/Core/ServiceBuilder/CacheBuilderTest.php
@@ -1,50 +1,31 @@
"unknow")
- );
-
- try
+ public function testCreateException()
{
- $service = Alchemy\Phrasea\Core\Service\Builder::create(self::$core, $configuration);
- $this->fail("An exception should be raised");
+ $configuration = new Symfony\Component\DependencyInjection\ParameterBag\ParameterBag(
+ array("type" => "unknow")
+ );
+
+ try {
+ $service = Alchemy\Phrasea\Core\Service\Builder::create(self::$core, $configuration);
+ $this->fail("An exception should be raised");
+ } catch (\Exception $e) {
+
+ }
}
- catch (\Exception $e)
+
+ public function testCreate()
{
+ $configuration = new Symfony\Component\DependencyInjection\ParameterBag\ParameterBag(
+ array("type" => "Cache\\ArrayCache")
+ );
+ $service = Alchemy\Phrasea\Core\Service\Builder::create(self::$core, $configuration);
+ $this->assertInstanceOf("\Alchemy\Phrasea\Core\Service\ServiceAbstract", $service);
}
- }
-
- public function testCreate()
- {
- $configuration = new Symfony\Component\DependencyInjection\ParameterBag\ParameterBag(
- array("type" => "Cache\\ArrayCache")
- );
-
- $service = Alchemy\Phrasea\Core\Service\Builder::create(self::$core, $configuration);
- $this->assertInstanceOf("\Alchemy\Phrasea\Core\Service\ServiceAbstract", $service);
- }
-
}
diff --git a/tests/Alchemy/Phrasea/Core/ServiceBuilder/LogBuilderTest.php b/tests/Alchemy/Phrasea/Core/ServiceBuilder/LogBuilderTest.php
index ac71b8851c..90e631231b 100644
--- a/tests/Alchemy/Phrasea/Core/ServiceBuilder/LogBuilderTest.php
+++ b/tests/Alchemy/Phrasea/Core/ServiceBuilder/LogBuilderTest.php
@@ -1,67 +1,48 @@
"unknow", "options" => array())
- );
-
- try
+ public function testCreateException()
{
- $service = Alchemy\Phrasea\Core\Service\Builder::create(self::$core, $configuration);
- $this->fail("An exception should be raised");
+ $configuration = new Symfony\Component\DependencyInjection\ParameterBag\ParameterBag(
+ array("type" => "unknow", "options" => array())
+ );
+
+ try {
+ $service = Alchemy\Phrasea\Core\Service\Builder::create(self::$core, $configuration);
+ $this->fail("An exception should be raised");
+ } catch (\Exception $e) {
+
+ }
}
- catch (\Exception $e)
+
+ public function testCreate()
{
+ $configuration = new Symfony\Component\DependencyInjection\ParameterBag\ParameterBag(
+ array("type" => "Log\\Doctrine\\Monolog", "options" => array(
+ "handler" => "rotate"
+ , "filename" => "test"
+ , 'channel' => 'Test'
+ , 'output' => 'json'
+ , 'max_day' => '1'
+ )
+ )
+ );
+ $service = Alchemy\Phrasea\Core\Service\Builder::create(self::$core, $configuration);
+ $this->assertInstanceOf("\Alchemy\Phrasea\Core\Service\ServiceAbstract", $service);
}
- }
- public function testCreate()
- {
- $configuration = new Symfony\Component\DependencyInjection\ParameterBag\ParameterBag(
- array("type" => "Log\\Doctrine\\Monolog", "options" => array(
- "handler" => "rotate"
- , "filename" => "test"
- , 'channel' => 'Test'
- , 'output' => 'json'
- , 'max_day' => '1'
- )
- )
- );
-
- $service = Alchemy\Phrasea\Core\Service\Builder::create(self::$core, $configuration);
- $this->assertInstanceOf("\Alchemy\Phrasea\Core\Service\ServiceAbstract", $service);
- }
-
- public function testCreateNamespace()
- {
- $configuration = new Symfony\Component\DependencyInjection\ParameterBag\ParameterBag(
- array("type" => "Log\\Doctrine\\Phpecho", "options" => array())
- );
-
- $service = Alchemy\Phrasea\Core\Service\Builder::create(self::$core, $configuration);
- $this->assertInstanceOf("\Alchemy\Phrasea\Core\Service\ServiceAbstract", $service);
- }
+ public function testCreateNamespace()
+ {
+ $configuration = new Symfony\Component\DependencyInjection\ParameterBag\ParameterBag(
+ array("type" => "Log\\Doctrine\\Phpecho", "options" => array())
+ );
+ $service = Alchemy\Phrasea\Core\Service\Builder::create(self::$core, $configuration);
+ $this->assertInstanceOf("\Alchemy\Phrasea\Core\Service\ServiceAbstract", $service);
+ }
}
diff --git a/tests/Alchemy/Phrasea/Core/ServiceBuilder/OrmBuilderTest.php b/tests/Alchemy/Phrasea/Core/ServiceBuilder/OrmBuilderTest.php
index fed9088119..6aec194ab6 100644
--- a/tests/Alchemy/Phrasea/Core/ServiceBuilder/OrmBuilderTest.php
+++ b/tests/Alchemy/Phrasea/Core/ServiceBuilder/OrmBuilderTest.php
@@ -1,62 +1,43 @@
"unknow", "options" => array())
- );
-
- try
+ public function testCreateException()
{
- $service = Alchemy\Phrasea\Core\Service\Builder::create(self::$core, $configuration);
- $this->fail("An exception should be raised");
+ $configuration = new Symfony\Component\DependencyInjection\ParameterBag\ParameterBag(
+ array("type" => "unknow", "options" => array())
+ );
+
+ try {
+ $service = Alchemy\Phrasea\Core\Service\Builder::create(self::$core, $configuration);
+ $this->fail("An exception should be raised");
+ } catch (\Exception $e) {
+
+ }
}
- catch (\Exception $e)
+
+ public function testCreate()
{
+ $registry = $this->getMock("\RegistryInterface");
+ $configuration = new Symfony\Component\DependencyInjection\ParameterBag\ParameterBag(
+ array("type" => "Orm\\Doctrine", "options" => array(
+ "debug" => false
+ , "log" => array('service' => "Log\\query_logger")
+ , "dbal" => "main_connexion"
+ , "cache" => array(
+ "metadata" => "Cache\\array_cache"
+ , "query" => "Cache\\array_cache"
+ , "result" => "Cache\\array_cache"
+ )
+ )
+ )
+ );
+
+ $service = Alchemy\Phrasea\Core\Service\Builder::create(self::$core, $configuration);
+ $this->assertInstanceOf("\Alchemy\Phrasea\Core\Service\ServiceAbstract", $service);
}
- }
-
- public function testCreate()
- {
- $registry = $this->getMock("\RegistryInterface");
-
- $configuration = new Symfony\Component\DependencyInjection\ParameterBag\ParameterBag(
- array("type" => "Orm\\Doctrine", "options" => array(
- "debug" => false
- , "log" => array('service'=>"Log\\query_logger")
- , "dbal" => "main_connexion"
- , "cache" => array(
- "metadata" => "Cache\\array_cache"
- , "query" => "Cache\\array_cache"
- , "result" => "Cache\\array_cache"
- )
- )
- )
- );
-
- $service = Alchemy\Phrasea\Core\Service\Builder::create(self::$core, $configuration);
- $this->assertInstanceOf("\Alchemy\Phrasea\Core\Service\ServiceAbstract", $service);
- }
-
}
diff --git a/tests/Alchemy/Phrasea/Core/ServiceBuilder/TemplateBuilderTest.php b/tests/Alchemy/Phrasea/Core/ServiceBuilder/TemplateBuilderTest.php
index b2aea9c3bd..fb7407c2e3 100644
--- a/tests/Alchemy/Phrasea/Core/ServiceBuilder/TemplateBuilderTest.php
+++ b/tests/Alchemy/Phrasea/Core/ServiceBuilder/TemplateBuilderTest.php
@@ -1,58 +1,39 @@
"unknow", "options" => array())
- );
-
- try
+ public function testCreateException()
{
- $service = Alchemy\Phrasea\Core\Service\Builder::create(self::$core, $configuration);
- $this->fail("An exception should be raised");
+ $configuration = new Symfony\Component\DependencyInjection\ParameterBag\ParameterBag(
+ array("type" => "unknow", "options" => array())
+ );
+
+ try {
+ $service = Alchemy\Phrasea\Core\Service\Builder::create(self::$core, $configuration);
+ $this->fail("An exception should be raised");
+ } catch (\Exception $e) {
+
+ }
}
- catch (\Exception $e)
+
+ public function testCreate()
{
+ $configuration = new Symfony\Component\DependencyInjection\ParameterBag\ParameterBag(
+ array(
+ "type" => "TemplateEngine\\Twig"
+ , "options" => array(
+ 'debug' => 'true'
+ , 'charset' => 'UTF-8'
+ , 'strict_variables' => 'true'
+ , 'autoescape' => 'true'
+ , 'optimizer' => 'true'
+ ))
+ );
+ $service = Alchemy\Phrasea\Core\Service\Builder::create(self::$core, $configuration);
+ $this->assertInstanceOf("\Alchemy\Phrasea\Core\Service\ServiceAbstract", $service);
}
- }
-
- public function testCreate()
- {
- $configuration = new Symfony\Component\DependencyInjection\ParameterBag\ParameterBag(
- array(
- "type" => "TemplateEngine\\Twig"
- , "options" => array(
- 'debug' => 'true'
- , 'charset' => 'UTF-8'
- , 'strict_variables' => 'true'
- , 'autoescape' => 'true'
- , 'optimizer' => 'true'
- ))
- );
-
- $service = Alchemy\Phrasea\Core\Service\Builder::create(self::$core, $configuration);
- $this->assertInstanceOf("\Alchemy\Phrasea\Core\Service\ServiceAbstract", $service);
- }
-
}
diff --git a/tests/Alchemy/Phrasea/Core/VersionTest.php b/tests/Alchemy/Phrasea/Core/VersionTest.php
index 456cf6ae9d..95f6340d35 100644
--- a/tests/Alchemy/Phrasea/Core/VersionTest.php
+++ b/tests/Alchemy/Phrasea/Core/VersionTest.php
@@ -1,36 +1,21 @@
assertTrue(is_string(Version::getNumber()));
- $this->assertRegExp('/[\d]{1}\.[\d]{1,2}\.[\d]{1,2}/', Version::getNumber());
- }
+ public function testGetNumber()
+ {
+ $this->assertTrue(is_string(Version::getNumber()));
+ $this->assertRegExp('/[\d]{1}\.[\d]{1,2}\.[\d]{1,2}/', Version::getNumber());
+ }
- public function testGetName()
- {
- $this->assertTrue(is_string(Version::getName()));
- $this->assertTrue(strlen(Version::getName()) > 3);
- }
+ public function testGetName()
+ {
+ $this->assertTrue(is_string(Version::getName()));
+ $this->assertTrue(strlen(Version::getName()) > 3);
+ }
}
diff --git a/tests/Alchemy/Phrasea/CoreTest.php b/tests/Alchemy/Phrasea/CoreTest.php
index 95365aa2f7..2d417f6946 100644
--- a/tests/Alchemy/Phrasea/CoreTest.php
+++ b/tests/Alchemy/Phrasea/CoreTest.php
@@ -1,146 +1,128 @@
assertInstanceOf('\Alchemy\Phrasea\Core\Version', self::$core->getVersion());
- }
-
- public function testCoreRegistry()
- {
- $this->assertInstanceOf('\registryInterface', self::$core->getRegistry());
- }
-
- public function testCoreEntityManager()
- {
- $this->assertInstanceOf('\Doctrine\ORM\EntityManager', self::$core->getEntityManager());
- }
-
- public function testCoreTemplateEngine()
- {
- $this->assertInstanceOf('\Twig_Environment', self::$core->getTwig());
- }
-
- public function testCoreSerializer()
- {
- $this->assertInstanceOf('\Symfony\Component\Serializer\Serializer', self::$core->getSerializer());
- }
-
- public function testCoreConfiguration()
- {
- $this->assertInstanceOf('\Alchemy\Phrasea\Core\Configuration', self::$core->getConfiguration());
- }
-
- public function testIsAuthenticathed()
- {
- $this->assertFalse(self::$core->isAuthenticated());
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $session = $appbox->get_session();
- $auth = new Session_Authentication_None(self::$user);
- $session->authenticate($auth);
- $this->assertTrue(self::$core->isAuthenticated());
- $session->logout();
- }
-
- public function testGetAuthenticathed()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $session = $appbox->get_session();
- $auth = new Session_Authentication_None(self::$user);
- $session->authenticate($auth);
- $this->assertInstanceOf("\User_Adapter", self::$core->getAuthenticatedUser());
- $session->logout();
- }
-
- public function testGetAvailableLanguages()
- {
- $languages = \Alchemy\Phrasea\Core::getAvailableLanguages();
- $this->assertTrue(is_array($languages));
- $this->assertEquals(5, count($languages));
- $this->assertTrue(array_key_exists("ar_SA", $languages));
- $this->assertTrue(array_key_exists("de_DE", $languages));
- $this->assertTrue(array_key_exists("en_GB", $languages));
- $this->assertTrue(array_key_exists("es_ES", $languages));
- $this->assertTrue(array_key_exists("fr_FR", $languages));
- }
-
- public function testGetPhpConf()
- {
- \Alchemy\Phrasea\Core::initPHPConf();
-// $this->assertEquals("4096", ini_get('output_buffering'));
- $this->assertGreaterThanOrEqual(2048, (int) ini_get('memory_limit'));
- $this->assertEquals("6143", ini_get('error_reporting'));
- $this->assertEquals("UTF-8", ini_get('default_charset'));
- $this->assertEquals("1", ini_get('session.use_cookies'));
- $this->assertEquals("1", ini_get('session.use_only_cookies'));
- $this->assertEquals("0", ini_get('session.auto_start'));
- $this->assertEquals("1", ini_get('session.hash_function'));
- $this->assertEquals("6", ini_get('session.hash_bits_per_character'));
- $this->assertEquals("1", ini_get('allow_url_fopen'));
- }
-
- public function testGetEnv()
- {
- $core = new \Alchemy\Phrasea\Core("test");
- $this->assertEquals("test", $core->getEnv());
- }
-
- public function testNotInstalled()
- {
-
- if (!extension_loaded('test_helpers'))
+ public function testCoreVersion()
{
- $this->markTestSkipped("test_helpers extension required");
+ $this->assertInstanceOf('\Alchemy\Phrasea\Core\Version', self::$core->getVersion());
}
- set_new_overload(array($this, 'newCallback'));
+ public function testCoreRegistry()
+ {
+ $this->assertInstanceOf('\registryInterface', self::$core->getRegistry());
+ }
- $specification = new \Alchemy\Phrasea\Core\Configuration\ApplicationSpecification();
+ public function testCoreEntityManager()
+ {
+ $this->assertInstanceOf('\Doctrine\ORM\EntityManager', self::$core->getEntityManager());
+ }
- $class = $this->getMock(
+ public function testCoreTemplateEngine()
+ {
+ $this->assertInstanceOf('\Twig_Environment', self::$core->getTwig());
+ }
+
+ public function testCoreSerializer()
+ {
+ $this->assertInstanceOf('\Symfony\Component\Serializer\Serializer', self::$core->getSerializer());
+ }
+
+ public function testCoreConfiguration()
+ {
+ $this->assertInstanceOf('\Alchemy\Phrasea\Core\Configuration', self::$core->getConfiguration());
+ }
+
+ public function testIsAuthenticathed()
+ {
+ $this->assertFalse(self::$core->isAuthenticated());
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $session = $appbox->get_session();
+ $auth = new Session_Authentication_None(self::$user);
+ $session->authenticate($auth);
+ $this->assertTrue(self::$core->isAuthenticated());
+ $session->logout();
+ }
+
+ public function testGetAuthenticathed()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $session = $appbox->get_session();
+ $auth = new Session_Authentication_None(self::$user);
+ $session->authenticate($auth);
+ $this->assertInstanceOf("\User_Adapter", self::$core->getAuthenticatedUser());
+ $session->logout();
+ }
+
+ public function testGetAvailableLanguages()
+ {
+ $languages = \Alchemy\Phrasea\Core::getAvailableLanguages();
+ $this->assertTrue(is_array($languages));
+ $this->assertEquals(5, count($languages));
+ $this->assertTrue(array_key_exists("ar_SA", $languages));
+ $this->assertTrue(array_key_exists("de_DE", $languages));
+ $this->assertTrue(array_key_exists("en_GB", $languages));
+ $this->assertTrue(array_key_exists("es_ES", $languages));
+ $this->assertTrue(array_key_exists("fr_FR", $languages));
+ }
+
+ public function testGetPhpConf()
+ {
+ \Alchemy\Phrasea\Core::initPHPConf();
+// $this->assertEquals("4096", ini_get('output_buffering'));
+ $this->assertGreaterThanOrEqual(2048, (int) ini_get('memory_limit'));
+ $this->assertEquals("6143", ini_get('error_reporting'));
+ $this->assertEquals("UTF-8", ini_get('default_charset'));
+ $this->assertEquals("1", ini_get('session.use_cookies'));
+ $this->assertEquals("1", ini_get('session.use_only_cookies'));
+ $this->assertEquals("0", ini_get('session.auto_start'));
+ $this->assertEquals("1", ini_get('session.hash_function'));
+ $this->assertEquals("6", ini_get('session.hash_bits_per_character'));
+ $this->assertEquals("1", ini_get('allow_url_fopen'));
+ }
+
+ public function testGetEnv()
+ {
+ $core = new \Alchemy\Phrasea\Core("test");
+ $this->assertEquals("test", $core->getEnv());
+ }
+
+ public function testNotInstalled()
+ {
+
+ if ( ! extension_loaded('test_helpers')) {
+ $this->markTestSkipped("test_helpers extension required");
+ }
+
+ set_new_overload(array($this, 'newCallback'));
+
+ $specification = new \Alchemy\Phrasea\Core\Configuration\ApplicationSpecification();
+
+ $class = $this->getMock(
'\Alchemy\Phrasea\Core\Configuration'
, array('isInstalled')
, array($specification)
, 'ConfMock'
- );
+ );
- $class->expects($this->any())
+ $class->expects($this->any())
->method('isInstalled')
->will($this->returnValue(false));
- $core = new \Alchemy\Phrasea\Core("test");
+ $core = new \Alchemy\Phrasea\Core("test");
- $this->assertInstanceOf("\Setup_Registry", $core->getRegistry());
+ $this->assertInstanceOf("\Setup_Registry", $core->getRegistry());
- unset_new_overload();
- }
-
- protected function newCallback($className)
- {
- switch ($className)
- {
- case 'Alchemy\Phrasea\Core\Configuration': return 'ConfMock';
- default: return $className;
+ unset_new_overload();
}
- }
+ protected function newCallback($className)
+ {
+ switch ($className) {
+ case 'Alchemy\Phrasea\Core\Configuration': return 'ConfMock';
+ default: return $className;
+ }
+ }
}
diff --git a/tests/Alchemy/Phrasea/Helper/Record/BridgeTest.php b/tests/Alchemy/Phrasea/Helper/Record/BridgeTest.php
deleted file mode 100644
index 749b4f36cf..0000000000
--- a/tests/Alchemy/Phrasea/Helper/Record/BridgeTest.php
+++ /dev/null
@@ -1,26 +0,0 @@
-markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
-}
diff --git a/tests/Alchemy/Phrasea/Helper/Record/EditTest.php b/tests/Alchemy/Phrasea/Helper/Record/EditTest.php
deleted file mode 100644
index c9e1ee462c..0000000000
--- a/tests/Alchemy/Phrasea/Helper/Record/EditTest.php
+++ /dev/null
@@ -1,138 +0,0 @@
-markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- *
- * @todo Implement testHas_thesaurus().
- */
- public function testHas_thesaurus()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- *
- * @todo Implement testGet_javascript_elements_ids().
- */
- public function testGet_javascript_elements_ids()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- *
- * @todo Implement testGet_javascript_elements().
- */
- public function testGet_javascript_elements()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- *
- * @todo Implement testGet_javascript_sugg_values().
- */
- public function testGet_javascript_sugg_values()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- *
- * @todo Implement testGet_javascript_status().
- */
- public function testGet_javascript_status()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- *
- * @todo Implement testGet_javascript_fields().
- */
- public function testGet_javascript_fields()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- *
- * @todo Implement testGet_status().
- */
- public function testGet_status()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- *
- * @todo Implement testGet_fields().
- */
- public function testGet_fields()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- *
- * @todo Implement testExecute().
- */
- public function testExecute()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
-}
diff --git a/tests/Alchemy/Phrasea/Helper/Record/FeedTest.php b/tests/Alchemy/Phrasea/Helper/Record/FeedTest.php
deleted file mode 100644
index 1676e50fe3..0000000000
--- a/tests/Alchemy/Phrasea/Helper/Record/FeedTest.php
+++ /dev/null
@@ -1,26 +0,0 @@
-markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
-}
diff --git a/tests/Alchemy/Phrasea/Helper/Record/HelperTest.php b/tests/Alchemy/Phrasea/Helper/Record/HelperTest.php
deleted file mode 100644
index 940a23f29e..0000000000
--- a/tests/Alchemy/Phrasea/Helper/Record/HelperTest.php
+++ /dev/null
@@ -1,186 +0,0 @@
-markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- *
- * @todo Implement testGet_original_basket().
- */
- public function testGet_original_basket()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- *
- * @todo Implement testIs_single_grouping().
- */
- public function testIs_single_grouping()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- *
- * @todo Implement testGet_grouping_head().
- */
- public function testGet_grouping_head()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- *
- * @todo Implement testGet_elements().
- */
- public function testGet_elements()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- *
- * @todo Implement testHas_many_sbas().
- */
- public function testHas_many_sbas()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- *
- * @todo Implement testIs_possible().
- */
- public function testIs_possible()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- *
- * @todo Implement testGet_count_not_actionable().
- */
- public function testGet_count_not_actionable()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- *
- * @todo Implement testGet_count_actionable().
- */
- public function testGet_count_actionable()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- *
- * @todo Implement testGet_count_actionable_groupings().
- */
- public function testGet_count_actionable_groupings()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- *
- * @todo Implement testGet_count_element_received().
- */
- public function testGet_count_element_received()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- *
- * @todo Implement testGet_sbas_id().
- */
- public function testGet_sbas_id()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- *
- * @todo Implement testGet_serialize_list().
- */
- public function testGet_serialize_list()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- *
- * @todo Implement testGrep_records().
- */
- public function testGrep_records()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
-}
diff --git a/tests/Alchemy/Phrasea/Helper/Record/MoveCollectionTest.php b/tests/Alchemy/Phrasea/Helper/Record/MoveCollectionTest.php
deleted file mode 100644
index a8c41b84c7..0000000000
--- a/tests/Alchemy/Phrasea/Helper/Record/MoveCollectionTest.php
+++ /dev/null
@@ -1,54 +0,0 @@
-markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- *
- * @todo Implement testPropose().
- */
- public function testPropose()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- *
- * @todo Implement testExecute().
- */
- public function testExecute()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
-}
diff --git a/tests/Alchemy/Phrasea/Helper/Record/PrinterTest.php b/tests/Alchemy/Phrasea/Helper/Record/PrinterTest.php
deleted file mode 100644
index fd680169fc..0000000000
--- a/tests/Alchemy/Phrasea/Helper/Record/PrinterTest.php
+++ /dev/null
@@ -1,42 +0,0 @@
-markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- *
- * @todo Implement testGet_count_thumbnail().
- */
- public function testGet_count_thumbnail()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
-}
diff --git a/tests/Alchemy/Phrasea/Helper/Record/PushTest.php b/tests/Alchemy/Phrasea/Helper/Record/PushTest.php
deleted file mode 100644
index 53a506736f..0000000000
--- a/tests/Alchemy/Phrasea/Helper/Record/PushTest.php
+++ /dev/null
@@ -1,31 +0,0 @@
-markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
-}
diff --git a/tests/Alchemy/Phrasea/Helper/Record/TooltipTest.php b/tests/Alchemy/Phrasea/Helper/Record/TooltipTest.php
deleted file mode 100644
index 7439874959..0000000000
--- a/tests/Alchemy/Phrasea/Helper/Record/TooltipTest.php
+++ /dev/null
@@ -1,26 +0,0 @@
-markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
-}
diff --git a/tests/Alchemy/Phrasea/Loader/AutoloaderTest.php b/tests/Alchemy/Phrasea/Loader/AutoloaderTest.php
index b1f6308988..0a9b7aba32 100644
--- a/tests/Alchemy/Phrasea/Loader/AutoloaderTest.php
+++ b/tests/Alchemy/Phrasea/Loader/AutoloaderTest.php
@@ -11,7 +11,7 @@ class AutoloaderTest extends \PhraseanetPHPUnitAbstract
public function testFindFile()
{
$testClassName = 'Test_Hello';
- $autoloader = new Alchemy\Phrasea\Loader\Autoloader();
+ $autoloader = new Alchemy\Phrasea\Loader\Autoloader();
$autoloader->addPath('fixture', __DIR__ . '/Fixtures');
$autoloader->loadClass($testClassName);
$this->assertTrue(class_exists($testClassName));
@@ -23,7 +23,7 @@ class AutoloaderTest extends \PhraseanetPHPUnitAbstract
public function testAddPath()
{
$autoloader = new Alchemy\Phrasea\Loader\Autoloader();
- $pathNb = count($autoloader->getPaths());
+ $pathNb = count($autoloader->getPaths());
$autoloader->addPath('fixture', __DIR__ . '/Fixtures');
$this->assertGreaterThan($pathNb, count($autoloader->getPaths()));
$this->assertArrayHasKey('fixture', $autoloader->getPaths());
@@ -40,5 +40,4 @@ class AutoloaderTest extends \PhraseanetPHPUnitAbstract
$this->assertArrayHasKey('config', $autoloader->getPaths());
$this->assertArrayHasKey('library', $autoloader->getPaths());
}
-
}
diff --git a/tests/Alchemy/Phrasea/Loader/CacheAutoloaderTest.php b/tests/Alchemy/Phrasea/Loader/CacheAutoloaderTest.php
index f09ba7b0fd..9bf40e7f38 100644
--- a/tests/Alchemy/Phrasea/Loader/CacheAutoloaderTest.php
+++ b/tests/Alchemy/Phrasea/Loader/CacheAutoloaderTest.php
@@ -1,121 +1,87 @@
apc = true;
+ parent::setUp();
+
+ if (extension_loaded('apc')) {
+ $this->apc = true;
+ }
+
+ if (extension_loaded('xcache')) {
+ $this->xcache = true;
+ }
}
- if (extension_loaded('xcache'))
+ public function testConstruct()
{
- $this->xcache = true;
- }
- }
+ if ( ! $this->apc && ! $this->xcache) {
+ try {
+ $autoloader = new Alchemy\Phrasea\Loader\CacheAutoloader('test_prefix_');
+ $this->fail("should raise an exception");
+ } catch (\Exception $e) {
- public function testConstruct()
- {
- if (!$this->apc && !$this->xcache)
+ }
+ }
+ }
+
+ public function testFindFileApc()
{
- try
- {
- $autoloader = new Alchemy\Phrasea\Loader\CacheAutoloader('test_prefix_');
- $this->fail("should raise an exception");
- }
- catch(\Exception $e)
- {
+ if ($this->apc) {
+ if ( ! (ini_get('apc.enabled') && ini_get('apc.enable_cli'))) {
+ $this->markTestSkipped('The apc extension is available, but not enabled.');
+ } else {
+ apc_clear_cache('user');
+ }
- }
+ $autoloader = new Alchemy\Phrasea\Loader\CacheAutoloader('test_prefix_');
+ $cacheAdapter = $autoloader->getAdapter();
+ $this->assertEquals($autoloader->findFile('Test_HelloCache'), $cacheAdapter->fetch('test_prefix_Test_Hello'));
+ }
}
- }
- public function testFindFileApc()
- {
- if ($this->apc)
+ public function testGetPrefix()
{
- if (!(ini_get('apc.enabled') && ini_get('apc.enable_cli')))
- {
- $this->markTestSkipped('The apc extension is available, but not enabled.');
- }
- else
- {
- apc_clear_cache('user');
- }
-
- $autoloader = new Alchemy\Phrasea\Loader\CacheAutoloader('test_prefix_');
- $cacheAdapter = $autoloader->getAdapter();
- $this->assertEquals($autoloader->findFile('Test_HelloCache'), $cacheAdapter->fetch('test_prefix_Test_Hello'));
+ if ($this->apc) {
+ $autoloader = new Alchemy\Phrasea\Loader\CacheAutoloader('test_prefix_');
+ $this->assertEquals('test_prefix_', $autoloader->getPrefix());
+ }
}
- }
- public function testGetPrefix()
- {
- if ($this->apc)
+ public function testRegister()
{
- $autoloader = new Alchemy\Phrasea\Loader\CacheAutoloader('test_prefix_');
- $this->assertEquals('test_prefix_', $autoloader->getPrefix());
+ if ($this->apc) {
+ if ( ! (ini_get('apc.enabled') && ini_get('apc.enable_cli'))) {
+ $this->markTestSkipped('The apc extension is available, but not enabled.');
+ } else {
+ apc_clear_cache('user');
+ }
+ $autoloader = new Alchemy\Phrasea\Loader\CacheAutoloader('test_prefix_');
+ $autoloader->addPath('fixture', __DIR__ . '/Fixtures');
+ $autoloader->register();
+ $this->assertTrue(class_exists("Test_test"));
+ }
}
- }
- public function testRegister()
- {
- if ($this->apc)
+ public function testFindFileXcache()
{
- if (!(ini_get('apc.enabled') && ini_get('apc.enable_cli')))
- {
- $this->markTestSkipped('The apc extension is available, but not enabled.');
- }
- else
- {
- apc_clear_cache('user');
- }
- $autoloader = new Alchemy\Phrasea\Loader\CacheAutoloader('test_prefix_');
- $autoloader->addPath('fixture', __DIR__ . '/Fixtures');
- $autoloader->register();
- $this->assertTrue(class_exists("Test_test"));
+ if ($this->xcache) {
+ $this->marktestSkipped("can't use xcache in cli mode");
+ }
}
- }
- public function testFindFileXcache()
- {
- if ($this->xcache)
+ public function tearDown()
{
- $this->marktestSkipped("can't use xcache in cli mode");
+ if (ini_get('apc.enabled') && ini_get('apc.enable_cli')) {
+ apc_clear_cache('user');
+ }
+ parent::tearDown();
}
- }
-
- public function tearDown()
- {
- if (ini_get('apc.enabled') && ini_get('apc.enable_cli'))
- {
- apc_clear_cache('user');
- }
- parent::tearDown();
- }
-
}
diff --git a/tests/Alchemy/Phrasea/Loader/Fixtures/Test/Hello.class.php b/tests/Alchemy/Phrasea/Loader/Fixtures/Test/Hello.class.php
index 0860cedf9e..6ede4ef74d 100644
--- a/tests/Alchemy/Phrasea/Loader/Fixtures/Test/Hello.class.php
+++ b/tests/Alchemy/Phrasea/Loader/Fixtures/Test/Hello.class.php
@@ -1,21 +1,5 @@
assertInstanceOf('\\MediaAlchemyst\\Specification\\Audio', $this->object->getMediaAlchemystSpec());
}
-
}
diff --git a/tests/Alchemy/Phrasea/Media/Subdef/FlexPaperTest.php b/tests/Alchemy/Phrasea/Media/Subdef/FlexPaperTest.php
index 47b0846454..539279d74b 100644
--- a/tests/Alchemy/Phrasea/Media/Subdef/FlexPaperTest.php
+++ b/tests/Alchemy/Phrasea/Media/Subdef/FlexPaperTest.php
@@ -4,7 +4,6 @@ namespace Alchemy\Phrasea\Media\Subdef;
class FlexPaperTest extends \PHPUnit_Framework_TestCase
{
-
/**
* @var FlexPaper
*/
@@ -38,5 +37,4 @@ class FlexPaperTest extends \PHPUnit_Framework_TestCase
{
$this->assertInstanceOf('\\MediaAlchemyst\\Specification\\Flash', $this->object->getMediaAlchemystSpec());
}
-
}
diff --git a/tests/Alchemy/Phrasea/Media/Subdef/GifTest.php b/tests/Alchemy/Phrasea/Media/Subdef/GifTest.php
index 611bad5230..f40eb3687a 100644
--- a/tests/Alchemy/Phrasea/Media/Subdef/GifTest.php
+++ b/tests/Alchemy/Phrasea/Media/Subdef/GifTest.php
@@ -4,7 +4,6 @@ namespace Alchemy\Phrasea\Media\Subdef;
class GifTest extends \PHPUnit_Framework_TestCase
{
-
/**
* @var Gif
*/
@@ -38,5 +37,4 @@ class GifTest extends \PHPUnit_Framework_TestCase
{
$this->assertInstanceOf('\\MediaAlchemyst\\Specification\\Animation', $this->object->getMediaAlchemystSpec());
}
-
}
diff --git a/tests/Alchemy/Phrasea/Media/Subdef/ImageTest.php b/tests/Alchemy/Phrasea/Media/Subdef/ImageTest.php
index d5e4032dd7..adb56fdb4c 100644
--- a/tests/Alchemy/Phrasea/Media/Subdef/ImageTest.php
+++ b/tests/Alchemy/Phrasea/Media/Subdef/ImageTest.php
@@ -4,7 +4,6 @@ namespace Alchemy\Phrasea\Media\Subdef;
class ImageTest extends \PHPUnit_Framework_TestCase
{
-
/**
* @var Image
*/
@@ -38,5 +37,4 @@ class ImageTest extends \PHPUnit_Framework_TestCase
{
$this->assertInstanceOf('\\MediaAlchemyst\\Specification\\Image', $this->object->getMediaAlchemystSpec());
}
-
}
diff --git a/tests/Alchemy/Phrasea/Media/Subdef/OptionType/BooleanTest.php b/tests/Alchemy/Phrasea/Media/Subdef/OptionType/BooleanTest.php
index b2c436e71d..0109d70aa5 100644
--- a/tests/Alchemy/Phrasea/Media/Subdef/OptionType/BooleanTest.php
+++ b/tests/Alchemy/Phrasea/Media/Subdef/OptionType/BooleanTest.php
@@ -4,7 +4,6 @@ namespace Alchemy\Phrasea\Media\Subdef\OptionType;
class BooleanTest extends \PHPUnit_Framework_TestCase
{
-
/**
* @var Boolean
*/
@@ -49,5 +48,4 @@ class BooleanTest extends \PHPUnit_Framework_TestCase
{
$this->assertEquals('Booleen', $this->object->getDisplayName());
}
-
}
diff --git a/tests/Alchemy/Phrasea/Media/Subdef/OptionType/EnumTest.php b/tests/Alchemy/Phrasea/Media/Subdef/OptionType/EnumTest.php
index 81328912a7..5e8aeffc71 100644
--- a/tests/Alchemy/Phrasea/Media/Subdef/OptionType/EnumTest.php
+++ b/tests/Alchemy/Phrasea/Media/Subdef/OptionType/EnumTest.php
@@ -4,7 +4,6 @@ namespace Alchemy\Phrasea\Media\Subdef\OptionType;
class EnumTest extends \PHPUnit_Framework_TestCase
{
-
/**
* @var Enum
*/
@@ -68,5 +67,4 @@ class EnumTest extends \PHPUnit_Framework_TestCase
{
$this->assertEquals('Numo', $this->object->getDisplayName());
}
-
}
diff --git a/tests/Alchemy/Phrasea/Media/Subdef/OptionType/RangeTest.php b/tests/Alchemy/Phrasea/Media/Subdef/OptionType/RangeTest.php
index 45b37f772b..331e1d2d06 100644
--- a/tests/Alchemy/Phrasea/Media/Subdef/OptionType/RangeTest.php
+++ b/tests/Alchemy/Phrasea/Media/Subdef/OptionType/RangeTest.php
@@ -4,7 +4,6 @@ namespace Alchemy\Phrasea\Media\Subdef\OptionType;
class RangeTest extends \PHPUnit_Framework_TestCase
{
-
/**
* @var Range
*/
@@ -88,5 +87,4 @@ class RangeTest extends \PHPUnit_Framework_TestCase
{
$this->assertEquals('Rangers', $this->object->getDisplayName());
}
-
}
diff --git a/tests/Alchemy/Phrasea/Media/Subdef/ProviderTest.php b/tests/Alchemy/Phrasea/Media/Subdef/ProviderTest.php
index 861c7451f4..2dde6024fa 100644
--- a/tests/Alchemy/Phrasea/Media/Subdef/ProviderTest.php
+++ b/tests/Alchemy/Phrasea/Media/Subdef/ProviderTest.php
@@ -4,7 +4,6 @@ namespace Alchemy\Phrasea\Media\Subdef;
class ProviderTest extends \PHPUnit_Framework_TestCase
{
-
/**
* @var Provider
*/
@@ -22,8 +21,7 @@ class ProviderTest extends \PHPUnit_Framework_TestCase
{
$this->assertTrue(is_array($this->object->getOptions()));
- foreach ($this->object->getOptions() as $option)
- {
+ foreach ($this->object->getOptions() as $option) {
$this->assertInstanceOf('\\Alchemy\\Phrasea\\Media\\Subdef\\OptionType\\OptionType', $option);
}
}
@@ -48,5 +46,4 @@ class ProviderTest extends \PHPUnit_Framework_TestCase
$option = $this->object->getOption(Image::OPTION_SIZE);
$this->assertEquals(300, $option->getValue());
}
-
}
diff --git a/tests/Alchemy/Phrasea/Media/Subdef/VideoTest.php b/tests/Alchemy/Phrasea/Media/Subdef/VideoTest.php
index 8a61af1e25..7693bc433c 100644
--- a/tests/Alchemy/Phrasea/Media/Subdef/VideoTest.php
+++ b/tests/Alchemy/Phrasea/Media/Subdef/VideoTest.php
@@ -4,7 +4,6 @@ namespace Alchemy\Phrasea\Media\Subdef;
class VideoTest extends \PHPUnit_Framework_TestCase
{
-
/**
* @var Video
*/
@@ -38,5 +37,4 @@ class VideoTest extends \PHPUnit_Framework_TestCase
{
$this->assertInstanceOf('\\MediaAlchemyst\\Specification\\Video', $this->object->getMediaAlchemystSpec());
}
-
}
diff --git a/tests/Alchemy/Phrasea/Vocabulary/ControlProvider/UserProviderTest.php b/tests/Alchemy/Phrasea/Vocabulary/ControlProvider/UserProviderTest.php
index 4d4f813daf..f640caedf9 100644
--- a/tests/Alchemy/Phrasea/Vocabulary/ControlProvider/UserProviderTest.php
+++ b/tests/Alchemy/Phrasea/Vocabulary/ControlProvider/UserProviderTest.php
@@ -4,88 +4,81 @@ require_once __DIR__ . '/../../../../PhraseanetPHPUnitAbstract.class.inc';
class UserProviderTest extends \PhraseanetPHPUnitAbstract
{
+ /**
+ * @var UserProvider
+ */
+ protected $object;
- /**
- * @var UserProvider
- */
- protected $object;
-
- public function setUp()
- {
- $this->object = new \Alchemy\Phrasea\Vocabulary\ControlProvider\UserProvider();
- }
-
- /**
- * Verify that Type is scalar and that the classname is like {Type}Provider
- */
- public function testGetType()
- {
- $type = $this->object->getType();
-
- $this->assertTrue(is_scalar($type));
-
- $classname = array_pop(explode('\\', get_class($this->object)));
-
- $this->assertEquals($classname, $type . 'Provider');
- }
-
- public function testGetName()
- {
- $this->assertTrue(is_scalar($this->object->getName()));
- }
-
- public function testFind()
- {
- $results = $this->object->find('BABE', self::$user, self::$collection->get_databox());
-
- $this->assertInstanceOf('\\Doctrine\\Common\\Collections\\ArrayCollection', $results);
-
- $results = $this->object->find(self::$user->get_email(), self::$user, self::$collection->get_databox());
-
- $this->assertInstanceOf('\\Doctrine\\Common\\Collections\\ArrayCollection', $results);
- $this->assertTrue($results->count() > 0);
-
- $results = $this->object->find(self::$user->get_firstname(), self::$user, self::$collection->get_databox());
-
- $this->assertInstanceOf('\\Doctrine\\Common\\Collections\\ArrayCollection', $results);
- $this->assertTrue($results->count() > 0);
-
- $results = $this->object->find(self::$user->get_lastname(), self::$user, self::$collection->get_databox());
-
- $this->assertInstanceOf('\\Doctrine\\Common\\Collections\\ArrayCollection', $results);
- $this->assertTrue($results->count() > 0);
- }
-
- public function testValidate()
- {
- $this->assertFalse($this->object->validate(-200));
- $this->assertFalse($this->object->validate('A'));
- $this->assertTrue($this->object->validate(self::$user->get_id()));
- }
-
- public function testGetValue()
- {
- try
+ public function setUp()
{
- $this->object->getValue(-200);
- $this->fail('Should raise an exception');
- }
- catch(\Exception $e)
- {
-
+ parent::setUp();
+ $this->object = new \Alchemy\Phrasea\Vocabulary\ControlProvider\UserProvider();
}
- try
- {
- $this->object->getValue('A');
- $this->fail('Should raise an exception');
- }
- catch(\Exception $e)
+ /**
+ * Verify that Type is scalar and that the classname is like {Type}Provider
+ */
+ public function testGetType()
{
+ $type = $this->object->getType();
+ $this->assertTrue(is_scalar($type));
+
+ $classname = array_pop(explode('\\', get_class($this->object)));
+
+ $this->assertEquals($classname, $type . 'Provider');
}
- $this->assertEquals(self::$user->get_display_name(), $this->object->getValue(self::$user->get_id()));
- }
+ public function testGetName()
+ {
+ $this->assertTrue(is_scalar($this->object->getName()));
+ }
+ public function testFind()
+ {
+ $results = $this->object->find('BABE', self::$user, self::$collection->get_databox());
+
+ $this->assertInstanceOf('\\Doctrine\\Common\\Collections\\ArrayCollection', $results);
+
+ $results = $this->object->find(self::$user->get_email(), self::$user, self::$collection->get_databox());
+
+ $this->assertInstanceOf('\\Doctrine\\Common\\Collections\\ArrayCollection', $results);
+ $this->assertTrue($results->count() > 0);
+
+ $results = $this->object->find(self::$user->get_firstname(), self::$user, self::$collection->get_databox());
+
+ $this->assertInstanceOf('\\Doctrine\\Common\\Collections\\ArrayCollection', $results);
+ $this->assertTrue($results->count() > 0);
+
+ $results = $this->object->find(self::$user->get_lastname(), self::$user, self::$collection->get_databox());
+
+ $this->assertInstanceOf('\\Doctrine\\Common\\Collections\\ArrayCollection', $results);
+ $this->assertTrue($results->count() > 0);
+ }
+
+ public function testValidate()
+ {
+ $this->assertFalse($this->object->validate(-200));
+ $this->assertFalse($this->object->validate('A'));
+ $this->assertTrue($this->object->validate(self::$user->get_id()));
+ }
+
+ public function testGetValue()
+ {
+ try {
+ $this->object->getValue(-200);
+ $this->fail('Should raise an exception');
+ } catch (\Exception $e) {
+
+ }
+
+ try {
+ $this->object->getValue('A');
+ $this->fail('Should raise an exception');
+ } catch (\Exception $e) {
+
+ }
+
+ $this->assertEquals(self::$user->get_display_name(), $this->object->getValue(self::$user->get_id()));
+ }
}
diff --git a/tests/Alchemy/Phrasea/Vocabulary/ControllerTest.php b/tests/Alchemy/Phrasea/Vocabulary/ControllerTest.php
index 6975082592..49d45a9310 100644
--- a/tests/Alchemy/Phrasea/Vocabulary/ControllerTest.php
+++ b/tests/Alchemy/Phrasea/Vocabulary/ControllerTest.php
@@ -5,33 +5,28 @@ require_once __DIR__ . '/../../../PhraseanetPHPUnitAbstract.class.inc';
class ControllerTest extends \PhraseanetPHPUnitAbstract
{
- public function testGet()
- {
- $provider = \Alchemy\Phrasea\Vocabulary\Controller::get('User');
-
- $this->assertInstanceOf('\\Alchemy\\Phrasea\\Vocabulary\\ControlProvider\\UserProvider', $provider);
-
- try
+ public function testGet()
{
- $provider = \Alchemy\Phrasea\Vocabulary\Controller::get('Zebulon');
- $this->fail('Should raise an exception');
+ $provider = \Alchemy\Phrasea\Vocabulary\Controller::get('User');
+
+ $this->assertInstanceOf('\\Alchemy\\Phrasea\\Vocabulary\\ControlProvider\\UserProvider', $provider);
+
+ try {
+ $provider = \Alchemy\Phrasea\Vocabulary\Controller::get('Zebulon');
+ $this->fail('Should raise an exception');
+ } catch (\Exception $e) {
+
+ }
}
- catch(\Exception $e)
+
+ public function testGetAvailable()
{
+ $available = \Alchemy\Phrasea\Vocabulary\Controller::getAvailable();
+ $this->assertTrue(is_array($available));
+
+ foreach ($available as $controller) {
+ $this->assertInstanceOf('\\Alchemy\\Phrasea\\Vocabulary\\ControlProvider\\ControlProviderInterface', $controller);
+ }
}
- }
-
- public function testGetAvailable()
- {
- $available = \Alchemy\Phrasea\Vocabulary\Controller::getAvailable();
-
- $this->assertTrue(is_array($available));
-
- foreach($available as $controller)
- {
- $this->assertInstanceOf('\\Alchemy\\Phrasea\\Vocabulary\\ControlProvider\\ControlProviderInterface', $controller);
- }
- }
-
}
diff --git a/tests/Alchemy/Phrasea/Vocabulary/TermTest.php b/tests/Alchemy/Phrasea/Vocabulary/TermTest.php
index 5a613f1f07..3157e43551 100644
--- a/tests/Alchemy/Phrasea/Vocabulary/TermTest.php
+++ b/tests/Alchemy/Phrasea/Vocabulary/TermTest.php
@@ -6,65 +6,64 @@ use \Alchemy\Phrasea\Vocabulary\Term;
class TermTest extends \PhraseanetPHPUnitAbstract
{
+ /**
+ * @var Term
+ */
+ protected $object;
- /**
- * @var Term
- */
- protected $object;
+ /**
+ * @var Term
+ */
+ protected $basicObject;
- /**
- * @var Term
- */
- protected $basicObject;
-
- /**
- * @var Term
- */
- protected $objectWithControl;
- protected $value2 = 'Supa valu&é"\'(§è!)';
- protected $context2 = 'context
+ /**
+ * @var Term
+ */
+ protected $objectWithControl;
+ protected $value2 = 'Supa valu&é"\'(§è!)';
+ protected $context2 = 'context
oualibi';
- protected $basicValue = 'Joli chien';
- protected $value = 'One value';
- protected $context = 'Another context';
- protected $control;
- protected $id = 25;
+ protected $basicValue = 'Joli chien';
+ protected $value = 'One value';
+ protected $context = 'Another context';
+ protected $control;
+ protected $id = 25;
- public function setUp()
- {
- $this->control = new Alchemy\Phrasea\Vocabulary\ControlProvider\UserProvider();
+ public function setUp()
+ {
+ parent::setUp();
+ $this->control = new Alchemy\Phrasea\Vocabulary\ControlProvider\UserProvider();
- $this->object = new Term($this->value, $this->context);
- $this->basicObject = new Term($this->basicValue);
- $this->objectWithControl = new Term($this->value2, $this->context2, $this->control, $this->id);
- }
+ $this->object = new Term($this->value, $this->context);
+ $this->basicObject = new Term($this->basicValue);
+ $this->objectWithControl = new Term($this->value2, $this->context2, $this->control, $this->id);
+ }
- public function testGetValue()
- {
- $this->assertEquals($this->basicValue, $this->basicObject->getValue());
- $this->assertEquals($this->value, $this->object->getValue());
- $this->assertEquals($this->value2, $this->objectWithControl->getValue());
- }
+ public function testGetValue()
+ {
+ $this->assertEquals($this->basicValue, $this->basicObject->getValue());
+ $this->assertEquals($this->value, $this->object->getValue());
+ $this->assertEquals($this->value2, $this->objectWithControl->getValue());
+ }
- public function testGetContext()
- {
- $this->assertEquals(null, $this->basicObject->getContext());
- $this->assertEquals($this->context, $this->object->getContext());
- $this->assertEquals($this->context2, $this->objectWithControl->getContext());
- }
+ public function testGetContext()
+ {
+ $this->assertEquals(null, $this->basicObject->getContext());
+ $this->assertEquals($this->context, $this->object->getContext());
+ $this->assertEquals($this->context2, $this->objectWithControl->getContext());
+ }
- public function testGetType()
- {
- $this->assertEquals(null, $this->basicObject->getType());
- $this->assertEquals(null, $this->object->getType());
- $this->assertEquals($this->control, $this->objectWithControl->getType());
- }
-
- public function testGetId()
- {
- $this->assertEquals(null, $this->basicObject->getId());
- $this->assertEquals(null, $this->object->getId());
- $this->assertEquals($this->id, $this->objectWithControl->getId());
- }
+ public function testGetType()
+ {
+ $this->assertEquals(null, $this->basicObject->getType());
+ $this->assertEquals(null, $this->object->getType());
+ $this->assertEquals($this->control, $this->objectWithControl->getType());
+ }
+ public function testGetId()
+ {
+ $this->assertEquals(null, $this->basicObject->getId());
+ $this->assertEquals(null, $this->object->getId());
+ $this->assertEquals($this->id, $this->objectWithControl->getId());
+ }
}
diff --git a/tests/Bridge/Api/Auth/Bridge_Api_Auth_AbstractTest.php b/tests/Bridge/Api/Auth/Bridge_Api_Auth_AbstractTest.php
index 150bff2915..398ef85355 100644
--- a/tests/Bridge/Api/Auth/Bridge_Api_Auth_AbstractTest.php
+++ b/tests/Bridge/Api/Auth/Bridge_Api_Auth_AbstractTest.php
@@ -6,12 +6,11 @@ require_once __DIR__ . '/../../Bridge_datas.inc';
class Bridge_Api_Auth_AbstractTest extends PHPUnit_Framework_TestCase
{
- public function testSet_settings()
- {
- $stub = $this->getMockForAbstractClass('Bridge_Api_Auth_Abstract');
- $setting = $this->getMock("Bridge_AccountSettings", array(), array(), '' , false);
- $return = $stub->set_settings($setting);
- $this->assertEquals($stub, $return);
- }
-
+ public function testSet_settings()
+ {
+ $stub = $this->getMockForAbstractClass('Bridge_Api_Auth_Abstract');
+ $setting = $this->getMock("Bridge_AccountSettings", array(), array(), '', false);
+ $return = $stub->set_settings($setting);
+ $this->assertEquals($stub, $return);
+ }
}
diff --git a/tests/Bridge/Api/Auth/Bridge_Api_Auth_FlickrTest.php b/tests/Bridge/Api/Auth/Bridge_Api_Auth_FlickrTest.php
index 7aba2ff92e..2b88437734 100644
--- a/tests/Bridge/Api/Auth/Bridge_Api_Auth_FlickrTest.php
+++ b/tests/Bridge/Api/Auth/Bridge_Api_Auth_FlickrTest.php
@@ -5,172 +5,170 @@ require_once __DIR__ . '/../../Bridge_datas.inc';
class Bridge_Api_Auth_FlickrTest extends PHPUnit_Framework_TestCase
{
+ /**
+ * @var Bridge_Api_Auth_Flickr
+ */
+ protected $object;
- /**
- * @var Bridge_Api_Auth_Flickr
- */
- protected $object;
+ public function setUp()
+ {
+ $this->object = new Bridge_Api_Auth_Flickr();
+ }
- public function setUp()
- {
- $this->object = new Bridge_Api_Auth_Flickr();
- }
+ public function testParse_request_token()
+ {
+ $this->assertNull($this->object->parse_request_token());
+ $_GET["frob"] = "123";
+ $this->assertEquals("123", $this->object->parse_request_token());
+ unset($_GET["frob"]);
+ $this->assertNull($this->object->parse_request_token());
+ }
- public function testParse_request_token()
- {
- $this->assertNull($this->object->parse_request_token());
- $_GET["frob"] = "123";
- $this->assertEquals("123", $this->object->parse_request_token());
- unset($_GET["frob"]);
- $this->assertNull($this->object->parse_request_token());
- }
-
- public function testConnect()
- {
- $api = $this->getMock("Phlickr_Api", array(), array(), "", false);
- //mock api method
- $api->expects($this->once())
+ public function testConnect()
+ {
+ $api = $this->getMock("Phlickr_Api", array(), array(), "", false);
+ //mock api method
+ $api->expects($this->once())
->method("setAuthTokenFromFrob")
->will($this->returnValue("un_token"));
- $api->expects($this->once())
+ $api->expects($this->once())
->method("setAuthToken")
->with($this->equalTo("un_token"));
- $api->expects($this->once())
+ $api->expects($this->once())
->method("isAuthValid")
->will($this->returnValue(true));
- $stub = $this->getMock("Bridge_Api_Auth_Flickr", array("get_api"));
+ $stub = $this->getMock("Bridge_Api_Auth_Flickr", array("get_api"));
- $stub->expects($this->any())
+ $stub->expects($this->any())
->method("get_api")
->will($this->returnValue($api));
- $return = $stub->connect("123");
+ $return = $stub->connect("123");
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $return);
- $this->assertArrayHasKey("auth_token", $return);
- $this->assertEquals("un_token", $return["auth_token"]);
- }
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $return);
+ $this->assertArrayHasKey("auth_token", $return);
+ $this->assertEquals("un_token", $return["auth_token"]);
+ }
- public function testBadConnect()
- {
- $api = $this->getMock("Phlickr_Api", array(), array(), "", false);
- //mock api method
- $api->expects($this->once())
+ public function testBadConnect()
+ {
+ $api = $this->getMock("Phlickr_Api", array(), array(), "", false);
+ //mock api method
+ $api->expects($this->once())
->method("setAuthTokenFromFrob")
->will($this->returnValue("un_token"));
- $api->expects($this->once())
+ $api->expects($this->once())
->method("isAuthValid")
->will($this->returnValue(false));
- $stub = $this->getMock("Bridge_Api_Auth_Flickr", array("get_api"));
+ $stub = $this->getMock("Bridge_Api_Auth_Flickr", array("get_api"));
- $stub->expects($this->any())
+ $stub->expects($this->any())
->method("get_api")
->will($this->returnValue($api));
- $this->setExpectedException("Bridge_Exception_ApiConnectorAccessTokenFailed");
+ $this->setExpectedException("Bridge_Exception_ApiConnectorAccessTokenFailed");
- $return = $stub->connect("123");
- }
+ $return = $stub->connect("123");
+ }
- public function testReconnect()
- {
- $this->assertEquals($this->object, $this->object->reconnect());
- }
+ public function testReconnect()
+ {
+ $this->assertEquals($this->object, $this->object->reconnect());
+ }
- public function testDisconnect()
- {
- $setting = $this->getMock("Bridge_AccountSettings", array("set"), array(), "", false);
+ public function testDisconnect()
+ {
+ $setting = $this->getMock("Bridge_AccountSettings", array("set"), array(), "", false);
- $setting->expects($this->once())
+ $setting->expects($this->once())
->method("set")
->with($this->equalTo("auth_token"), $this->isNull());
- $this->object->set_settings($setting);
+ $this->object->set_settings($setting);
- $return = $this->object->disconnect();
+ $return = $this->object->disconnect();
- $this->assertEquals($this->object, $return);
- }
+ $this->assertEquals($this->object, $return);
+ }
- public function testIs_connected()
- {
- $setting = $this->getMock("Bridge_AccountSettings", array("get"), array(), "", false);
+ public function testIs_connected()
+ {
+ $setting = $this->getMock("Bridge_AccountSettings", array("get"), array(), "", false);
- $setting->expects($this->any())
+ $setting->expects($this->any())
->method("get")
->with($this->equalTo("auth_token"))
->will($this->onConsecutiveCalls("123456", 123456, null));
- $this->object->set_settings($setting);
+ $this->object->set_settings($setting);
- $this->assertTrue($this->object->is_connected());
- $this->assertTrue($this->object->is_connected());
- $this->assertFalse($this->object->is_connected());
- }
+ $this->assertTrue($this->object->is_connected());
+ $this->assertTrue($this->object->is_connected());
+ $this->assertFalse($this->object->is_connected());
+ }
- public function testGet_auth_signatures()
- {
- $setting = $this->getMock("Bridge_AccountSettings", array("get"), array(), "", false);
+ public function testGet_auth_signatures()
+ {
+ $setting = $this->getMock("Bridge_AccountSettings", array("get"), array(), "", false);
- $setting->expects($this->once())
+ $setting->expects($this->once())
->method("get")
->with($this->equalTo("auth_token"))
->will($this->returnValue("123"));
- $this->object->set_settings($setting);
+ $this->object->set_settings($setting);
- $return = $this->object->get_auth_signatures();
+ $return = $this->object->get_auth_signatures();
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $return);
- $this->assertArrayHasKey("auth_token", $return);
- $this->assertEquals("123", $return["auth_token"]);
- }
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $return);
+ $this->assertArrayHasKey("auth_token", $return);
+ $this->assertEquals("123", $return["auth_token"]);
+ }
- public function testSet_parameters()
- {
- $parameters = array(
- "caca" => "boudain"
- , "sirop" => "fraise"
- , "choco" => "banane"
- , "pirouette" => "cacahuete"
- );
+ public function testSet_parameters()
+ {
+ $parameters = array(
+ "caca" => "boudain"
+ , "sirop" => "fraise"
+ , "choco" => "banane"
+ , "pirouette" => "cacahuete"
+ );
- $return = $this->object->set_parameters($parameters);
+ $return = $this->object->set_parameters($parameters);
- $this->assertEquals(0, sizeof(get_object_vars($this->object)));
- $this->assertEquals($return, $this->object);
- }
+ $this->assertEquals(0, sizeof(get_object_vars($this->object)));
+ $this->assertEquals($return, $this->object);
+ }
- public function testGet_auth_url()
- {
- $api = $this->getMock("Phlickr_Api", array(), array(), "", false);
- //mock api method
- $api->expects($this->any())
+ public function testGet_auth_url()
+ {
+ $api = $this->getMock("Phlickr_Api", array(), array(), "", false);
+ //mock api method
+ $api->expects($this->any())
->method("requestFrob")
->will($this->returnValue("un_token"));
- $api->expects($this->any())
+ $api->expects($this->any())
->method("buildAuthUrl")
->with($this->equalTo("write"), $this->equalTo("un_token"))
->will($this->returnValue("une_super_url"));
- $stub = $this->getMock("Bridge_Api_Auth_Flickr", array("get_api"));
+ $stub = $this->getMock("Bridge_Api_Auth_Flickr", array("get_api"));
- $stub->expects($this->any())
+ $stub->expects($this->any())
->method("get_api")
->will($this->returnValue($api));
- $params = array("permissions" => "write");
+ $params = array("permissions" => "write");
- $stub->set_parameters($params);
-
- $this->assertEquals("une_super_url", $stub->get_auth_url());
- $this->assertEquals("une_super_url", $stub->get_auth_url($params));
- }
+ $stub->set_parameters($params);
+ $this->assertEquals("une_super_url", $stub->get_auth_url());
+ $this->assertEquals("une_super_url", $stub->get_auth_url($params));
+ }
}
diff --git a/tests/Bridge/Api/Auth/Bridge_Api_Auth_OAuth2Test.php b/tests/Bridge/Api/Auth/Bridge_Api_Auth_OAuth2Test.php
index f77cf35303..68d376d438 100644
--- a/tests/Bridge/Api/Auth/Bridge_Api_Auth_OAuth2Test.php
+++ b/tests/Bridge/Api/Auth/Bridge_Api_Auth_OAuth2Test.php
@@ -5,138 +5,135 @@ require_once __DIR__ . '/../../Bridge_datas.inc';
class Bridge_Api_Auth_OAuth2Test extends PHPUnit_Framework_TestCase
{
+ /**
+ * @var Bridge_Api_Auth_OAuth2
+ */
+ protected $object;
+ protected $parameters;
- /**
- * @var Bridge_Api_Auth_OAuth2
- */
- protected $object;
- protected $parameters;
+ public function setUp()
+ {
+ $this->object = new Bridge_Api_Auth_OAuth2();
- public function setUp()
- {
- $this->object = new Bridge_Api_Auth_OAuth2();
+ $this->parameters = array(
+ 'client_id' => "client_id"
+ , 'client_secret' => "client_secret"
+ , 'redirect_uri' => "redirect_uri"
+ , 'scope' => 'super_scope'
+ , 'response_type' => 'code'
+ , 'token_endpoint' => "one_token_endpoint"
+ , 'auth_endpoint' => "one_auth_endpoint"
+ );
+ }
- $this->parameters = array(
- 'client_id' => "client_id"
- , 'client_secret' => "client_secret"
- , 'redirect_uri' => "redirect_uri"
- , 'scope' => 'super_scope'
- , 'response_type' => 'code'
- , 'token_endpoint' => "one_token_endpoint"
- , 'auth_endpoint' => "one_auth_endpoint"
- );
- }
+ public function testParse_request_token()
+ {
+ $this->object->set_parameters($this->parameters);
+ $_GET = array("code" => "12345");
+ $token = $this->object->parse_request_token();
+ $this->assertEquals("12345", $token);
+ $this->parameters["response_type"] = "blabla";
+ $this->object->set_parameters($this->parameters);
+ $this->assertNull($this->object->parse_request_token());
+ }
+ public function testConnect()
+ {
+ $this->setExpectedException("Bridge_Exception_ApiConnectorAccessTokenFailed");
- public function testParse_request_token()
- {
- $this->object->set_parameters($this->parameters);
- $_GET = array("code" => "12345");
- $token = $this->object->parse_request_token();
- $this->assertEquals("12345", $token);
- $this->parameters["response_type"] = "blabla";
- $this->object->set_parameters($this->parameters);
- $this->assertNull($this->object->parse_request_token());
- }
+ $this->object->connect("123");
+ }
- public function testConnect()
- {
- $this->setExpectedException("Bridge_Exception_ApiConnectorAccessTokenFailed");
+ public function testReconnect()
+ {
+ $setting = $this->getMock("Bridge_AccountSettings", array("get"), array(), "", false);
- $this->object->connect("123");
- }
-
- public function testReconnect()
- {
- $setting = $this->getMock("Bridge_AccountSettings", array("get"), array(), "", false);
-
- $setting->expects($this->once())
+ $setting->expects($this->once())
->method("get")
->with($this->equalTo("refresh_token"))
->will($this->returnValue("123"));
- $this->object->set_settings($setting);
+ $this->object->set_settings($setting);
- $this->setExpectedException("Bridge_Exception_ApiConnectorAccessTokenFailed");
+ $this->setExpectedException("Bridge_Exception_ApiConnectorAccessTokenFailed");
- $this->object->reconnect();
- }
+ $this->object->reconnect();
+ }
- public function testDisconnect()
- {
- $setting = $this->getMock("Bridge_AccountSettings", array("set"), array(), "", false);
+ public function testDisconnect()
+ {
+ $setting = $this->getMock("Bridge_AccountSettings", array("set"), array(), "", false);
- $setting->expects($this->once())
+ $setting->expects($this->once())
->method("set")
->with($this->equalTo("auth_token"), $this->isNull());
- $this->object->set_settings($setting);
+ $this->object->set_settings($setting);
- $return = $this->object->disconnect();
+ $return = $this->object->disconnect();
- $this->assertEquals($this->object, $return);
- }
+ $this->assertEquals($this->object, $return);
+ }
- public function testIs_connected()
- {
- $setting = $this->getMock("Bridge_AccountSettings", array("get"), array(), "", false);
+ public function testIs_connected()
+ {
+ $setting = $this->getMock("Bridge_AccountSettings", array("get"), array(), "", false);
- $setting->expects($this->any())
+ $setting->expects($this->any())
->method("get")
->with($this->equalTo("auth_token"))
- ->will($this->onConsecutiveCalls("123456",123456, null));
+ ->will($this->onConsecutiveCalls("123456", 123456, null));
- $this->object->set_settings($setting);
+ $this->object->set_settings($setting);
- $this->assertTrue($this->object->is_connected());
- $this->assertTrue($this->object->is_connected());
- $this->assertFalse($this->object->is_connected());
- }
+ $this->assertTrue($this->object->is_connected());
+ $this->assertTrue($this->object->is_connected());
+ $this->assertFalse($this->object->is_connected());
+ }
- public function testGet_auth_signatures()
- {
- $setting = $this->getMock("Bridge_AccountSettings", array("get"), array(), "", false);
+ public function testGet_auth_signatures()
+ {
+ $setting = $this->getMock("Bridge_AccountSettings", array("get"), array(), "", false);
- $setting->expects($this->once())
+ $setting->expects($this->once())
->method("get")
->with($this->equalTo("auth_token"))
->will($this->returnValue("123"));
- $this->object->set_settings($setting);
+ $this->object->set_settings($setting);
- $return = $this->object->get_auth_signatures();
+ $return = $this->object->get_auth_signatures();
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $return);
- $this->assertArrayHasKey("auth_token", $return);
- $this->assertEquals("123" , $return["auth_token"]);
- }
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $return);
+ $this->assertArrayHasKey("auth_token", $return);
+ $this->assertEquals("123", $return["auth_token"]);
+ }
- public function testSet_parameters()
- {
- $parameters = array(
- "client_id" => "cid"
- ,"allo"=>"hello"
- ,"yo" => "coucou"
- ,"response_type" => "hihi"
- );
+ public function testSet_parameters()
+ {
+ $parameters = array(
+ "client_id" => "cid"
+ , "allo" => "hello"
+ , "yo" => "coucou"
+ , "response_type" => "hihi"
+ );
- $return = $this->object->set_parameters($parameters);
+ $return = $this->object->set_parameters($parameters);
- $this->assertEquals(0 , sizeof(get_object_vars($this->object)));
- $this->assertEquals($return, $this->object);
- }
+ $this->assertEquals(0, sizeof(get_object_vars($this->object)));
+ $this->assertEquals($return, $this->object);
+ }
- public function testGet_auth_url()
- {
- $this->object->set_parameters($this->parameters);
- $expected_url = "one_auth_endpoint?response_type=code&client_id=client_id&redirect_uri=redirect_uri&scope=super_scope";
- $this->assertEquals($expected_url, $this->object->get_auth_url());
+ public function testGet_auth_url()
+ {
+ $this->object->set_parameters($this->parameters);
+ $expected_url = "one_auth_endpoint?response_type=code&client_id=client_id&redirect_uri=redirect_uri&scope=super_scope";
+ $this->assertEquals($expected_url, $this->object->get_auth_url());
- $more_params = array("test" => "test");
- $this->assertEquals($expected_url."&test=test", $this->object->get_auth_url($more_params));
-
- $more_params = array("response_type" => "test");
- $this->assertNotEquals($expected_url, $this->object->get_auth_url($more_params));
- }
+ $more_params = array("test" => "test");
+ $this->assertEquals($expected_url . "&test=test", $this->object->get_auth_url($more_params));
+ $more_params = array("response_type" => "test");
+ $this->assertNotEquals($expected_url, $this->object->get_auth_url($more_params));
+ }
}
diff --git a/tests/Bridge/Api/Bridge_Api_AbstractCollectionTest.php b/tests/Bridge/Api/Bridge_Api_AbstractCollectionTest.php
index b09eb83cf7..85e292dce1 100644
--- a/tests/Bridge/Api/Bridge_Api_AbstractCollectionTest.php
+++ b/tests/Bridge/Api/Bridge_Api_AbstractCollectionTest.php
@@ -5,175 +5,123 @@ require_once __DIR__ . '/../Bridge_datas.inc';
class Bridge_Api_AbstractCollectionTest extends PHPUnit_Framework_TestCase
{
+ /**
+ * @var Bridge_Api_AbstractCollection
+ */
+ protected $object;
- /**
- * @var Bridge_Api_AbstractCollection
- */
- protected $object;
+ public function testGet_total_items()
+ {
+ $stub = $this->getMockForAbstractClass('Bridge_Api_AbstractCollection');
+ $this->assertNull($stub->get_total_items());
+ $stub->set_total_items("3");
+ $this->assertEquals(3, $stub->get_total_items());
+ }
- public function setUp()
- {
+ public function testSet_total_items()
+ {
+ $stub = $this->getMockForAbstractClass('Bridge_Api_AbstractCollection');
+ $return = $stub->set_total_items("3");
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_INT, $stub->get_total_items());
+ $this->assertEquals(3, $stub->get_total_items());
+ $this->assertEquals($return, $stub);
+ }
- }
+ public function testGet_items_per_page()
+ {
+ $stub = $this->getMockForAbstractClass('Bridge_Api_AbstractCollection');
+ $this->assertNull($stub->get_items_per_page());
+ $stub->set_items_per_page("3");
+ $this->assertEquals(3, $stub->get_items_per_page());
+ }
- /**
- * Tears down the fixture, for example, closes a network connection.
- * This method is called after a test is executed.
- */
- public function tearDown()
- {
+ public function testSet_items_per_page()
+ {
+ $stub = $this->getMockForAbstractClass('Bridge_Api_AbstractCollection');
+ $return = $stub->set_items_per_page("3");
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_INT, $stub->get_items_per_page());
+ $this->assertEquals(3, $stub->get_items_per_page());
+ $this->assertEquals($return, $stub);
+ }
- }
+ public function testGet_current_page()
+ {
+ $stub = $this->getMockForAbstractClass('Bridge_Api_AbstractCollection');
+ $this->assertEquals(1, $stub->get_current_page());
+ $stub->set_current_page("3");
+ $this->assertEquals(3, $stub->get_current_page());
+ }
- /**
- * @todo Implement testGet_total_items().
- */
- public function testGet_total_items()
- {
- $stub = $this->getMockForAbstractClass('Bridge_Api_AbstractCollection');
- $this->assertNull($stub->get_total_items());
- $stub->set_total_items("3");
- $this->assertEquals(3, $stub->get_total_items());
- }
+ public function testSet_current_page()
+ {
+ $stub = $this->getMockForAbstractClass('Bridge_Api_AbstractCollection');
+ $return = $stub->set_current_page("3");
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_INT, $stub->get_current_page());
+ $this->assertEquals(3, $stub->get_current_page());
+ $this->assertEquals($return, $stub);
+ $return = $stub->set_current_page(-4);
+ $this->assertEquals(3, $stub->get_current_page());
+ }
- /**
- * @todo Implement testSet_total_items().
- */
- public function testSet_total_items()
- {
- $stub = $this->getMockForAbstractClass('Bridge_Api_AbstractCollection');
- $return = $stub->set_total_items("3");
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_INT, $stub->get_total_items());
- $this->assertEquals(3, $stub->get_total_items());
- $this->assertEquals($return, $stub);
- }
+ public function testGet_total_page()
+ {
+ $stub = $this->getMockForAbstractClass('Bridge_Api_AbstractCollection');
+ $this->assertEquals(1, $stub->get_total_page());
+ $stub->set_total_page("3");
+ $this->assertEquals(3, $stub->get_total_page());
+ }
- /**
- * @todo Implement testGet_items_per_page().
- */
- public function testGet_items_per_page()
- {
- $stub = $this->getMockForAbstractClass('Bridge_Api_AbstractCollection');
- $this->assertNull($stub->get_items_per_page());
- $stub->set_items_per_page("3");
- $this->assertEquals(3, $stub->get_items_per_page());
- }
+ public function testSet_total_page()
+ {
+ $stub = $this->getMockForAbstractClass('Bridge_Api_AbstractCollection');
+ $return = $stub->set_total_page("3");
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_INT, $stub->get_total_page());
+ $this->assertEquals(3, $stub->get_total_page());
+ $this->assertEquals($return, $stub);
+ $return = $stub->set_total_page(-4);
+ $this->assertEquals(3, $stub->get_total_page());
+ }
- /**
- * @todo Implement testSet_items_per_page().
- */
- public function testSet_items_per_page()
- {
- $stub = $this->getMockForAbstractClass('Bridge_Api_AbstractCollection');
- $return = $stub->set_items_per_page("3");
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_INT, $stub->get_items_per_page());
- $this->assertEquals(3, $stub->get_items_per_page());
- $this->assertEquals($return, $stub);
- }
+ public function testHas_next_page()
+ {
+ $stub = $this->getMockForAbstractClass('Bridge_Api_AbstractCollection');
+ $stub->set_current_page(2);
+ $stub->set_total_page(2);
+ $this->assertFalse($stub->has_next_page());
+ $stub->set_current_page(1);
+ $stub->set_total_page(2);
+ $this->assertTrue($stub->has_next_page());
+ $stub->set_current_page(3);
+ $stub->set_total_page(2);
+ $this->assertFalse($stub->has_next_page());
+ }
- /**
- * @todo Implement testGet_current_page().
- */
- public function testGet_current_page()
- {
- $stub = $this->getMockForAbstractClass('Bridge_Api_AbstractCollection');
- $this->assertEquals(1, $stub->get_current_page());
- $stub->set_current_page("3");
- $this->assertEquals(3, $stub->get_current_page());
- }
+ public function testHas_previous_page()
+ {
+ $stub = $this->getMockForAbstractClass('Bridge_Api_AbstractCollection');
+ $stub->set_current_page(2);
+ $this->assertTrue($stub->has_previous_page());
+ $stub->set_current_page(1);
+ $this->assertFalse($stub->has_previous_page());
+ $stub->set_current_page(0);
+ $this->assertFalse($stub->has_previous_page());
+ }
- /**
- * @todo Implement testSet_current_page().
- */
- public function testSet_current_page()
- {
- $stub = $this->getMockForAbstractClass('Bridge_Api_AbstractCollection');
- $return = $stub->set_current_page("3");
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_INT, $stub->get_current_page());
- $this->assertEquals(3, $stub->get_current_page());
- $this->assertEquals($return, $stub);
- $return = $stub->set_current_page(-4);
- $this->assertEquals(3, $stub->get_current_page());
- }
-
- /**
- * @todo Implement testGet_total_page().
- */
- public function testGet_total_page()
- {
- $stub = $this->getMockForAbstractClass('Bridge_Api_AbstractCollection');
- $this->assertEquals(1, $stub->get_total_page());
- $stub->set_total_page("3");
- $this->assertEquals(3, $stub->get_total_page());
- }
-
- /**
- * @todo Implement testSet_total_page().
- */
- public function testSet_total_page()
- {
- $stub = $this->getMockForAbstractClass('Bridge_Api_AbstractCollection');
- $return = $stub->set_total_page("3");
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_INT, $stub->get_total_page());
- $this->assertEquals(3, $stub->get_total_page());
- $this->assertEquals($return, $stub);
- $return = $stub->set_total_page(-4);
- $this->assertEquals(3, $stub->get_total_page());
- }
-
- /**
- * @todo Implement testHas_next_page().
- */
- public function testHas_next_page()
- {
- $stub = $this->getMockForAbstractClass('Bridge_Api_AbstractCollection');
- $stub->set_current_page(2);
- $stub->set_total_page(2);
- $this->assertFalse($stub->has_next_page());
- $stub->set_current_page(1);
- $stub->set_total_page(2);
- $this->assertTrue($stub->has_next_page());
- $stub->set_current_page(3);
- $stub->set_total_page(2);
- $this->assertFalse($stub->has_next_page());
- }
-
- /**
- * @todo Implement testHas_previous_page().
- */
- public function testHas_previous_page()
- {
- $stub = $this->getMockForAbstractClass('Bridge_Api_AbstractCollection');
- $stub->set_current_page(2);
- $this->assertTrue($stub->has_previous_page());
- $stub->set_current_page(1);
- $this->assertFalse($stub->has_previous_page());
- $stub->set_current_page(0);
- $this->assertFalse($stub->has_previous_page());
- }
-
- /**
- * @todo Implement testHas_more_than_one_page().
- */
- public function testHas_more_than_one_page()
- {
- $stub = $this->getMockForAbstractClass('Bridge_Api_AbstractCollection');
- $stub->set_total_page(2);
- $this->assertTrue($stub->has_more_than_one_page());
- $stub->set_total_page(1);
- $this->assertFalse($stub->has_more_than_one_page());
- $stub->set_total_page(0);
- $this->assertFalse($stub->has_more_than_one_page());
- }
-
- /**
- * @todo Implement testGet_elements().
- */
- public function testGet_elements()
- {
- $stub = $this->getMockForAbstractClass('Bridge_Api_AbstractCollection');
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $stub->get_elements());
- $this->assertEquals(array(), $stub->get_elements());
- }
+ public function testHas_more_than_one_page()
+ {
+ $stub = $this->getMockForAbstractClass('Bridge_Api_AbstractCollection');
+ $stub->set_total_page(2);
+ $this->assertTrue($stub->has_more_than_one_page());
+ $stub->set_total_page(1);
+ $this->assertFalse($stub->has_more_than_one_page());
+ $stub->set_total_page(0);
+ $this->assertFalse($stub->has_more_than_one_page());
+ }
+ public function testGet_elements()
+ {
+ $stub = $this->getMockForAbstractClass('Bridge_Api_AbstractCollection');
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $stub->get_elements());
+ $this->assertEquals(array(), $stub->get_elements());
+ }
}
diff --git a/tests/Bridge/Api/Bridge_Api_AbstractTest.php b/tests/Bridge/Api/Bridge_Api_AbstractTest.php
index 526edd6d78..d0073616fe 100644
--- a/tests/Bridge/Api/Bridge_Api_AbstractTest.php
+++ b/tests/Bridge/Api/Bridge_Api_AbstractTest.php
@@ -5,250 +5,202 @@ require_once __DIR__ . '/../Bridge_datas.inc';
class Bridge_Api_AbstractTest extends PhraseanetWebTestCaseAuthenticatedAbstract
{
+ public static $account = null;
+ public static $api = null;
- public static $account = null;
- public static $api = null;
+ /**
+ * @var Bridge_Api_Abstract
+ */
+ protected $auth;
- /**
- * @var Bridge_Api_Abstract
- */
- protected $auth;
-
- public function setUp()
- {
- $this->auth = $this->getMock("Bridge_Api_Auth_Interface");
- }
-
- /**
- * Tears down the fixture, for example, closes a network connection.
- * This method is called after a test is executed.
- */
- public function tearDown()
- {
-
- }
-
- public static function setUpBeforeClass()
- {
- parent::setUpBeforeClass();
- try
+ public function setUp()
{
- self::$api = Bridge_Api::get_by_api_name(appbox::get_instance(\bootstrap::getCore()), 'apitest');
- }
- catch (Bridge_Exception_ApiNotFound $e)
- {
- self::$api = Bridge_Api::create(appbox::get_instance(\bootstrap::getCore()), 'apitest');
+ parent::setUp();
+ $this->auth = $this->getMock("Bridge_Api_Auth_Interface");
}
- try
+ public static function setUpBeforeClass()
{
- self::$account = Bridge_Account::load_account_from_distant_id(appbox::get_instance(\bootstrap::getCore()), self::$api, self::$user, 'kirikoo');
+ parent::setUpBeforeClass();
+ try {
+ self::$api = Bridge_Api::get_by_api_name(appbox::get_instance(\bootstrap::getCore()), 'apitest');
+ } catch (Bridge_Exception_ApiNotFound $e) {
+ self::$api = Bridge_Api::create(appbox::get_instance(\bootstrap::getCore()), 'apitest');
+ }
+
+ try {
+ self::$account = Bridge_Account::load_account_from_distant_id(appbox::get_instance(\bootstrap::getCore()), self::$api, self::$user, 'kirikoo');
+ } catch (Bridge_Exception_AccountNotFound $e) {
+ self::$account = Bridge_Account::create(appbox::get_instance(\bootstrap::getCore()), self::$api, self::$user, 'kirikoo', 'coucou');
+ }
}
- catch (Bridge_Exception_AccountNotFound $e)
+
+ public static function tearDownAfterClass()
{
- self::$account = Bridge_Account::create(appbox::get_instance(\bootstrap::getCore()), self::$api, self::$user, 'kirikoo', 'coucou');
+ self::$api->delete();
+ if (self::$account instanceof Bridge_Account) {
+ self::$account->delete();
+ }
+ parent::tearDownAfterClass();
}
- }
- public static function tearDownAfterClass()
- {
- parent::tearDownAfterClass();
- self::$api->delete();
- if (self::$account instanceof Bridge_Account)
- self::$account->delete();
- }
+ public function testSet_auth_settings()
+ {
+ $stub = $this->getMockForAbstractClass('Bridge_Api_Abstract', array(registry::get_instance(), $this->auth, "Mock_Bridge_Api_Abstract"));
- /**
- * @todo Implement testSet_auth_settings().
- */
- public function testSet_auth_settings()
- {
- $stub = $this->getMockForAbstractClass('Bridge_Api_Abstract', array(registry::get_instance(), $this->auth, "Mock_Bridge_Api_Abstract"));
+ $settings = self::$account->get_settings();
- $settings = self::$account->get_settings();
-
- $stub->expects($this->once())
+ $stub->expects($this->once())
->method('set_transport_authentication_params');
- $return = $stub->set_auth_settings($settings);
+ $return = $stub->set_auth_settings($settings);
- $this->assertEquals($stub, $return);
- }
+ $this->assertEquals($stub, $return);
+ }
- /**
- * @todo Implement testConnect().
- */
- public function testConnectGood()
- {
- $stub = $this->getMock('Bridge_Api_Abstract', array("is_configured", "initialize_transport", "set_auth_params", "set_transport_authentication_params"), array(registry::get_instance(), $this->auth, "Mock_Bridge_Api_Abstract"));
+ public function testConnectGood()
+ {
+ $stub = $this->getMock('Bridge_Api_Abstract', array("is_configured", "initialize_transport", "set_auth_params", "set_transport_authentication_params"), array(registry::get_instance(), $this->auth, "Mock_Bridge_Api_Abstract"));
- $stub->expects($this->once())
+ $stub->expects($this->once())
->method('is_configured')
->will($this->returnValue(TRUE));
- $this->auth->expects($this->once())
+ $this->auth->expects($this->once())
->method('parse_request_token')
->will($this->returnValue("token"));
- $this->auth->expects($this->once())
+ $this->auth->expects($this->once())
->method('connect')
->will($this->returnValue(array("coucou")));
- $return = $stub->connect();
+ $return = $stub->connect();
- $this->assertEquals(array("coucou"), $return);
- }
+ $this->assertEquals(array("coucou"), $return);
+ }
- public function testConnectBad()
- {
- $stub = $this->getMock('Bridge_Api_Abstract', array("is_configured", "initialize_transport", "set_auth_params", "set_transport_authentication_params"), array(registry::get_instance(), $this->auth, "Mock_Bridge_Api_Abstract"));
+ public function testConnectBad()
+ {
+ $stub = $this->getMock('Bridge_Api_Abstract', array("is_configured", "initialize_transport", "set_auth_params", "set_transport_authentication_params"), array(registry::get_instance(), $this->auth, "Mock_Bridge_Api_Abstract"));
- $stub->expects($this->once())
+ $stub->expects($this->once())
->method('is_configured')
->will($this->returnValue(FALSE));
- $this->setExpectedException("Bridge_Exception_ApiConnectorNotConfigured");
+ $this->setExpectedException("Bridge_Exception_ApiConnectorNotConfigured");
- $stub->connect();
- }
+ $stub->connect();
+ }
- /**
- * @todo Implement testReconnect().
- */
- public function testReconnect()
- {
- $stub = $this->getMock('Bridge_Api_Abstract', array("is_configured", "initialize_transport", "set_auth_params", "set_transport_authentication_params"), array(registry::get_instance(), $this->auth, "Mock_Bridge_Api_Abstract"));
+ public function testReconnect()
+ {
+ $stub = $this->getMock('Bridge_Api_Abstract', array("is_configured", "initialize_transport", "set_auth_params", "set_transport_authentication_params"), array(registry::get_instance(), $this->auth, "Mock_Bridge_Api_Abstract"));
- $stub->expects($this->once())
+ $stub->expects($this->once())
->method('is_configured')
->will($this->returnValue(TRUE));
- $this->auth->expects($this->once())
+ $this->auth->expects($this->once())
->method('reconnect');
- $return = $stub->reconnect();
+ $return = $stub->reconnect();
- $this->assertEquals($stub, $return);
- }
+ $this->assertEquals($stub, $return);
+ }
- /**
- * @todo Implement testReconnect().
- */
- public function testReconnectBad()
- {
- $stub = $this->getMock('Bridge_Api_Abstract', array("is_configured", "initialize_transport", "set_auth_params", "set_transport_authentication_params"), array(registry::get_instance(), $this->auth, "Mock_Bridge_Api_Abstract"));
+ public function testReconnectBad()
+ {
+ $stub = $this->getMock('Bridge_Api_Abstract', array("is_configured", "initialize_transport", "set_auth_params", "set_transport_authentication_params"), array(registry::get_instance(), $this->auth, "Mock_Bridge_Api_Abstract"));
- $stub->expects($this->once())
+ $stub->expects($this->once())
->method('is_configured')
->will($this->returnValue(FALSE));
- $this->setExpectedException("Bridge_Exception_ApiConnectorNotConfigured");
+ $this->setExpectedException("Bridge_Exception_ApiConnectorNotConfigured");
- $stub->reconnect();
- }
+ $stub->reconnect();
+ }
- /**
- * @todo Implement testDisconnect().
- */
- public function testDisconnect()
- {
- $stub = $this->getMock('Bridge_Api_Abstract', array("is_configured", "initialize_transport", "set_auth_params", "set_transport_authentication_params"), array(registry::get_instance(), $this->auth, "Mock_Bridge_Api_Abstract"));
+ public function testDisconnect()
+ {
+ $stub = $this->getMock('Bridge_Api_Abstract', array("is_configured", "initialize_transport", "set_auth_params", "set_transport_authentication_params"), array(registry::get_instance(), $this->auth, "Mock_Bridge_Api_Abstract"));
- $stub->expects($this->once())
+ $stub->expects($this->once())
->method('is_configured')
->will($this->returnValue(TRUE));
- $this->auth->expects($this->once())
+ $this->auth->expects($this->once())
->method('disconnect');
- $return = $stub->disconnect();
+ $return = $stub->disconnect();
- $this->assertEquals($stub, $return);
- }
+ $this->assertEquals($stub, $return);
+ }
- /**
- * @todo Implement testDisconnect().
- */
- public function testDisconnectBad()
- {
- $stub = $this->getMock('Bridge_Api_Abstract', array("is_configured", "initialize_transport", "set_auth_params", "set_transport_authentication_params"), array(registry::get_instance(), $this->auth, "Mock_Bridge_Api_Abstract"));
+ public function testDisconnectBad()
+ {
+ $stub = $this->getMock('Bridge_Api_Abstract', array("is_configured", "initialize_transport", "set_auth_params", "set_transport_authentication_params"), array(registry::get_instance(), $this->auth, "Mock_Bridge_Api_Abstract"));
- $stub->expects($this->once())
+ $stub->expects($this->once())
->method('is_configured')
->will($this->returnValue(FALSE));
- $this->setExpectedException("Bridge_Exception_ApiConnectorNotConfigured");
+ $this->setExpectedException("Bridge_Exception_ApiConnectorNotConfigured");
- $stub->disconnect();
- }
+ $stub->disconnect();
+ }
- /**
- * @todo Implement testIs_connected().
- */
- public function testIs_connected()
- {
- $stub = $this->getMockForAbstractClass('Bridge_Api_Abstract', array(registry::get_instance(), $this->auth, "Mock_Bridge_Api_Abstract"));
+ public function testIs_connected()
+ {
+ $stub = $this->getMockForAbstractClass('Bridge_Api_Abstract', array(registry::get_instance(), $this->auth, "Mock_Bridge_Api_Abstract"));
- $this->auth->expects($this->once())
+ $this->auth->expects($this->once())
->method('is_connected')
->will($this->returnValue(TRUE));
- $return = $stub->is_connected();
+ $return = $stub->is_connected();
- $this->assertEquals(TRUE, $return);
- }
+ $this->assertEquals(TRUE, $return);
+ }
- /**
- * @todo Implement testGet_auth_url().
- */
- public function testGet_auth_url()
- {
- $stub = $this->getMockForAbstractClass('Bridge_Api_Abstract', array(registry::get_instance(), $this->auth, "Mock_Bridge_Api_Abstract"));
+ public function testGet_auth_url()
+ {
+ $stub = $this->getMockForAbstractClass('Bridge_Api_Abstract', array(registry::get_instance(), $this->auth, "Mock_Bridge_Api_Abstract"));
- $this->auth->expects($this->once())
+ $this->auth->expects($this->once())
->method('get_auth_url')
->with($this->isType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY))
->will($this->returnValue("une url"));
- $return = $stub->get_auth_url();
+ $return = $stub->get_auth_url();
- $this->assertEquals("une url", $return);
- }
+ $this->assertEquals("une url", $return);
+ }
- /**
- * @todo Implement testSet_locale().
- */
- public function testSet_locale()
- {
- $stub = $this->getMockForAbstractClass('Bridge_Api_Abstract', array(registry::get_instance(), $this->auth, "Mock_Bridge_Api_Abstract"));
+ public function testSet_locale()
+ {
+ $stub = $this->getMockForAbstractClass('Bridge_Api_Abstract', array(registry::get_instance(), $this->auth, "Mock_Bridge_Api_Abstract"));
- $stub->set_locale("fr");
+ $stub->set_locale("fr");
- $this->assertEquals("fr", $stub->get_locale());
- }
+ $this->assertEquals("fr", $stub->get_locale());
+ }
- /**
- * @todo Implement testIs_valid_object_id().
- */
- public function testIs_valid_object_id()
- {
- $stub = $this->getMockForAbstractClass('Bridge_Api_Abstract', array(registry::get_instance(), $this->auth, "Mock_Bridge_Api_Abstract"));
+ public function testIs_valid_object_id()
+ {
+ $stub = $this->getMockForAbstractClass('Bridge_Api_Abstract', array(registry::get_instance(), $this->auth, "Mock_Bridge_Api_Abstract"));
- $this->assertTrue($stub->is_valid_object_id("abc"));
- $this->assertTrue($stub->is_valid_object_id(123));
- $this->assertTrue($stub->is_valid_object_id(12.25));
- $this->assertFalse($stub->is_valid_object_id(array()));
- $this->assertFalse($stub->is_valid_object_id(true));
- }
-
- /**
- * @todo Implement testHandle_exception().
- */
- public function testHandle_exception()
- {
- $stub = $this->getMockForAbstractClass('Bridge_Api_Abstract', array(registry::get_instance(), $this->auth, "Mock_Bridge_Api_Abstract"));
- $e = new Exception("hihi");
- $void = $stub->handle_exception($e);
- $this->assertNull($void);
- }
+ $this->assertTrue($stub->is_valid_object_id("abc"));
+ $this->assertTrue($stub->is_valid_object_id(123));
+ $this->assertTrue($stub->is_valid_object_id(12.25));
+ $this->assertFalse($stub->is_valid_object_id(array()));
+ $this->assertFalse($stub->is_valid_object_id(true));
+ }
+ public function testHandle_exception()
+ {
+ $stub = $this->getMockForAbstractClass('Bridge_Api_Abstract', array(registry::get_instance(), $this->auth, "Mock_Bridge_Api_Abstract"));
+ $e = new Exception("hihi");
+ $void = $stub->handle_exception($e);
+ $this->assertNull($void);
+ }
}
diff --git a/tests/Bridge/Api/Bridge_Api_ContainerCollectionTest.php b/tests/Bridge/Api/Bridge_Api_ContainerCollectionTest.php
index d7774a457b..f479a41de9 100644
--- a/tests/Bridge/Api/Bridge_Api_ContainerCollectionTest.php
+++ b/tests/Bridge/Api/Bridge_Api_ContainerCollectionTest.php
@@ -5,17 +5,16 @@ require_once __DIR__ . '/../Bridge_datas.inc';
class Bridge_Api_ContainerCollectionTest extends PHPUnit_Framework_TestCase
{
- public function testAdd_element()
- {
- $collection = new Bridge_Api_ContainerCollection();
- $i = 0;
- while($i < 5)
- {
- $container = $this->getMock("Bridge_Api_ContainerInterface");
- $collection->add_element(new $container);
- $i++;
- }
- $this->assertEquals(5, sizeof($collection->get_elements()));
- }
+ public function testAdd_element()
+ {
+ $collection = new Bridge_Api_ContainerCollection();
+ $i = 0;
+ while ($i < 5) {
+ $container = $this->getMock("Bridge_Api_ContainerInterface");
+ $collection->add_element(new $container);
+ $i ++;
+ }
+ $this->assertEquals(5, sizeof($collection->get_elements()));
+ }
}
diff --git a/tests/Bridge/Api/Bridge_Api_DailymotionTest.php b/tests/Bridge/Api/Bridge_Api_DailymotionTest.php
deleted file mode 100644
index a6f3430d72..0000000000
--- a/tests/Bridge/Api/Bridge_Api_DailymotionTest.php
+++ /dev/null
@@ -1,348 +0,0 @@
-object = $this->getMock("Bridge_Api_Dailymotion", array("initialize_transport", "set_auth_params"), array(registry::get_instance(), $this->getMock("Bridge_Api_Auth_Interface")));
-
- }
-
- /**
- * Tears down the fixture, for example, closes a network connection.
- * This method is called after a test is executed.
- */
- protected function tearDown()
- {
-
- }
-
- /**
- * @todo Implement testConnect().
- */
- public function testConnect()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testReconnect().
- */
- public function testReconnect()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_user_id().
- */
- public function testGet_user_id()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_user_name().
- */
- public function testGet_user_name()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_name().
- */
- public function testGet_name()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_icon_url().
- */
- public function testGet_icon_url()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_image_url().
- */
- public function testGet_image_url()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_url().
- */
- public function testGet_url()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_infos().
- */
- public function testGet_infos()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_default_element_type().
- */
- public function testGet_default_element_type()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_default_container_type().
- */
- public function testGet_default_container_type()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_element_types().
- */
- public function testGet_element_types()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_container_types().
- */
- public function testGet_container_types()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_object_class_from_type().
- */
- public function testGet_object_class_from_type()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testList_elements().
- */
- public function testList_elements()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testList_containers().
- */
- public function testList_containers()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testUpdate_element().
- */
- public function testUpdate_element()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testCreate_container().
- */
- public function testCreate_container()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testAdd_element_to_container().
- */
- public function testAdd_element_to_container()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testDelete_object().
- */
- public function testDelete_object()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testAcceptable_records().
- */
- public function testAcceptable_records()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_element_status().
- */
- public function testGet_element_status()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testMap_connector_to_element_status().
- */
- public function testMap_connector_to_element_status()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_error_message_from_status().
- */
- public function testGet_error_message_from_status()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testHandle_exception().
- */
- public function testHandle_exception()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testUpload().
- */
- public function testUpload()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_element_from_id().
- */
- public function testGet_element_from_id()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_container_from_id().
- */
- public function testGet_container_from_id()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_category_list().
- */
- public function testGet_category_list()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
-}
diff --git a/tests/Bridge/Api/Bridge_Api_ElementCollectionTest.php b/tests/Bridge/Api/Bridge_Api_ElementCollectionTest.php
index e20f5de786..19d6ed7e4a 100644
--- a/tests/Bridge/Api/Bridge_Api_ElementCollectionTest.php
+++ b/tests/Bridge/Api/Bridge_Api_ElementCollectionTest.php
@@ -6,17 +6,15 @@ require_once __DIR__ . '/../Bridge_datas.inc';
class Bridge_Api_ElementCollectionTest extends PHPUnit_Framework_TestCase
{
- public function testAdd_element()
- {
- $collection = new Bridge_Api_ElementCollection();
- $i = 0;
- while($i < 5)
+ public function testAdd_element()
{
- $element = $this->getMock("Bridge_Api_ElementInterface");
- $collection->add_element(new $element);
- $i++;
+ $collection = new Bridge_Api_ElementCollection();
+ $i = 0;
+ while ($i < 5) {
+ $element = $this->getMock("Bridge_Api_ElementInterface");
+ $collection->add_element(new $element);
+ $i ++;
+ }
+ $this->assertEquals(5, sizeof($collection->get_elements()));
}
- $this->assertEquals(5, sizeof($collection->get_elements()));
- }
-
}
diff --git a/tests/Bridge/Api/Bridge_Api_FlickrTest.php b/tests/Bridge/Api/Bridge_Api_FlickrTest.php
deleted file mode 100644
index fa547fc2f0..0000000000
--- a/tests/Bridge/Api/Bridge_Api_FlickrTest.php
+++ /dev/null
@@ -1,336 +0,0 @@
-object = $this->getMock("Bridge_Api_Flickr", array("initialize_transport", "set_auth_params"), array(registry::get_instance(), $this->getMock("Bridge_Api_Auth_Interface")));
- }
-
- /**
- * Tears down the fixture, for example, closes a network connection.
- * This method is called after a test is executed.
- */
- public function tearDown()
- {
-
- }
-
- /**
- * @todo Implement testConnect().
- */
- public function testConnect()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testDisconnect().
- */
- public function testDisconnect()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_user_name().
- */
- public function testGet_user_name()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_user_id().
- */
- public function testGet_user_id()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_name().
- */
- public function testGet_name()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_icon_url().
- */
- public function testGet_icon_url()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_image_url().
- */
- public function testGet_image_url()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_url().
- */
- public function testGet_url()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_infos().
- */
- public function testGet_infos()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_default_element_type().
- */
- public function testGet_default_element_type()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_default_container_type().
- */
- public function testGet_default_container_type()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_element_from_id().
- */
- public function testGet_element_from_id()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_container_from_id().
- */
- public function testGet_container_from_id()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testList_containers().
- */
- public function testList_containers()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testUpdate_element().
- */
- public function testUpdate_element()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testCreate_container().
- */
- public function testCreate_container()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testAdd_element_to_container().
- */
- public function testAdd_element_to_container()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testDelete_object().
- */
- public function testDelete_object()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testList_elements().
- */
- public function testList_elements()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_element_status().
- */
- public function testGet_element_status()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testMap_connector_to_element_status().
- */
- public function testMap_connector_to_element_status()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_error_message_from_status().
- */
- public function testGet_error_message_from_status()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testUpload().
- */
- public function testUpload()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testAcceptable_records().
- */
- public function testAcceptable_records()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_object_class_from_type().
- */
- public function testGet_object_class_from_type()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_element_types().
- */
- public function testGet_element_types()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_container_types().
- */
- public function testGet_container_types()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_category_list().
- */
- public function testGet_category_list()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
-}
diff --git a/tests/Bridge/Api/Bridge_Api_YoutubeTest.php b/tests/Bridge/Api/Bridge_Api_YoutubeTest.php
deleted file mode 100644
index 2af43f91b1..0000000000
--- a/tests/Bridge/Api/Bridge_Api_YoutubeTest.php
+++ /dev/null
@@ -1,339 +0,0 @@
-object = $this->getMock("Bridge_Api_Youtube", array("initialize_transport", "set_auth_params"), array(registry::get_instance(), $this->getMock("Bridge_Api_Auth_Interface")));
- }
-
- /**
- * @todo Implement testConnect().
- */
- public function testConnect()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testReconnect().
- */
- public function testReconnect()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_user_id().
- */
- public function testGet_user_id()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_user_name().
- */
- public function testGet_user_name()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_name().
- */
- public function testGet_name()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_icon_url().
- */
- public function testGet_icon_url()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_image_url().
- */
- public function testGet_image_url()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_url().
- */
- public function testGet_url()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_infos().
- */
- public function testGet_infos()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_default_element_type().
- */
- public function testGet_default_element_type()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_default_container_type().
- */
- public function testGet_default_container_type()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_element_types().
- */
- public function testGet_element_types()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_container_types().
- */
- public function testGet_container_types()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_object_class_from_type().
- */
- public function testGet_object_class_from_type()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testList_elements().
- */
- public function testList_elements()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testList_containers().
- */
- public function testList_containers()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testUpdate_element().
- */
- public function testUpdate_element()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testCreate_container().
- */
- public function testCreate_container()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testAdd_element_to_container().
- */
- public function testAdd_element_to_container()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testDelete_object().
- */
- public function testDelete_object()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testAcceptable_records().
- */
- public function testAcceptable_records()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_element_status().
- */
- public function testGet_element_status()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testMap_connector_to_element_status().
- */
- public function testMap_connector_to_element_status()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_error_message_from_status().
- */
- public function testGet_error_message_from_status()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testHandle_exception().
- */
- public function testHandle_exception()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testUpload().
- */
- public function testUpload()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
-
- /**
- * @todo Implement testGet_element_from_id().
- */
- public function testGet_element_from_id()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_category_list().
- */
- public function testGet_category_list()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_container_from_id().
- */
- public function testGet_container_from_id()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
-}
diff --git a/tests/Bridge/Api/Dailymotion/Bridge_Api_Dailymotion_ContainerTest.php b/tests/Bridge/Api/Dailymotion/Bridge_Api_Dailymotion_ContainerTest.php
index b1cd6a6eef..d687faefab 100644
--- a/tests/Bridge/Api/Dailymotion/Bridge_Api_Dailymotion_ContainerTest.php
+++ b/tests/Bridge/Api/Dailymotion/Bridge_Api_Dailymotion_ContainerTest.php
@@ -1,107 +1,82 @@
test = array(
+ 'id' => '01234567'
+ , 'description' => 'one description'
+ , 'name' => 'hello container'
+ );
+ }
- protected function setUp()
- {
- $this->test = array(
- 'id' => '01234567'
- ,'description' => 'one description'
- , 'name' => 'hello container'
- );
- }
+ public function testGet_created_on()
+ {
+ $this->object = new Bridge_Api_Dailymotion_Container($this->test, 'playlist', 'thumb', 'url');
+ $this->assertNull($this->object->get_created_on());
+ }
- /**
- * @todo Implement testGet_created_on().
- */
- public function testGet_created_on()
- {
- $this->object = new Bridge_Api_Dailymotion_Container($this->test, 'playlist', 'thumb', 'url');
- $this->assertNull($this->object->get_created_on());
- }
+ public function testGet_description()
+ {
+ $this->object = new Bridge_Api_Dailymotion_Container($this->test, 'playlist', 'thumb', 'url');
+ $this->assertEquals($this->test['description'], $this->object->get_description());
+ unset($this->test["description"]);
+ $this->object = new Bridge_Api_Dailymotion_Element($this->test, 'blabla');
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_description());
+ $this->assertEmpty($this->object->get_description());
+ }
- /**
- * @todo Implement testGet_description().
- */
- public function testGet_description()
- {
- $this->object = new Bridge_Api_Dailymotion_Container($this->test, 'playlist', 'thumb', 'url');
- $this->assertEquals($this->test['description'], $this->object->get_description());
- unset($this->test["description"]);
- $this->object = new Bridge_Api_Dailymotion_Element($this->test, 'blabla');
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_description());
- $this->assertEmpty($this->object->get_description());
- }
+ public function testGet_id()
+ {
+ $this->object = new Bridge_Api_Dailymotion_Container($this->test, 'playlist', 'thumb', 'url');
+ $this->assertEquals($this->test['id'], $this->object->get_id());
+ unset($this->test["id"]);
+ $this->object = new Bridge_Api_Dailymotion_Element($this->test, 'blabla');
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_id());
+ $this->assertEmpty($this->object->get_id());
+ }
- /**
- * @todo Implement testGet_id().
- */
- public function testGet_id()
- {
- $this->object = new Bridge_Api_Dailymotion_Container($this->test, 'playlist', 'thumb', 'url');
- $this->assertEquals($this->test['id'], $this->object->get_id());
- unset($this->test["id"]);
- $this->object = new Bridge_Api_Dailymotion_Element($this->test, 'blabla');
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_id());
- $this->assertEmpty($this->object->get_id());
- }
+ public function testGet_thumbnail()
+ {
+ $this->object = new Bridge_Api_Dailymotion_Container($this->test, 'playlist', 'thumb', 'url');
+ $this->assertEquals('thumb', $this->object->get_thumbnail());
+ }
- /**
- * @todo Implement testGet_thumbnail().
- */
- public function testGet_thumbnail()
- {
- $this->object = new Bridge_Api_Dailymotion_Container($this->test, 'playlist', 'thumb', 'url');
- $this->assertEquals('thumb', $this->object->get_thumbnail());
- }
+ public function testGet_title()
+ {
+ $this->object = new Bridge_Api_Dailymotion_Container($this->test, 'playlist', 'thumb', 'url');
+ $this->assertEquals($this->test['name'], $this->object->get_title());
+ unset($this->test["name"]);
+ $this->object = new Bridge_Api_Dailymotion_Element($this->test, 'blabla');
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_title());
+ $this->assertEmpty($this->object->get_title());
+ }
- /**
- * @todo Implement testGet_title().
- */
- public function testGet_title()
- {
- $this->object = new Bridge_Api_Dailymotion_Container($this->test, 'playlist', 'thumb', 'url');
- $this->assertEquals($this->test['name'], $this->object->get_title());
- unset($this->test["name"]);
- $this->object = new Bridge_Api_Dailymotion_Element($this->test, 'blabla');
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_title());
- $this->assertEmpty($this->object->get_title());
- }
+ public function testGet_type()
+ {
+ $this->object = new Bridge_Api_Dailymotion_Container($this->test, 'playlist', 'thumb', 'url');
+ $this->assertEquals('playlist', $this->object->get_type());
+ }
- /**
- * @todo Implement testGet_type().
- */
- public function testGet_type()
- {
- $this->object = new Bridge_Api_Dailymotion_Container($this->test, 'playlist', 'thumb', 'url');
- $this->assertEquals('playlist', $this->object->get_type());
- }
-
- /**
- * @todo Implement testGet_updated_on().
- */
- public function testGet_updated_on()
- {
- $this->object = new Bridge_Api_Dailymotion_Container($this->test, 'playlist', 'thumb', 'url');
- $this->assertNull($this->object->get_updated_on());
- }
-
- /**
- * @todo Implement testGet_url().
- */
- public function testGet_url()
- {
- $this->object = new Bridge_Api_Dailymotion_Container($this->test, 'playlist', 'thumb', 'url');
- $this->assertEquals('url', $this->object->get_url());
- }
+ public function testGet_updated_on()
+ {
+ $this->object = new Bridge_Api_Dailymotion_Container($this->test, 'playlist', 'thumb', 'url');
+ $this->assertNull($this->object->get_updated_on());
+ }
+ public function testGet_url()
+ {
+ $this->object = new Bridge_Api_Dailymotion_Container($this->test, 'playlist', 'thumb', 'url');
+ $this->assertEquals('url', $this->object->get_url());
+ }
}
diff --git a/tests/Bridge/Api/Dailymotion/Bridge_Api_Dailymotion_ElementTest.php b/tests/Bridge/Api/Dailymotion/Bridge_Api_Dailymotion_ElementTest.php
index 4503f3b55f..29d574c150 100644
--- a/tests/Bridge/Api/Dailymotion/Bridge_Api_Dailymotion_ElementTest.php
+++ b/tests/Bridge/Api/Dailymotion/Bridge_Api_Dailymotion_ElementTest.php
@@ -6,155 +6,153 @@ require_once __DIR__ . '/../../../../lib/classes/Bridge/Api/Dailymotion/Element.
class Bridge_Api_Dailymotion_ElementTest extends PHPUnit_Framework_TestCase
{
+ /**
+ * @var Bridge_Api_Dailymotion_Element
+ */
+ protected $object;
+ protected $test;
- /**
- * @var Bridge_Api_Dailymotion_Element
- */
- protected $object;
- protected $test;
+ public function setUp()
+ {
+ $this->test = array(
+ 'created_time' => time()
+ , 'description' => 'Description of a dailymotion element'
+ , 'id' => "1"
+ , 'thumbnail_medium_url' => 'thumbnail_medium_url'
+ , 'title' => 'title of dailymotion lement'
+ , 'modified_time' => time()
+ , 'url' => 'www.my.element/url'
+ , 'private' => 1
+ , 'views_total' => '34'
+ , 'ratings_total' => '4'
+ , 'duration' => 80
+ , 'channel' => 'animation'
+ );
+ }
- public function setUp()
- {
- $this->test = array(
- 'created_time' => time()
- , 'description' => 'Description of a dailymotion element'
- , 'id' => "1"
- , 'thumbnail_medium_url' => 'thumbnail_medium_url'
- , 'title' => 'title of dailymotion lement'
- , 'modified_time' => time()
- , 'url' => 'www.my.element/url'
- , 'private' => 1
- , 'views_total' => '34'
- , 'ratings_total' => '4'
- , 'duration' => 80
- , 'channel' => 'animation'
- );
- }
+ public function testGet_created_on()
+ {
+ $this->object = new Bridge_Api_Dailymotion_Element($this->test, 'blabla');
+ $this->assertEquals(DateTime::createFromFormat('U', $this->test['created_time']), $this->object->get_created_on());
+ }
- public function testGet_created_on()
- {
- $this->object = new Bridge_Api_Dailymotion_Element($this->test, 'blabla');
- $this->assertEquals(DateTime::createFromFormat('U', $this->test['created_time']), $this->object->get_created_on());
- }
+ public function testGet_description()
+ {
+ $this->object = new Bridge_Api_Dailymotion_Element($this->test, 'blabla');
+ $this->assertEquals($this->test['description'], $this->object->get_description());
+ unset($this->test["description"]);
+ $this->object = new Bridge_Api_Dailymotion_Element($this->test, 'blabla');
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_description());
+ $this->assertEmpty($this->object->get_description());
+ }
- public function testGet_description()
- {
- $this->object = new Bridge_Api_Dailymotion_Element($this->test, 'blabla');
- $this->assertEquals($this->test['description'], $this->object->get_description());
- unset($this->test["description"]);
- $this->object = new Bridge_Api_Dailymotion_Element($this->test, 'blabla');
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_description());
- $this->assertEmpty($this->object->get_description());
- }
+ public function testGet_id()
+ {
+ $this->object = new Bridge_Api_Dailymotion_Element($this->test, 'blabla');
+ $this->assertEquals($this->test['id'], $this->object->get_id());
+ unset($this->test["id"]);
+ $this->object = new Bridge_Api_Dailymotion_Element($this->test, 'blabla');
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_description());
+ $this->assertEmpty($this->object->get_id());
+ }
- public function testGet_id()
- {
- $this->object = new Bridge_Api_Dailymotion_Element($this->test, 'blabla');
- $this->assertEquals($this->test['id'], $this->object->get_id());
- unset($this->test["id"]);
- $this->object = new Bridge_Api_Dailymotion_Element($this->test, 'blabla');
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_description());
- $this->assertEmpty($this->object->get_id());
- }
+ public function testGet_thumbnail()
+ {
+ $this->object = new Bridge_Api_Dailymotion_Element($this->test, 'blabla');
+ $this->assertEquals($this->test['thumbnail_medium_url'], $this->object->get_thumbnail());
+ unset($this->test["thumbnail_medium_url"]);
+ $this->object = new Bridge_Api_Dailymotion_Element($this->test, 'blabla');
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_thumbnail());
+ $this->assertEmpty($this->object->get_thumbnail());
+ }
- public function testGet_thumbnail()
- {
- $this->object = new Bridge_Api_Dailymotion_Element($this->test, 'blabla');
- $this->assertEquals($this->test['thumbnail_medium_url'], $this->object->get_thumbnail());
- unset($this->test["thumbnail_medium_url"]);
- $this->object = new Bridge_Api_Dailymotion_Element($this->test, 'blabla');
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_thumbnail());
- $this->assertEmpty($this->object->get_thumbnail());
- }
+ public function testGet_title()
+ {
+ $this->object = new Bridge_Api_Dailymotion_Element($this->test, 'blabla');
+ $this->assertEquals($this->test['title'], $this->object->get_title());
+ unset($this->test["title"]);
+ $this->object = new Bridge_Api_Dailymotion_Element($this->test, 'blabla');
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_title());
+ $this->assertEmpty($this->object->get_title());
+ }
- public function testGet_title()
- {
- $this->object = new Bridge_Api_Dailymotion_Element($this->test, 'blabla');
- $this->assertEquals($this->test['title'], $this->object->get_title());
- unset($this->test["title"]);
- $this->object = new Bridge_Api_Dailymotion_Element($this->test, 'blabla');
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_title());
- $this->assertEmpty($this->object->get_title());
- }
+ public function testGet_type()
+ {
+ $type = 'kikoo';
+ $this->object = new Bridge_Api_Dailymotion_Element($this->test, $type);
+ $this->assertEquals($type, $this->object->get_type());
+ $type = 'kooki';
+ $this->object = new Bridge_Api_Dailymotion_Element($this->test, $type);
+ $this->assertEquals($type, $this->object->get_type());
+ }
- public function testGet_type()
- {
- $type = 'kikoo';
- $this->object = new Bridge_Api_Dailymotion_Element($this->test, $type);
- $this->assertEquals($type, $this->object->get_type());
- $type = 'kooki';
- $this->object = new Bridge_Api_Dailymotion_Element($this->test, $type);
- $this->assertEquals($type, $this->object->get_type());
- }
+ public function testGet_updated_on()
+ {
+ $this->object = new Bridge_Api_Dailymotion_Element($this->test, 'blabla');
+ $this->assertEquals(DateTime::createFromFormat('U', $this->test['modified_time']), $this->object->get_updated_on());
+ }
- public function testGet_updated_on()
- {
- $this->object = new Bridge_Api_Dailymotion_Element($this->test, 'blabla');
- $this->assertEquals(DateTime::createFromFormat('U', $this->test['modified_time']), $this->object->get_updated_on());
- }
+ public function testGet_url()
+ {
+ $this->object = new Bridge_Api_Dailymotion_Element($this->test, 'blabla');
+ $this->assertEquals($this->test['url'], $this->object->get_url());
+ unset($this->test["url"]);
+ $this->object = new Bridge_Api_Dailymotion_Element($this->test, 'blabla');
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_url());
+ $this->assertEmpty($this->object->get_url());
+ }
- public function testGet_url()
- {
- $this->object = new Bridge_Api_Dailymotion_Element($this->test, 'blabla');
- $this->assertEquals($this->test['url'], $this->object->get_url());
- unset($this->test["url"]);
- $this->object = new Bridge_Api_Dailymotion_Element($this->test, 'blabla');
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_url());
- $this->assertEmpty($this->object->get_url());
- }
+ public function testIs_private()
+ {
+ $this->object = new Bridge_Api_Dailymotion_Element($this->test, 'blabla');
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_BOOL, $this->object->is_private());
+ $this->assertTrue($this->object->is_private());
+ unset($this->test["private"]);
+ $this->object = new Bridge_Api_Dailymotion_Element($this->test, 'blabla');
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_BOOL, $this->object->is_private());
+ $this->assertFalse($this->object->is_private());
+ }
- public function testIs_private()
- {
- $this->object = new Bridge_Api_Dailymotion_Element($this->test, 'blabla');
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_BOOL, $this->object->is_private());
- $this->assertTrue($this->object->is_private());
- unset($this->test["private"]);
- $this->object = new Bridge_Api_Dailymotion_Element($this->test, 'blabla');
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_BOOL, $this->object->is_private());
- $this->assertFalse($this->object->is_private());
- }
+ public function testGet_duration()
+ {
+ $this->object = new Bridge_Api_Dailymotion_Element($this->test, 'blabla');
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_duration());
+ $this->assertEquals("01:20", $this->object->get_duration());
+ unset($this->test["duration"]);
+ $this->object = new Bridge_Api_Dailymotion_Element($this->test, 'blabla');
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_duration());
+ $this->assertEquals("00:00", $this->object->get_duration());
+ }
- public function testGet_duration()
- {
- $this->object = new Bridge_Api_Dailymotion_Element($this->test, 'blabla');
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_duration());
- $this->assertEquals("01:20", $this->object->get_duration());
- unset($this->test["duration"]);
- $this->object = new Bridge_Api_Dailymotion_Element($this->test, 'blabla');
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_duration());
- $this->assertEquals("00:00", $this->object->get_duration());
- }
+ public function testGet_view_count()
+ {
+ $this->object = new Bridge_Api_Dailymotion_Element($this->test, 'blabla');
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_INT, $this->object->get_view_count());
+ $this->assertEquals($this->test['views_total'], $this->object->get_view_count());
+ unset($this->test["views_total"]);
+ $this->object = new Bridge_Api_Dailymotion_Element($this->test, 'blabla');
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_INT, $this->object->get_view_count());
+ $this->assertEquals(0, $this->object->get_view_count());
+ }
- public function testGet_view_count()
- {
- $this->object = new Bridge_Api_Dailymotion_Element($this->test, 'blabla');
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_INT, $this->object->get_view_count());
- $this->assertEquals($this->test['views_total'], $this->object->get_view_count());
- unset($this->test["views_total"]);
- $this->object = new Bridge_Api_Dailymotion_Element($this->test, 'blabla');
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_INT, $this->object->get_view_count());
- $this->assertEquals(0 , $this->object->get_view_count());
- }
-
- public function testGet_rating()
- {
- $this->object = new Bridge_Api_Dailymotion_Element($this->test, 'blabla');
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_INT, $this->object->get_rating());
- $this->assertEquals($this->test['ratings_total'], $this->object->get_rating());
- unset($this->test["ratings_total"]);
- $this->object = new Bridge_Api_Dailymotion_Element($this->test, 'blabla');
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_INT, $this->object->get_rating());
- $this->assertEquals(0 , $this->object->get_rating());
- }
-
- public function testGet_category()
- {
- $this->object = new Bridge_Api_Dailymotion_Element($this->test, 'blabla');
- $this->assertEquals($this->test['channel'], $this->object->get_category());
- unset($this->test["channel"]);
- $this->object = new Bridge_Api_Dailymotion_Element($this->test, 'blabla');
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_category());
- $this->assertEmpty($this->object->get_category());
- }
+ public function testGet_rating()
+ {
+ $this->object = new Bridge_Api_Dailymotion_Element($this->test, 'blabla');
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_INT, $this->object->get_rating());
+ $this->assertEquals($this->test['ratings_total'], $this->object->get_rating());
+ unset($this->test["ratings_total"]);
+ $this->object = new Bridge_Api_Dailymotion_Element($this->test, 'blabla');
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_INT, $this->object->get_rating());
+ $this->assertEquals(0, $this->object->get_rating());
+ }
+ public function testGet_category()
+ {
+ $this->object = new Bridge_Api_Dailymotion_Element($this->test, 'blabla');
+ $this->assertEquals($this->test['channel'], $this->object->get_category());
+ unset($this->test["channel"]);
+ $this->object = new Bridge_Api_Dailymotion_Element($this->test, 'blabla');
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_category());
+ $this->assertEmpty($this->object->get_category());
+ }
}
diff --git a/tests/Bridge/Api/Flickr/Bridge_Api_Flickr_ContainerTest.php b/tests/Bridge/Api/Flickr/Bridge_Api_Flickr_ContainerTest.php
index d43d7c1167..d44eeee1b8 100644
--- a/tests/Bridge/Api/Flickr/Bridge_Api_Flickr_ContainerTest.php
+++ b/tests/Bridge/Api/Flickr/Bridge_Api_Flickr_ContainerTest.php
@@ -5,72 +5,70 @@ require_once __DIR__ . '/../../Bridge_datas.inc';
class Bridge_Api_Flickr_ContainerTest extends PHPUnit_Framework_TestCase
{
+ /**
+ * @var Bridge_Api_Flickr_Container
+ */
+ protected $object;
- /**
- * @var Bridge_Api_Flickr_Container
- */
- protected $object;
-
- public function setUp()
- {
- $string = '
+ public function setUp()
+ {
+ $string = '
Avis Blanche
My Grandma\'s Recipe File.
';
- $xml = simplexml_load_string($string);
- $this->object = new Bridge_Api_Flickr_Container($xml, 'userid123', "photoset", "my_humbnail");
- }
+ $xml = simplexml_load_string($string);
+ $this->object = new Bridge_Api_Flickr_Container($xml, 'userid123', "photoset", "my_humbnail");
+ }
- public function testGet_id()
- {
- $this->assertEquals("72157626216528324", $this->object->get_id());
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_id());
- }
+ public function testGet_id()
+ {
+ $this->assertEquals("72157626216528324", $this->object->get_id());
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_id());
+ }
- public function testGet_thumbnail()
- {
- $this->assertEquals("my_humbnail", $this->object->get_thumbnail());
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_thumbnail());
- }
+ public function testGet_thumbnail()
+ {
+ $this->assertEquals("my_humbnail", $this->object->get_thumbnail());
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_thumbnail());
+ }
- public function testGet_url()
- {
- $this->assertRegExp("/https:\/\/secure.flickr.com\/photos/", $this->object->get_url());
- $this->assertRegExp("/userid123/", $this->object->get_url());
- $this->assertRegExp("/72157626216528324/", $this->object->get_url());
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_thumbnail());
- }
+ public function testGet_url()
+ {
+ $this->assertRegExp("/https:\/\/secure.flickr.com\/photos/", $this->object->get_url());
+ $this->assertRegExp("/userid123/", $this->object->get_url());
+ $this->assertRegExp("/72157626216528324/", $this->object->get_url());
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_thumbnail());
+ }
- public function testGet_title()
- {
- $this->assertEquals("My Grandma's Recipe File.", $this->object->get_description());
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_description());
- }
+ public function testGet_title()
+ {
+ $this->assertEquals("My Grandma's Recipe File.", $this->object->get_description());
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_description());
+ }
- public function testGet_description()
- {
- $this->assertEquals("Avis Blanche", $this->object->get_title());
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_title());
- }
+ public function testGet_description()
+ {
+ $this->assertEquals("Avis Blanche", $this->object->get_title());
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_title());
+ }
- public function testGet_updated_on()
- {
- $this->assertInstanceOf('DateTime', $this->object->get_updated_on());
- $this->assertEquals(DateTime::createFromFormat('U', '1300335009'), $this->object->get_updated_on());
- }
+ public function testGet_updated_on()
+ {
+ $this->assertInstanceOf('DateTime', $this->object->get_updated_on());
+ $this->assertEquals(DateTime::createFromFormat('U', '1300335009'), $this->object->get_updated_on());
+ }
- public function testGet_created_on()
- {
- $this->assertInstanceOf('DateTime', $this->object->get_created_on());
- $this->assertEquals(DateTime::createFromFormat('U', '1299514498'), $this->object->get_created_on());
- }
-
- public function testGet_type()
- {
- $this->assertEquals("photoset", $this->object->get_type());
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_type());
- }
+ public function testGet_created_on()
+ {
+ $this->assertInstanceOf('DateTime', $this->object->get_created_on());
+ $this->assertEquals(DateTime::createFromFormat('U', '1299514498'), $this->object->get_created_on());
+ }
+ public function testGet_type()
+ {
+ $this->assertEquals("photoset", $this->object->get_type());
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_type());
+ }
}
diff --git a/tests/Bridge/Api/Flickr/Bridge_Api_Flickr_ElementTest.php b/tests/Bridge/Api/Flickr/Bridge_Api_Flickr_ElementTest.php
index 1229f74e38..9714dc87fb 100644
--- a/tests/Bridge/Api/Flickr/Bridge_Api_Flickr_ElementTest.php
+++ b/tests/Bridge/Api/Flickr/Bridge_Api_Flickr_ElementTest.php
@@ -5,27 +5,26 @@ require_once __DIR__ . '/../../Bridge_datas.inc';
class Bridge_Api_Flickr_ElementTest extends PHPUnit_Framework_TestCase
{
+ /**
+ * @var Bridge_Api_Flickr_Element
+ */
+ protected $object_list;
- /**
- * @var Bridge_Api_Flickr_Element
- */
- protected $object_list;
+ /**
+ * @var Bridge_Api_Flickr_Element
+ */
+ protected $object_alone;
+ protected $xml_list;
+ protected $xml_alone;
- /**
- * @var Bridge_Api_Flickr_Element
- */
- protected $object_alone;
- protected $xml_list;
- protected $xml_alone;
-
- public function setUp()
- {
- $str = '
+ public function setUp()
+ {
+ $str = '
une description
';
- $string = '
+ $string = '
@@ -49,114 +48,113 @@ class Bridge_Api_Flickr_ElementTest extends PHPUnit_Framework_TestCase
';
- $this->xml_alone = simplexml_load_string($string);
- $this->object_alone = new Bridge_Api_Flickr_Element($this->xml_alone, '12037949754@N01', 'album', false);
- $this->xml_list = simplexml_load_string($str);
- $this->object_list = new Bridge_Api_Flickr_Element($this->xml_list, '12037949754@N01', 'album', true);
- }
+ $this->xml_alone = simplexml_load_string($string);
+ $this->object_alone = new Bridge_Api_Flickr_Element($this->xml_alone, '12037949754@N01', 'album', false);
+ $this->xml_list = simplexml_load_string($str);
+ $this->object_list = new Bridge_Api_Flickr_Element($this->xml_list, '12037949754@N01', 'album', true);
+ }
- public function testGet_id()
- {
- $this->assertEquals("5930279108", $this->object_alone->get_id());
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object_alone->get_id());
- $this->assertEquals("6263188755", $this->object_list->get_id());
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object_list->get_id());
- }
+ public function testGet_id()
+ {
+ $this->assertEquals("5930279108", $this->object_alone->get_id());
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object_alone->get_id());
+ $this->assertEquals("6263188755", $this->object_list->get_id());
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object_list->get_id());
+ }
- public function testGet_url()
- {
- $this->assertRegExp("/6263188755/", $this->object_list->get_url());
- $this->assertRegExp("/album/", $this->object_list->get_url());
- $this->assertRegExp("/60578095@N05/", $this->object_list->get_url());
- $this->assertRegExp("/http:\/\/www.flickr.com\//", $this->object_list->get_url());
- $this->assertEquals("http://www.flickr.com/photos/bees/2733/", $this->object_alone->get_url());
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object_alone->get_url());
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object_list->get_url());
- }
+ public function testGet_url()
+ {
+ $this->assertRegExp("/6263188755/", $this->object_list->get_url());
+ $this->assertRegExp("/album/", $this->object_list->get_url());
+ $this->assertRegExp("/60578095@N05/", $this->object_list->get_url());
+ $this->assertRegExp("/http:\/\/www.flickr.com\//", $this->object_list->get_url());
+ $this->assertEquals("http://www.flickr.com/photos/bees/2733/", $this->object_alone->get_url());
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object_alone->get_url());
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object_list->get_url());
+ }
- public function testGet_thumbnail()
- {
- $this->assertEquals("http://farm7.static.flickr.com/6034/6263188755_2dca715798_t.jpg", $this->object_list->get_thumbnail());
- $this->assertRegExp("/https:\/\/farm7.static.flickr.com/", $this->object_alone->get_thumbnail());
- $this->assertRegExp("/6135/", $this->object_alone->get_thumbnail());
- $this->assertRegExp("/c06196fbd8/", $this->object_alone->get_thumbnail());
- $this->assertRegExp("/5930279108/", $this->object_alone->get_thumbnail());
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object_alone->get_thumbnail());
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object_list->get_thumbnail());
- }
+ public function testGet_thumbnail()
+ {
+ $this->assertEquals("http://farm7.static.flickr.com/6034/6263188755_2dca715798_t.jpg", $this->object_list->get_thumbnail());
+ $this->assertRegExp("/https:\/\/farm7.static.flickr.com/", $this->object_alone->get_thumbnail());
+ $this->assertRegExp("/6135/", $this->object_alone->get_thumbnail());
+ $this->assertRegExp("/c06196fbd8/", $this->object_alone->get_thumbnail());
+ $this->assertRegExp("/5930279108/", $this->object_alone->get_thumbnail());
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object_alone->get_thumbnail());
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object_list->get_thumbnail());
+ }
- public function testGet_title()
- {
- $this->assertEquals("un titre", $this->object_list->get_title());
- $this->assertEquals("Australia.gif", $this->object_alone->get_title());
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object_alone->get_title());
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object_list->get_title());
- }
+ public function testGet_title()
+ {
+ $this->assertEquals("un titre", $this->object_list->get_title());
+ $this->assertEquals("Australia.gif", $this->object_alone->get_title());
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object_alone->get_title());
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object_list->get_title());
+ }
- public function testGet_description()
- {
- $this->assertEquals("une description", $this->object_list->get_description());
- $this->assertEquals("drapeau de l'australie", $this->object_alone->get_description());
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object_alone->get_description());
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object_list->get_description());
- }
+ public function testGet_description()
+ {
+ $this->assertEquals("une description", $this->object_list->get_description());
+ $this->assertEquals("drapeau de l'australie", $this->object_alone->get_description());
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object_alone->get_description());
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object_list->get_description());
+ }
- public function testGet_updated_on()
- {
- $this->assertInstanceOf('DateTime', $this->object_list->get_updated_on());
- $this->assertInstanceOf('DateTime', $this->object_alone->get_updated_on());
- $this->assertEquals(DateTime::createFromFormat('U', '1319126343'), $this->object_list->get_updated_on());
- $this->assertEquals(DateTime::createFromFormat('U', '1314975347'), $this->object_alone->get_updated_on());
- }
+ public function testGet_updated_on()
+ {
+ $this->assertInstanceOf('DateTime', $this->object_list->get_updated_on());
+ $this->assertInstanceOf('DateTime', $this->object_alone->get_updated_on());
+ $this->assertEquals(DateTime::createFromFormat('U', '1319126343'), $this->object_list->get_updated_on());
+ $this->assertEquals(DateTime::createFromFormat('U', '1314975347'), $this->object_alone->get_updated_on());
+ }
- public function testGet_category()
- {
- $this->assertEmpty($this->object_list->get_category());
- $this->assertEmpty($this->object_alone->get_category());
- }
+ public function testGet_category()
+ {
+ $this->assertEmpty($this->object_list->get_category());
+ $this->assertEmpty($this->object_alone->get_category());
+ }
- public function testGet_duration()
- {
- $this->assertEmpty($this->object_list->get_duration());
- $this->assertEmpty($this->object_alone->get_duration());
- }
+ public function testGet_duration()
+ {
+ $this->assertEmpty($this->object_list->get_duration());
+ $this->assertEmpty($this->object_alone->get_duration());
+ }
- public function testGet_view_count()
- {
- $this->assertEquals(1, $this->object_list->get_view_count());
- $this->assertEquals(1, $this->object_alone->get_view_count());
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_INT, $this->object_alone->get_view_count());
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_INT, $this->object_list->get_view_count());
- }
+ public function testGet_view_count()
+ {
+ $this->assertEquals(1, $this->object_list->get_view_count());
+ $this->assertEquals(1, $this->object_alone->get_view_count());
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_INT, $this->object_alone->get_view_count());
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_INT, $this->object_list->get_view_count());
+ }
- public function testGet_rating()
- {
- $this->assertNull($this->object_list->get_rating());
- $this->assertNull($this->object_alone->get_rating());
- }
+ public function testGet_rating()
+ {
+ $this->assertNull($this->object_list->get_rating());
+ $this->assertNull($this->object_alone->get_rating());
+ }
- public function testGet_created_on()
- {
- $this->assertInstanceOf('DateTime', $this->object_list->get_created_on());
- $this->assertInstanceOf('DateTime', $this->object_alone->get_created_on());
- $this->assertEquals(DateTime::createFromFormat('U', '1319117962'), $this->object_list->get_created_on());
- $this->assertEquals(DateTime::createFromFormat('U', '1310477820'), $this->object_alone->get_created_on());
- }
+ public function testGet_created_on()
+ {
+ $this->assertInstanceOf('DateTime', $this->object_list->get_created_on());
+ $this->assertInstanceOf('DateTime', $this->object_alone->get_created_on());
+ $this->assertEquals(DateTime::createFromFormat('U', '1319117962'), $this->object_list->get_created_on());
+ $this->assertEquals(DateTime::createFromFormat('U', '1310477820'), $this->object_alone->get_created_on());
+ }
- public function testIs_private()
- {
- $this->assertFalse($this->object_list->is_private());
- $this->assertTrue($this->object_alone->is_private());
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_BOOL, $this->object_alone->is_private());
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_BOOL, $this->object_list->is_private());
- }
-
- public function testGet_type()
- {
- $this->assertEquals('album', $this->object_list->get_type());
- $this->assertEquals('album', $this->object_alone->get_type());
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object_alone->get_type());
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object_list->get_type());
- }
+ public function testIs_private()
+ {
+ $this->assertFalse($this->object_list->is_private());
+ $this->assertTrue($this->object_alone->is_private());
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_BOOL, $this->object_alone->is_private());
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_BOOL, $this->object_list->is_private());
+ }
+ public function testGet_type()
+ {
+ $this->assertEquals('album', $this->object_list->get_type());
+ $this->assertEquals('album', $this->object_alone->get_type());
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object_alone->get_type());
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object_list->get_type());
+ }
}
diff --git a/tests/Bridge/Api/Youtube/Bridge_Api_Youtube_ContainerTest.php b/tests/Bridge/Api/Youtube/Bridge_Api_Youtube_ContainerTest.php
index 0961b3b44d..426e0ef20f 100644
--- a/tests/Bridge/Api/Youtube/Bridge_Api_Youtube_ContainerTest.php
+++ b/tests/Bridge/Api/Youtube/Bridge_Api_Youtube_ContainerTest.php
@@ -5,77 +5,69 @@ require_once __DIR__ . '/../../Bridge_datas.inc';
class Bridge_Api_Youtube_ContainerTest extends PHPUnit_Framework_TestCase
{
+ /**
+ * @var Bridge_Api_Youtube_Container
+ */
+ protected $object;
- /**
- * @var Bridge_Api_Youtube_Container
- */
- protected $object;
+ public function setUp()
+ {
+ $published = new Zend_Gdata_App_Extension_Published("2011-10-21 12:00:00");
+ $updated = new Zend_Gdata_App_Extension_Updated("2011-10-21 12:20:00");
+ $id = new Zend_Gdata_App_Extension_Id("Az2cv12");
+ $entry = new Zend_Gdata_YouTube_PlaylistListEntry();
+ $entry->setMajorProtocolVersion(2);
+ $entry->setId($id);
+ $entry->setTitle(new Zend_Gdata_App_Extension_Title("one title"));
+ $entry->setUpdated($updated);
+ $entry->setPublished($published);
+ $entry->setLink(array(new Zend_Gdata_App_Extension_link("one url", "alternate")));
+ $entry->setDescription(new Zend_Gdata_App_Extension_Summary("one description"));
+ $this->object = new Bridge_Api_Youtube_Container($entry, 'playlist', 'my_thumbnail');
+ }
- public function setUp()
- {
- $published = new Zend_Gdata_App_Extension_Published("2011-10-21 12:00:00");
- $updated = new Zend_Gdata_App_Extension_Updated("2011-10-21 12:20:00");
- $id = new Zend_Gdata_App_Extension_Id("Az2cv12");
- $entry = new Zend_Gdata_YouTube_PlaylistListEntry();
- $entry->setMajorProtocolVersion(2);
- $entry->setId($id);
- $entry->setTitle(new Zend_Gdata_App_Extension_Title("one title"));
- $entry->setUpdated($updated);
- $entry->setPublished($published);
- $entry->setLink(array(new Zend_Gdata_App_Extension_link("one url", "alternate")));
- $entry->setDescription(new Zend_Gdata_App_Extension_Summary("one description"));
- $this->object = new Bridge_Api_Youtube_Container($entry, 'playlist', 'my_thumbnail');
- }
+ /**
+ * @todo find a way to test getPlaylistId
+ */
+ public function testGet_thumbnail()
+ {
+ $this->assertEquals("my_thumbnail", $this->object->get_thumbnail());
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_thumbnail());
+ }
+ public function testGet_url()
+ {
+ $this->assertEquals("one url", $this->object->get_url());
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_url());
+ }
+ public function testGet_title()
+ {
+ $this->assertEquals("one title", $this->object->get_title());
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_title());
+ }
- /**
- * @todo fin a way to test getPlaylistId
- */
+ public function testGet_description()
+ {
+ $this->assertEquals("one description", $this->object->get_description());
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_description());
+ }
+ public function testGet_updated_on()
+ {
+ $this->assertInstanceOf('DateTime', $this->object->get_updated_on());
+ $this->assertEquals(new DateTime("2011-10-21 12:20:00"), $this->object->get_updated_on());
+ }
+ public function testGet_created_on()
+ {
+ $this->assertInstanceOf('DateTime', $this->object->get_created_on());
+ $this->assertEquals(new DateTime("2011-10-21 12:00:00"), $this->object->get_created_on());
+ }
-
- public function testGet_thumbnail()
- {
- $this->assertEquals("my_thumbnail", $this->object->get_thumbnail());
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_thumbnail());
- }
-
- public function testGet_url()
- {
- $this->assertEquals("one url", $this->object->get_url());
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_url());
- }
-
- public function testGet_title()
- {
- $this->assertEquals("one title", $this->object->get_title());
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_title());
- }
-
- public function testGet_description()
- {
- $this->assertEquals("one description", $this->object->get_description());
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_description());
- }
-
- public function testGet_updated_on()
- {
- $this->assertInstanceOf('DateTime', $this->object->get_updated_on());
- $this->assertEquals(new DateTime("2011-10-21 12:20:00"), $this->object->get_updated_on());
- }
-
- public function testGet_created_on()
- {
- $this->assertInstanceOf('DateTime', $this->object->get_created_on());
- $this->assertEquals(new DateTime("2011-10-21 12:00:00"), $this->object->get_created_on());
- }
-
- public function testGet_type()
- {
- $this->assertEquals("playlist", $this->object->get_type());
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_type());
- }
-
+ public function testGet_type()
+ {
+ $this->assertEquals("playlist", $this->object->get_type());
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_type());
+ }
}
diff --git a/tests/Bridge/Api/Youtube/Bridge_Api_Youtube_ElementTest.php b/tests/Bridge/Api/Youtube/Bridge_Api_Youtube_ElementTest.php
index 92ca86083e..beef0a742c 100644
--- a/tests/Bridge/Api/Youtube/Bridge_Api_Youtube_ElementTest.php
+++ b/tests/Bridge/Api/Youtube/Bridge_Api_Youtube_ElementTest.php
@@ -5,120 +5,118 @@ require_once __DIR__ . '/../../Bridge_datas.inc';
class Bridge_Api_Youtube_ElementTest extends PHPUnit_Framework_TestCase
{
+ /**
+ * @var Bridge_Api_Youtube_Element
+ */
+ protected $object;
- /**
- * @var Bridge_Api_Youtube_Element
- */
- protected $object;
+ public function setUp()
+ {
+ $published = new Zend_Gdata_App_Extension_Published("2011-10-21 12:00:00");
+ $updated = new Zend_Gdata_App_Extension_Updated("2011-10-21 12:20:00");
+ $id = new Zend_Gdata_App_Extension_Id("Az2cv12");
+ $rating = new Zend_Gdata_Extension_Rating(4, 1, 5, 200, 4);
+ $duration = new Zend_Gdata_YouTube_Extension_Duration(80);
+ $player = new Zend_Gdata_Media_Extension_MediaPlayer();
+ $player->setUrl("coucou");
+ $stat = new Zend_Gdata_YouTube_Extension_Statistics();
+ $stat->setViewCount("5");
+ $thumb = new Zend_Gdata_Media_Extension_MediaThumbnail('une url', '120', '90');
+ $media = new Zend_Gdata_YouTube_Extension_MediaGroup();
+ $media->setPlayer(array($player));
+ $media->setDuration($duration);
+ $media->setVideoId($id);
+ $media->setThumbnail(array($thumb));
+ $entry = new Zend_Gdata_YouTube_VideoEntry();
+ $entry->setMajorProtocolVersion(2);
+ $entry->setMediaGroup($media);
+ $entry->setStatistics($stat);
+ $entry->setRating($rating);
+ $entry->setVideoCategory("category");
+ $entry->setVideoDescription("one description");
+ $entry->setVideoPrivate();
+ $entry->setVideoTags(array('tags'));
+ $entry->setVideoTitle("hellow");
+ $entry->setUpdated($updated);
+ $entry->setPublished($published);
+ $this->object = new Bridge_Api_Youtube_Element($entry, 'video');
+ }
- public function setUp()
- {
- $published = new Zend_Gdata_App_Extension_Published("2011-10-21 12:00:00");
- $updated = new Zend_Gdata_App_Extension_Updated("2011-10-21 12:20:00");
- $id = new Zend_Gdata_App_Extension_Id("Az2cv12");
- $rating = new Zend_Gdata_Extension_Rating(4, 1, 5, 200, 4);
- $duration = new Zend_Gdata_YouTube_Extension_Duration(80);
- $player = new Zend_Gdata_Media_Extension_MediaPlayer();
- $player->setUrl("coucou");
- $stat = new Zend_Gdata_YouTube_Extension_Statistics();
- $stat->setViewCount("5");
- $thumb = new Zend_Gdata_Media_Extension_MediaThumbnail('une url', '120', '90');
- $media = new Zend_Gdata_YouTube_Extension_MediaGroup();
- $media->setPlayer(array($player));
- $media->setDuration($duration);
- $media->setVideoId($id);
- $media->setThumbnail(array($thumb));
- $entry = new Zend_Gdata_YouTube_VideoEntry();
- $entry->setMajorProtocolVersion(2);
- $entry->setMediaGroup($media);
- $entry->setStatistics($stat);
- $entry->setRating($rating);
- $entry->setVideoCategory("category");
- $entry->setVideoDescription("one description");
- $entry->setVideoPrivate();
- $entry->setVideoTags(array('tags'));
- $entry->setVideoTitle("hellow");
- $entry->setUpdated($updated);
- $entry->setPublished($published);
- $this->object = new Bridge_Api_Youtube_Element($entry, 'video');
- }
+ public function testGet_id()
+ {
+ $this->assertEquals("Az2cv12", $this->object->get_id());
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_id());
+ }
- public function testGet_id()
- {
- $this->assertEquals("Az2cv12", $this->object->get_id());
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_id());
- }
+ public function testGet_thumbnail()
+ {
+ $this->assertEquals("une url", $this->object->get_thumbnail());
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_thumbnail());
+ }
- public function testGet_thumbnail()
- {
- $this->assertEquals("une url", $this->object->get_thumbnail());
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_thumbnail());
- }
+ public function testGet_url()
+ {
+ $this->assertEquals("coucou", $this->object->get_url());
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_url());
+ }
- public function testGet_url()
- {
- $this->assertEquals("coucou", $this->object->get_url());
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_url());
- }
+ public function testGet_title()
+ {
+ $this->assertEquals("hellow", $this->object->get_title());
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_title());
+ }
- public function testGet_title()
- {
- $this->assertEquals("hellow", $this->object->get_title());
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_title());
- }
+ public function testGet_description()
+ {
+ $this->assertEquals("one description", $this->object->get_description());
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_description());
+ }
- public function testGet_description()
- {
- $this->assertEquals("one description", $this->object->get_description());
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_description());
- }
+ public function testGet_updated_on()
+ {
+ $this->assertInstanceOf('DateTime', $this->object->get_updated_on());
+ $this->assertEquals(new DateTime("2011-10-21 12:20:00"), $this->object->get_updated_on());
+ }
- public function testGet_updated_on()
- {
- $this->assertInstanceOf('DateTime', $this->object->get_updated_on());
- $this->assertEquals(new DateTime("2011-10-21 12:20:00"), $this->object->get_updated_on());
- }
+ public function testGet_category()
+ {
+ $this->assertEquals("category", $this->object->get_category());
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_category());
+ }
- public function testGet_category()
- {
- $this->assertEquals("category", $this->object->get_category());
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_category());
- }
+ public function testGet_duration()
+ {
+ $this->assertEquals(p4string::format_seconds(80), $this->object->get_duration());
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_duration());
+ }
- public function testGet_duration()
- {
- $this->assertEquals(p4string::format_seconds(80), $this->object->get_duration());
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_duration());
- }
+ public function testGet_view_count()
+ {
+ $this->assertEquals(5, $this->object->get_view_count());
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_INT, $this->object->get_view_count());
+ }
- public function testGet_view_count()
- {
- $this->assertEquals(5, $this->object->get_view_count());
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_INT, $this->object->get_view_count());
- }
+ public function testGet_rating()
+ {
+ $this->assertEquals(200, $this->object->get_rating());
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_INT, $this->object->get_rating());
+ }
- public function testGet_rating()
- {
- $this->assertEquals(200, $this->object->get_rating());
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_INT, $this->object->get_rating());
- }
+ public function testGet_created_on()
+ {
+ $this->assertInstanceOf('DateTime', $this->object->get_created_on());
+ $this->assertEquals(new DateTime("2011-10-21 12:00:00"), $this->object->get_created_on());
+ }
- public function testGet_created_on()
- {
- $this->assertInstanceOf('DateTime', $this->object->get_created_on());
- $this->assertEquals(new DateTime("2011-10-21 12:00:00"), $this->object->get_created_on());
- }
-
- public function testIs_private()
- {
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_BOOL, $this->object->is_private());
- $this->assertTrue($this->object->is_private());
- }
-
- public function testGet_type()
- {
- $this->assertEquals("video", $this->object->get_type());
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_type());
- }
+ public function testIs_private()
+ {
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_BOOL, $this->object->is_private());
+ $this->assertTrue($this->object->is_private());
+ }
+ public function testGet_type()
+ {
+ $this->assertEquals("video", $this->object->get_type());
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_type());
+ }
}
diff --git a/tests/Bridge/Bridge_AccountSettingsTest.php b/tests/Bridge/Bridge_AccountSettingsTest.php
index 2ac1e64260..276507c56f 100644
--- a/tests/Bridge/Bridge_AccountSettingsTest.php
+++ b/tests/Bridge/Bridge_AccountSettingsTest.php
@@ -5,70 +5,66 @@ require_once __DIR__ . '/Bridge_datas.inc';
class Bridge_AccountSettingsTest extends PhraseanetPHPUnitAuthenticatedAbstract
{
+ /**
+ * @var Bridge_AccountSettings
+ */
+ protected $object;
+ protected $account;
+ protected $api;
+ protected $dist_id;
+ protected $named;
- /**
- * @var Bridge_AccountSettings
- */
- protected $object;
- protected $account;
- protected $api;
- protected $dist_id;
- protected $named;
-
- public function setUp()
- {
- try
+ public function setUp()
{
- $appbox = appbox::get_instance(\bootstrap::getCore());
+ parent::setUp();
+ try {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
- $sql = 'DELETE FROM bridge_apis WHERE name = "Apitest"';
- $stmt = $appbox->get_connection()->prepare($sql);
- $stmt->execute();
- $stmt->closeCursor();
- $this->api = Bridge_Api::create($appbox, 'Apitest');
- $this->dist_id = 'EZ1565loPP';
- $this->named = 'Fête à pinpins';
- $this->account = Bridge_Account::create($appbox, $this->api, self::$user, $this->dist_id, $this->named);
+ $sql = 'DELETE FROM bridge_apis WHERE name = "Apitest"';
+ $stmt = $appbox->get_connection()->prepare($sql);
+ $stmt->execute();
+ $stmt->closeCursor();
+ $this->api = Bridge_Api::create($appbox, 'Apitest');
+ $this->dist_id = 'EZ1565loPP';
+ $this->named = 'Fête à pinpins';
+ $this->account = Bridge_Account::create($appbox, $this->api, self::$user, $this->dist_id, $this->named);
- $this->object = new Bridge_AccountSettings($appbox, $this->account);
+ $this->object = new Bridge_AccountSettings($appbox, $this->account);
+ } catch (Exception $e) {
+ $this->fail($e->getMessage());
+ }
}
- catch (Exception $e)
+
+ public function tearDown()
{
- $this->fail($e->getMessage());
+ $this->api->delete();
+ parent::tearDown();
}
- }
- public function tearDown()
- {
- $this->api->delete();
- }
+ public function testGet()
+ {
+ $this->assertNull($this->object->get('test'));
+ $this->assertEquals('caca', $this->object->get('test', 'caca'));
+ $obj = new DateTime();
+ $this->assertEquals($obj, $this->object->get('test', $obj));
+ }
- public function testGet()
- {
- $this->assertNull($this->object->get('test'));
- $this->assertEquals('caca', $this->object->get('test', 'caca'));
- $obj = new DateTime();
- $this->assertEquals($obj, $this->object->get('test', $obj));
- }
-
- public function testSet()
- {
- $this->object->set('tip', 'top');
- $this->assertEquals('top', $this->object->get('tip'));
- $this->object->set('tip', 'tap');
- $this->assertEquals('tap', $this->object->get('tip'));
- $this->object->set('tip', null);
- $this->assertEquals(null, $this->object->get('tip'));
- }
-
- public function testDelete()
- {
- $this->object->set('tip', 'top');
- $this->assertEquals('top', $this->object->get('tip'));
- $this->object->delete('tip');
- $this->assertEquals(null, $this->object->get('tip'));
- $this->assertEquals('flop', $this->object->get('tip', 'flop'));
- }
+ public function testSet()
+ {
+ $this->object->set('tip', 'top');
+ $this->assertEquals('top', $this->object->get('tip'));
+ $this->object->set('tip', 'tap');
+ $this->assertEquals('tap', $this->object->get('tip'));
+ $this->object->set('tip', null);
+ $this->assertEquals(null, $this->object->get('tip'));
+ }
+ public function testDelete()
+ {
+ $this->object->set('tip', 'top');
+ $this->assertEquals('top', $this->object->get('tip'));
+ $this->object->delete('tip');
+ $this->assertEquals(null, $this->object->get('tip'));
+ $this->assertEquals('flop', $this->object->get('tip', 'flop'));
+ }
}
-
diff --git a/tests/Bridge/Bridge_AccountTest.php b/tests/Bridge/Bridge_AccountTest.php
index abd275be21..579d930cd8 100644
--- a/tests/Bridge/Bridge_AccountTest.php
+++ b/tests/Bridge/Bridge_AccountTest.php
@@ -5,159 +5,150 @@ require_once __DIR__ . '/Bridge_datas.inc';
class Bridge_AccountTest extends PhraseanetPHPUnitAuthenticatedAbstract
{
+ /**
+ * @var Bridge_Account
+ */
+ protected $object;
+ protected $api;
+ protected $dist_id;
+ protected $named;
+ protected $id;
- /**
- * @var Bridge_Account
- */
- protected $object;
- protected $api;
- protected $dist_id;
- protected $named;
- protected $id;
-
- public function setUp()
- {
- try
+ public function setUp()
{
- $appbox = appbox::get_instance(\bootstrap::getCore());
+ parent::setUp();
+ try {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
- $sql = 'DELETE FROM bridge_apis WHERE name = "Apitest"';
- $stmt = $appbox->get_connection()->prepare($sql);
- $stmt->execute();
- $stmt->closeCursor();
+ $sql = 'DELETE FROM bridge_apis WHERE name = "Apitest"';
+ $stmt = $appbox->get_connection()->prepare($sql);
+ $stmt->execute();
+ $stmt->closeCursor();
- $this->api = Bridge_Api::create($appbox, 'Apitest');
- $this->dist_id = 'EZ1565loPP';
- $this->named = 'Fête à pinpins';
- $account = Bridge_Account::create($appbox, $this->api, self::$user, $this->dist_id, $this->named);
- $this->id = $account->get_id();
-
- $this->object = new Bridge_Account($appbox, $this->api, $this->id);
- }
- catch (Exception $e)
- {
- $this->fail($e->getMessage());
- }
- }
-
- public function tearDown()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $this->object->delete();
-
- try
- {
- new Bridge_Account($appbox, $this->api, $this->id);
- $this->fail();
- }
- catch (Bridge_Exception_AccountNotFound $e)
- {
+ $this->api = Bridge_Api::create($appbox, 'Apitest');
+ $this->dist_id = 'EZ1565loPP';
+ $this->named = 'Fête à pinpins';
+ $account = Bridge_Account::create($appbox, $this->api, self::$user, $this->dist_id, $this->named);
+ $this->id = $account->get_id();
+ $this->object = new Bridge_Account($appbox, $this->api, $this->id);
+ } catch (Exception $e) {
+ $this->fail($e->getMessage());
+ }
}
- $this->api->delete();
- }
-
- public function testGet_id()
- {
- $this->assertTrue(is_int($this->object->get_id()));
- $this->assertEquals($this->id, $this->object->get_id());
- }
-
- public function testGet_api()
- {
- $this->assertInstanceOf('Bridge_Api', $this->object->get_api());
- $this->assertEquals($this->api, $this->object->get_api());
- $this->assertEquals($this->api->get_id(), $this->object->get_api()->get_id());
- }
-
- public function testGet_dist_id()
- {
- $this->assertEquals($this->dist_id, $this->object->get_dist_id());
- }
-
- public function testGet_user()
- {
- $this->assertInstanceOf('User_Adapter', $this->object->get_user());
- $this->assertEquals(self::$user->get_id(), $this->object->get_user()->get_id());
- }
-
- public function testGet_name()
- {
- $this->assertEquals($this->named, $this->object->get_name());
- }
-
- public function testGet_created_on()
- {
- $this->assertInstanceOf('DateTime', $this->object->get_created_on());
- $this->assertTrue($this->object->get_created_on() <= new DateTime());
- }
-
- public function testGet_updated_on()
- {
- $this->assertInstanceOf('DateTime', $this->object->get_updated_on());
- $this->assertTrue($this->object->get_updated_on() <= new DateTime());
- $this->assertTrue($this->object->get_updated_on() >= $this->object->get_created_on());
-
- $update1 = $this->object->get_updated_on();
- sleep(2);
- $this->object->set_name('prout');
-
- $update2 = $this->object->get_updated_on();
- $this->assertTrue($update2 > $update1);
- }
-
- public function testSet_name()
- {
- $new_name = 'YODELALI &é"\'(-è_çà)';
- $this->object->set_name($new_name);
- $this->assertEquals($new_name, $this->object->get_name());
- $new_name = 'BACHI BOUZOUKS';
- $this->object->set_name($new_name);
- $this->assertEquals($new_name, $this->object->get_name());
- }
-
- public function testGet_accounts_by_api()
- {
- $accounts = Bridge_Account::get_accounts_by_api(appbox::get_instance(\bootstrap::getCore()), $this->api);
- $this->assertTrue(is_array($accounts));
-
- $this->assertGreaterThan(0, count($accounts));
-
- foreach ($accounts as $account)
+ public function tearDown()
{
- $this->assertInstanceOf('Bridge_Account', $account);
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $this->object->delete();
+
+ try {
+ new Bridge_Account($appbox, $this->api, $this->id);
+ $this->fail();
+ } catch (Bridge_Exception_AccountNotFound $e) {
+
+ }
+
+ $this->api->delete();
+ parent::tearDown();
}
- }
- public function testGet_settings()
- {
- $this->assertInstanceOf('Bridge_AccountSettings', $this->object->get_settings());
- }
-
- public function testGet_accounts_by_user()
- {
- $accounts = Bridge_Account::get_accounts_by_user(appbox::get_instance(\bootstrap::getCore()), self::$user);
-
- $this->assertTrue(is_array($accounts));
- $this->assertTrue(count($accounts) > 0);
-
- foreach ($accounts as $account)
+ public function testGet_id()
{
- $this->assertInstanceOf('Bridge_Account', $account);
+ $this->assertTrue(is_int($this->object->get_id()));
+ $this->assertEquals($this->id, $this->object->get_id());
}
- }
- public function testLoad_account()
- {
- $account = Bridge_Account::load_account(appbox::get_instance(\bootstrap::getCore()), $this->object->get_id());
- $this->assertEquals($this->object->get_id(), $account->get_id());
- }
+ public function testGet_api()
+ {
+ $this->assertInstanceOf('Bridge_Api', $this->object->get_api());
+ $this->assertEquals($this->api, $this->object->get_api());
+ $this->assertEquals($this->api->get_id(), $this->object->get_api()->get_id());
+ }
- public function testLoad_account_from_distant_id()
- {
- $this->markTestIncomplete();
- }
+ public function testGet_dist_id()
+ {
+ $this->assertEquals($this->dist_id, $this->object->get_dist_id());
+ }
+ public function testGet_user()
+ {
+ $this->assertInstanceOf('User_Adapter', $this->object->get_user());
+ $this->assertEquals(self::$user->get_id(), $this->object->get_user()->get_id());
+ }
+
+ public function testGet_name()
+ {
+ $this->assertEquals($this->named, $this->object->get_name());
+ }
+
+ public function testGet_created_on()
+ {
+ $this->assertInstanceOf('DateTime', $this->object->get_created_on());
+ $this->assertTrue($this->object->get_created_on() <= new DateTime());
+ }
+
+ public function testGet_updated_on()
+ {
+ $this->assertInstanceOf('DateTime', $this->object->get_updated_on());
+ $this->assertTrue($this->object->get_updated_on() <= new DateTime());
+ $this->assertTrue($this->object->get_updated_on() >= $this->object->get_created_on());
+
+ $update1 = $this->object->get_updated_on();
+ sleep(2);
+ $this->object->set_name('prout');
+
+ $update2 = $this->object->get_updated_on();
+ $this->assertTrue($update2 > $update1);
+ }
+
+ public function testSet_name()
+ {
+ $new_name = 'YODELALI &é"\'(-è_çà)';
+ $this->object->set_name($new_name);
+ $this->assertEquals($new_name, $this->object->get_name());
+ $new_name = 'BACHI BOUZOUKS';
+ $this->object->set_name($new_name);
+ $this->assertEquals($new_name, $this->object->get_name());
+ }
+
+ public function testGet_accounts_by_api()
+ {
+ $accounts = Bridge_Account::get_accounts_by_api(appbox::get_instance(\bootstrap::getCore()), $this->api);
+ $this->assertTrue(is_array($accounts));
+
+ $this->assertGreaterThan(0, count($accounts));
+
+ foreach ($accounts as $account) {
+ $this->assertInstanceOf('Bridge_Account', $account);
+ }
+ }
+
+ public function testGet_settings()
+ {
+ $this->assertInstanceOf('Bridge_AccountSettings', $this->object->get_settings());
+ }
+
+ public function testGet_accounts_by_user()
+ {
+ $accounts = Bridge_Account::get_accounts_by_user(appbox::get_instance(\bootstrap::getCore()), self::$user);
+
+ $this->assertTrue(is_array($accounts));
+ $this->assertTrue(count($accounts) > 0);
+
+ foreach ($accounts as $account) {
+ $this->assertInstanceOf('Bridge_Account', $account);
+ }
+ }
+
+ public function testLoad_account()
+ {
+ $account = Bridge_Account::load_account(appbox::get_instance(\bootstrap::getCore()), $this->object->get_id());
+ $this->assertEquals($this->object->get_id(), $account->get_id());
+ }
+
+ public function testLoad_account_from_distant_id()
+ {
+ $this->markTestIncomplete();
+ }
}
-
diff --git a/tests/Bridge/Bridge_ApiTest.php b/tests/Bridge/Bridge_ApiTest.php
index d958bbbead..b88f4f1c71 100644
--- a/tests/Bridge/Bridge_ApiTest.php
+++ b/tests/Bridge/Bridge_ApiTest.php
@@ -5,190 +5,185 @@ require_once __DIR__ . '/Bridge_datas.inc';
class Bridge_ApiTest extends PhraseanetPHPUnitAuthenticatedAbstract
{
+ /**
+ * @var Bridge_Api
+ */
+ protected $object;
+ protected $id;
+ protected $type;
- /**
- * @var Bridge_Api
- */
- protected $object;
- protected $id;
- protected $type;
-
- public function setUp()
- {
-
- $appbox = appbox::get_instance(\bootstrap::getCore());
-
- $sql = 'DELETE FROM bridge_apis WHERE name = "Apitest"';
- $stmt = $appbox->get_connection()->prepare($sql);
- $stmt->execute();
- $stmt->closeCursor();
-
- $this->type = 'Apitest';
- $api = Bridge_Api::create($appbox, $this->type);
-
- $this->id = $api->get_id();
- $this->object = new Bridge_Api($appbox, $api->get_id());
- }
-
- public function tearDown()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
-
- $this->object->delete();
-
- try
+ public function setUp()
{
- new Bridge_Api($appbox, $this->id);
- $this->fail();
+ parent::setUp();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+
+ $sql = 'DELETE FROM bridge_apis WHERE name = "Apitest"';
+ $stmt = $appbox->get_connection()->prepare($sql);
+ $stmt->execute();
+ $stmt->closeCursor();
+
+ $this->type = 'Apitest';
+ $api = Bridge_Api::create($appbox, $this->type);
+
+ $this->id = $api->get_id();
+ $this->object = new Bridge_Api($appbox, $api->get_id());
}
- catch (Bridge_Exception_ApiNotFound $e)
+
+ public function tearDown()
{
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $this->object->delete();
+
+ try {
+ new Bridge_Api($appbox, $this->id);
+ $this->fail();
+ } catch (Bridge_Exception_ApiNotFound $e) {
+
+ }
+ parent::tearDown();
}
- }
- public function testGet_id()
- {
- $this->assertTrue(is_int($this->object->get_id()));
- $this->assertTrue($this->object->get_id() > 0);
- $this->assertEquals($this->id, $this->object->get_id());
- }
+ public function testGet_id()
+ {
+ $this->assertTrue(is_int($this->object->get_id()));
+ $this->assertTrue($this->object->get_id() > 0);
+ $this->assertEquals($this->id, $this->object->get_id());
+ }
- public function testis_disabled()
- {
- $this->assertTrue(is_bool($this->object->is_disabled()));
- $this->assertFalse($this->object->is_disabled());
- }
+ public function testis_disabled()
+ {
+ $this->assertTrue(is_bool($this->object->is_disabled()));
+ $this->assertFalse($this->object->is_disabled());
+ }
- public function testenable()
- {
- $this->assertTrue(is_bool($this->object->is_disabled()));
- $this->assertFalse($this->object->is_disabled());
- sleep(1);
- $update1 = $this->object->get_updated_on();
+ public function testenable()
+ {
+ $this->assertTrue(is_bool($this->object->is_disabled()));
+ $this->assertFalse($this->object->is_disabled());
+ sleep(1);
+ $update1 = $this->object->get_updated_on();
- $this->object->disable(new DateTime('+2 seconds'));
- $this->assertTrue($this->object->is_disabled());
- sleep(3);
- $update2 = $this->object->get_updated_on();
- $this->assertTrue($update2 > $update1);
- $this->assertFalse($this->object->is_disabled());
- $this->object->enable();
- $this->assertFalse($this->object->is_disabled());
- }
+ $this->object->disable(new DateTime('+2 seconds'));
+ $this->assertTrue($this->object->is_disabled());
+ sleep(3);
+ $update2 = $this->object->get_updated_on();
+ $this->assertTrue($update2 > $update1);
+ $this->assertFalse($this->object->is_disabled());
+ $this->object->enable();
+ $this->assertFalse($this->object->is_disabled());
+ }
- public function testdisable()
- {
- $this->testenable();
- }
+ public function testdisable()
+ {
+ $this->testenable();
+ }
- public function testGet_created_on()
- {
- $this->assertInstanceOf('DateTime', $this->object->get_created_on());
- $this->assertTrue($this->object->get_created_on() <= new DateTime());
- }
+ public function testGet_created_on()
+ {
+ $this->assertInstanceOf('DateTime', $this->object->get_created_on());
+ $this->assertTrue($this->object->get_created_on() <= new DateTime());
+ }
- public function testGet_updated_on()
- {
- $this->assertInstanceOf('DateTime', $this->object->get_updated_on());
- $this->assertTrue($this->object->get_updated_on() <= new DateTime());
- $this->assertTrue($this->object->get_updated_on() >= $this->object->get_created_on());
- }
+ public function testGet_updated_on()
+ {
+ $this->assertInstanceOf('DateTime', $this->object->get_updated_on());
+ $this->assertTrue($this->object->get_updated_on() <= new DateTime());
+ $this->assertTrue($this->object->get_updated_on() >= $this->object->get_created_on());
+ }
- public function testGet_connector()
- {
- $this->markTestIncomplete();
- }
+ public function testGet_connector()
+ {
+ $this->markTestIncomplete();
+ }
- public function testlist_elements()
- {
- $this->markTestIncomplete();
- }
+ public function testlist_elements()
+ {
+ $this->markTestIncomplete();
+ }
- public function testlist_containers()
- {
- $this->markTestIncomplete();
- }
+ public function testlist_containers()
+ {
+ $this->markTestIncomplete();
+ }
- public function testupdate_element()
- {
- $this->markTestIncomplete();
- }
+ public function testupdate_element()
+ {
+ $this->markTestIncomplete();
+ }
- public function testcreate_container()
- {
- $this->markTestIncomplete();
- }
+ public function testcreate_container()
+ {
+ $this->markTestIncomplete();
+ }
- public function testadd_element_to_container()
- {
- $this->markTestIncomplete();
- }
+ public function testadd_element_to_container()
+ {
+ $this->markTestIncomplete();
+ }
- public function testdelete_object()
- {
- $this->markTestIncomplete();
- }
+ public function testdelete_object()
+ {
+ $this->markTestIncomplete();
+ }
- public function testacceptable_records()
- {
- $this->markTestIncomplete();
- }
+ public function testacceptable_records()
+ {
+ $this->markTestIncomplete();
+ }
- public function testget_element_from_id()
- {
- $this->markTestIncomplete();
- }
+ public function testget_element_from_id()
+ {
+ $this->markTestIncomplete();
+ }
- public function testget_container_from_id()
- {
- $this->markTestIncomplete();
- }
+ public function testget_container_from_id()
+ {
+ $this->markTestIncomplete();
+ }
- public function testget_category_list()
- {
- $this->markTestIncomplete();
- }
+ public function testget_category_list()
+ {
+ $this->markTestIncomplete();
+ }
- public function testget_element_status()
- {
- $this->markTestIncomplete();
- }
+ public function testget_element_status()
+ {
+ $this->markTestIncomplete();
+ }
- public function testmap_connector_to_element_status()
- {
- $this->markTestIncomplete();
- }
+ public function testmap_connector_to_element_status()
+ {
+ $this->markTestIncomplete();
+ }
- public function testupload()
- {
- $this->markTestIncomplete();
- }
+ public function testupload()
+ {
+ $this->markTestIncomplete();
+ }
- public function testgenerate_callback_url()
- {
- $this->markTestIncomplete();
- }
+ public function testgenerate_callback_url()
+ {
+ $this->markTestIncomplete();
+ }
- public function testgenerate_login_url()
- {
- $this->markTestIncomplete();
- }
+ public function testgenerate_login_url()
+ {
+ $this->markTestIncomplete();
+ }
- public function testget_connector_by_name()
- {
- $this->markTestIncomplete();
- }
+ public function testget_connector_by_name()
+ {
+ $this->markTestIncomplete();
+ }
- public function testget_by_api_name()
- {
- $this->markTestIncomplete();
- }
-
- public function testget_availables()
- {
- $this->markTestIncomplete();
- }
+ public function testget_by_api_name()
+ {
+ $this->markTestIncomplete();
+ }
+ public function testget_availables()
+ {
+ $this->markTestIncomplete();
+ }
}
-
diff --git a/tests/Bridge/Bridge_ElementTest.php b/tests/Bridge/Bridge_ElementTest.php
index b9ba2f74b5..f73c87d3f9 100644
--- a/tests/Bridge/Bridge_ElementTest.php
+++ b/tests/Bridge/Bridge_ElementTest.php
@@ -5,181 +5,176 @@ require_once __DIR__ . '/Bridge_datas.inc';
class Bridge_ElementTest extends PhraseanetPHPUnitAuthenticatedAbstract
{
+ /**
+ * @var Bridge_Element
+ */
+ protected $object;
+ protected $account;
+ protected $api;
+ protected $dist_id;
+ protected $named;
+ protected $id;
+ protected $title;
+ protected $status;
+ protected static $need_records = 1;
- /**
- * @var Bridge_Element
- */
- protected $object;
- protected $account;
- protected $api;
- protected $dist_id;
- protected $named;
- protected $id;
- protected $title;
- protected $status;
- protected static $need_records = 1;
-
- public function setUp()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
-
- $sql = 'DELETE FROM bridge_apis WHERE name = "Apitest"';
- $stmt = $appbox->get_connection()->prepare($sql);
- $stmt->execute();
- $stmt->closeCursor();
-
- $this->api = Bridge_Api::create($appbox, 'Apitest');
- $this->dist_id = 'EZ1565loPP';
- $this->named = 'Fête à pinpins';
- $this->account = Bridge_Account::create($appbox, $this->api, self::$user, $this->dist_id, $this->named);
-
- $this->title = 'GOGACKO';
- $this->status = 'Processing';
-
- $element = Bridge_Element::create($appbox, $this->account, self::$record_1, $this->title, $this->status, $this->account->get_api()->get_connector()->get_default_element_type());
- $this->id = $element->get_id();
- $this->object = new Bridge_Element($appbox, $this->account, $this->id);
- }
-
- public function tearDown()
- {
-
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $this->object->delete();
-
- try
+ public function setUp()
{
- new Bridge_Element($appbox, $this->account, $this->id);
- $this->fail();
+ parent::setUp();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+
+ $sql = 'DELETE FROM bridge_apis WHERE name = "Apitest"';
+ $stmt = $appbox->get_connection()->prepare($sql);
+ $stmt->execute();
+ $stmt->closeCursor();
+
+ $this->api = Bridge_Api::create($appbox, 'Apitest');
+ $this->dist_id = 'EZ1565loPP';
+ $this->named = 'Fête à pinpins';
+ $this->account = Bridge_Account::create($appbox, $this->api, self::$user, $this->dist_id, $this->named);
+
+ $this->title = 'GOGACKO';
+ $this->status = 'Processing';
+
+ $element = Bridge_Element::create($appbox, $this->account, self::$record_1, $this->title, $this->status, $this->account->get_api()->get_connector()->get_default_element_type());
+ $this->id = $element->get_id();
+ $this->object = new Bridge_Element($appbox, $this->account, $this->id);
}
- catch (Bridge_Exception_ElementNotFound $e)
+
+ public function tearDown()
+ {
+
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $this->object->delete();
+
+ try {
+ new Bridge_Element($appbox, $this->account, $this->id);
+ $this->fail();
+ } catch (Bridge_Exception_ElementNotFound $e) {
+
+ }
+
+ $this->api->delete();
+ parent::tearDown();
+ }
+
+ public function testGet_account()
+ {
+ $this->assertInstanceOf('Bridge_Account', $this->object->get_account());
+ $this->assertEquals($this->account, $this->object->get_account());
+ $this->assertEquals($this->account->get_id(), $this->object->get_account()->get_id());
+ }
+
+ public function testGet_id()
{
}
- $this->api->delete();
- }
-
- public function testGet_account()
- {
- $this->assertInstanceOf('Bridge_Account', $this->object->get_account());
- $this->assertEquals($this->account, $this->object->get_account());
- $this->assertEquals($this->account->get_id(), $this->object->get_account()->get_id());
- }
-
- public function testGet_id()
- {
-
- }
-
- public function testGet_record()
- {
- $this->assertInstanceOf('record_adapter', $this->object->get_record());
- $this->assertEquals(self::$record_1->get_sbas_id(), $this->object->get_record()->get_sbas_id());
- $this->assertEquals(self::$record_1->get_record_id(), $this->object->get_record()->get_record_id());
- }
-
- public function testGet_dist_id()
- {
- $this->assertNull($this->object->get_dist_id());
- }
-
- public function testGet_status()
- {
- $this->assertEquals($this->status, $this->object->get_status());
- }
-
- public function testSet_status()
- {
- $update1 = $this->object->get_updated_on();
- $new_status = '&é"\'(-è_çà)';
- $this->object->set_status($new_status);
- $this->assertEquals($new_status, $this->object->get_status());
- sleep(1);
- $new_status = '&é"0687345àç_)à)';
- $this->object->set_status($new_status);
- $this->assertEquals($new_status, $this->object->get_status());
- $update2 = $this->object->get_updated_on();
- $this->assertTrue($update2 > $update1);
- }
-
- public function testGet_title()
- {
- $this->assertEquals($this->title, $this->object->get_title());
- }
-
- public function testGet_type()
- {
- $this->markTestIncomplete();
- }
-
- public function testSet_title()
- {
- $update1 = $this->object->get_updated_on();
- sleep(1);
- $new_title = 'Cigares du pharaon';
- $this->object->set_title($new_title);
- $this->assertEquals($new_title, $this->object->get_title());
- $update2 = $this->object->get_updated_on();
- $this->assertTrue($update2 > $update1);
- }
-
- public function testSet_distid()
- {
- $update1 = $this->object->get_updated_on();
- sleep(1);
- $this->object->set_dist_id($this->dist_id);
- $this->assertEquals($this->dist_id, $this->object->get_dist_id());
- $update2 = $this->object->get_updated_on();
- $this->assertTrue($update2 > $update1);
- }
-
- public function testGet_created_on()
- {
- $this->assertInstanceOf('DateTime', $this->object->get_created_on());
- }
-
- public function testGet_updated_on()
- {
- $this->assertInstanceOf('DateTime', $this->object->get_updated_on());
- }
-
- public function testGet_elements_by_account()
- {
- $elements = Bridge_Element::get_elements_by_account(appbox::get_instance(\bootstrap::getCore()), $this->account);
- $this->assertTrue(is_array($elements));
- $this->assertGreaterThan(0, count($elements));
-
- foreach ($elements as $element)
+ public function testGet_record()
{
- $this->assertInstanceOf('Bridge_Element', $element);
+ $this->assertInstanceOf('record_adapter', $this->object->get_record());
+ $this->assertEquals(self::$record_1->get_sbas_id(), $this->object->get_record()->get_sbas_id());
+ $this->assertEquals(self::$record_1->get_record_id(), $this->object->get_record()->get_record_id());
}
- }
- public function testGet_connector_status()
- {
- $this->markTestIncomplete();
- }
+ public function testGet_dist_id()
+ {
+ $this->assertNull($this->object->get_dist_id());
+ }
- public function testSet_connector_status()
- {
- $this->markTestIncomplete();
- }
+ public function testGet_status()
+ {
+ $this->assertEquals($this->status, $this->object->get_status());
+ }
- public function testGet_datas()
- {
- $this->markTestIncomplete();
- }
+ public function testSet_status()
+ {
+ $update1 = $this->object->get_updated_on();
+ $new_status = '&é"\'(-è_çà)';
+ $this->object->set_status($new_status);
+ $this->assertEquals($new_status, $this->object->get_status());
+ sleep(1);
+ $new_status = '&é"0687345àç_)à)';
+ $this->object->set_status($new_status);
+ $this->assertEquals($new_status, $this->object->get_status());
+ $update2 = $this->object->get_updated_on();
+ $this->assertTrue($update2 > $update1);
+ }
- public function testSet_datas()
- {
- $this->markTestIncomplete();
- }
+ public function testGet_title()
+ {
+ $this->assertEquals($this->title, $this->object->get_title());
+ }
- public function test()
- {
- $this->markTestIncomplete();
- }
+ public function testGet_type()
+ {
+ $this->markTestIncomplete();
+ }
+ public function testSet_title()
+ {
+ $update1 = $this->object->get_updated_on();
+ sleep(1);
+ $new_title = 'Cigares du pharaon';
+ $this->object->set_title($new_title);
+ $this->assertEquals($new_title, $this->object->get_title());
+ $update2 = $this->object->get_updated_on();
+ $this->assertTrue($update2 > $update1);
+ }
+
+ public function testSet_distid()
+ {
+ $update1 = $this->object->get_updated_on();
+ sleep(1);
+ $this->object->set_dist_id($this->dist_id);
+ $this->assertEquals($this->dist_id, $this->object->get_dist_id());
+ $update2 = $this->object->get_updated_on();
+ $this->assertTrue($update2 > $update1);
+ }
+
+ public function testGet_created_on()
+ {
+ $this->assertInstanceOf('DateTime', $this->object->get_created_on());
+ }
+
+ public function testGet_updated_on()
+ {
+ $this->assertInstanceOf('DateTime', $this->object->get_updated_on());
+ }
+
+ public function testGet_elements_by_account()
+ {
+ $elements = Bridge_Element::get_elements_by_account(appbox::get_instance(\bootstrap::getCore()), $this->account);
+ $this->assertTrue(is_array($elements));
+ $this->assertGreaterThan(0, count($elements));
+
+ foreach ($elements as $element) {
+ $this->assertInstanceOf('Bridge_Element', $element);
+ }
+ }
+
+ public function testGet_connector_status()
+ {
+ $this->markTestIncomplete();
+ }
+
+ public function testSet_connector_status()
+ {
+ $this->markTestIncomplete();
+ }
+
+ public function testGet_datas()
+ {
+ $this->markTestIncomplete();
+ }
+
+ public function testSet_datas()
+ {
+ $this->markTestIncomplete();
+ }
+
+ public function test()
+ {
+ $this->markTestIncomplete();
+ }
}
-
diff --git a/tests/Bridge/Bridge_datas.inc b/tests/Bridge/Bridge_datas.inc
index 32e86b4bd5..fa990c142d 100644
--- a/tests/Bridge/Bridge_datas.inc
+++ b/tests/Bridge/Bridge_datas.inc
@@ -1,547 +1,513 @@
id;
+ }
- public function get_id()
- {
- return $this->id;
- }
+ public function get_thumbnail($width = 120, $height = 90)
+ {
- public function get_thumbnail($width = 120, $height = 90)
- {
+ }
- }
+ public function get_title()
+ {
- public function get_title()
- {
+ }
- }
+ public function get_type()
+ {
+ return $this->type;
+ }
- public function get_type()
- {
- return $this->type;
- }
+ public function get_updated_on()
+ {
- public function get_updated_on()
- {
+ }
- }
+ public function get_url()
+ {
- public function get_url()
- {
+ }
- }
+ public function get_category()
+ {
- public function get_category()
- {
+ }
- }
+ public function is_private()
+ {
- public function is_private()
- {
+ }
- }
-
- public function get_rating()
- {
-
- }
+ public function get_rating()
+ {
+ }
}
class Bridge_Api_Apitest_Element implements Bridge_Api_ElementInterface
{
+ public $id;
+ public $type;
- public $id;
- public $type;
+ public function __construct()
+ {
- public function __construct()
- {
+ }
- }
+ public function get_category()
+ {
- public function get_category()
- {
+ }
- }
+ public function get_created_on()
+ {
- public function get_created_on()
- {
+ }
- }
+ public function get_description()
+ {
- public function get_description()
- {
+ }
- }
+ public function get_duration()
+ {
- public function get_duration()
- {
+ }
- }
+ public function get_id()
+ {
+ return $this->id;
+ }
- public function get_id()
- {
- return $this->id;
- }
+ public function get_rating()
+ {
- public function get_rating()
- {
+ }
- }
+ public function get_thumbnail()
+ {
- public function get_thumbnail()
- {
+ }
- }
+ public function get_title()
+ {
- public function get_title()
- {
+ }
- }
+ public function get_type()
+ {
+ return $this->type;
+ }
- public function get_type()
- {
- return $this->type;
- }
+ public function get_updated_on()
+ {
- public function get_updated_on()
- {
+ }
- }
+ public function get_url()
+ {
- public function get_url()
- {
+ }
- }
+ public function get_view_count()
+ {
- public function get_view_count()
- {
+ }
- }
-
- public function is_private()
- {
-
- }
+ public function is_private()
+ {
+ }
}
class Bridge_Api_Apitest extends Bridge_Api_Abstract implements Bridge_Api_Interface
{
+ const AUTH_TYPE = 'None';
- const AUTH_TYPE = 'None';
+ public static $hasError = false;
+ public static $hasException = false;
- public static $hasError = false;
- public static $hasException = false;
-
- public function __construct(registryInterface $registry, Bridge_Api_Auth_Interface $auth)
- {
- parent::__construct($registry, $auth);
- }
-
- protected function initialize_transport()
- {
-
- }
-
- protected function set_auth_params()
- {
-
- }
-
- protected function set_transport_authentication_params()
- {
-
- }
-
- public function get_terms_url()
- {
- return 'http://example.com/terms.html';
- }
-
- /**
- *
- * @return Array
- */
- public function connect()
- {
- return array('auth_token' => 'kikoo', 'refresh_token' => 'kooki');
- }
-
- /**
- *
- * @return Bridge_Api_Interface
- */
- public function reconnect()
- {
- return parent::reconnect();
- }
-
- /**
- *
- * @return Bridge_Api_Interface
- */
- public function disconnect()
- {
- return parent::disconnect();
- }
-
- /**
- *
- * @return boolean
- */
- public function is_connected()
- {
- return parent::is_connected();
- }
-
- /**
- *
- * @return Bridge_Api_Interface
- */
- public function set_locale($locale)
- {
-
- }
-
- /**
- *
- * @return string
- */
- public function get_name()
- {
- return 'Youtube';
- }
-
- /**
- *
- * @return string
- */
- public function get_icon_url()
- {
-
- }
-
- /**
- *
- * @return string
- */
- public function get_image_url()
- {
-
- }
-
- /**
- *
- * @return string
- */
- public function get_url()
- {
-
- }
-
- /**
- *
- * @return string
- */
- public function get_infos()
- {
-
- }
-
- public function get_object_class_from_type($type)
- {
- switch ($type)
+ public function __construct(registryInterface $registry, Bridge_Api_Auth_Interface $auth)
{
- case $this->get_default_element_type() :
- return Bridge_Api_Interface::OBJECT_CLASS_ELEMENT;
- break;
- case $this->get_default_container_type() :
- return Bridge_Api_Interface::OBJECT_CLASS_CONTAINER;
- break;
- }
- }
-
- public function get_default_element_type()
- {
- return 'video';
- }
-
- public function get_default_container_type()
- {
- return 'playlist';
- }
-
- public function get_element_types()
- {
-
- }
-
- public function get_container_types()
- {
-
- }
-
- public function get_element_from_id($element_id, $object)
- {
- $element = new Bridge_Api_Apitest_Element();
- $element->id = $element_id;
- $element->type = $object;
-
- return $element;
- }
-
- public function get_container_from_id($element_id, $object)
- {
- $container = new Bridge_Api_Apitest_Containers();
- $container->id = $element_id;
- $container->type = $object;
-
- return $container;
- }
-
- public function get_category_list()
- {
-
- }
-
- public function get_user_name()
- {
- return "coucou";
- }
-
- public function get_user_id()
- {
- return 'kirikoo';
- }
-
- public function list_elements($type, $offset_start = 0, $quantity = 10)
- {
- $element_collection = new Bridge_Api_ElementCollection();
- $i = 0;
- while ($i < 5)
- {
- $element_collection->add_element(new Bridge_Api_Apitest_Element());
- $i++;
+ parent::__construct($registry, $auth);
}
- return $element_collection;
- }
-
- public function list_containers($type, $offset_start = 0, $quantity = 10)
- {
- $container_collection = new Bridge_Api_ContainerCollection();
- $i = 0;
- while ($i < 5)
+ protected function initialize_transport()
{
- $container_collection->add_element(new Bridge_Api_Apitest_Containers());
- $i++;
+
}
- return $container_collection;
- }
-
- public function update_element($object, $object_id, Array $datas)
- {
-
- }
-
- public function create_container($container_type, \Symfony\Component\HttpFoundation\Request $request)
- {
- if (self::$hasException)
+ protected function set_auth_params()
{
- self::$hasException = false;
- throw new \Exception("une erreur");
- }
- }
- public function add_element_to_container($element_type, $element_id, $destination, $container_id)
- {
- if (self::$hasException)
+ }
+
+ protected function set_transport_authentication_params()
{
- self::$hasException = false;
- throw new \Exception("une erreur");
- }
- }
- public function delete_object($object, $object_id)
- {
- if (self::$hasException)
+ }
+
+ public function get_terms_url()
{
- self::$hasException = false;
- throw new \Exception("une erreur");
+ return 'http://example.com/terms.html';
}
- }
- /**
- *
- * @return Closure
- */
- public function acceptable_records()
- {
- $func = function($record)
- {
- return true;
+ /**
+ *
+ * @return Array
+ */
+ public function connect()
+ {
+ return array('auth_token' => 'kikoo', 'refresh_token' => 'kooki');
+ }
+
+ /**
+ *
+ * @return Bridge_Api_Interface
+ */
+ public function reconnect()
+ {
+ return parent::reconnect();
+ }
+
+ /**
+ *
+ * @return Bridge_Api_Interface
+ */
+ public function disconnect()
+ {
+ return parent::disconnect();
+ }
+
+ /**
+ *
+ * @return boolean
+ */
+ public function is_connected()
+ {
+ return parent::is_connected();
+ }
+
+ /**
+ *
+ * @return Bridge_Api_Interface
+ */
+ public function set_locale($locale)
+ {
+
+ }
+
+ /**
+ *
+ * @return string
+ */
+ public function get_name()
+ {
+ return 'Youtube';
+ }
+
+ /**
+ *
+ * @return string
+ */
+ public function get_icon_url()
+ {
+
+ }
+
+ /**
+ *
+ * @return string
+ */
+ public function get_image_url()
+ {
+
+ }
+
+ /**
+ *
+ * @return string
+ */
+ public function get_url()
+ {
+
+ }
+
+ /**
+ *
+ * @return string
+ */
+ public function get_infos()
+ {
+
+ }
+
+ public function get_object_class_from_type($type)
+ {
+ switch ($type) {
+ case $this->get_default_element_type() :
+ return Bridge_Api_Interface::OBJECT_CLASS_ELEMENT;
+ break;
+ case $this->get_default_container_type() :
+ return Bridge_Api_Interface::OBJECT_CLASS_CONTAINER;
+ break;
+ }
+ }
+
+ public function get_default_element_type()
+ {
+ return 'video';
+ }
+
+ public function get_default_container_type()
+ {
+ return 'playlist';
+ }
+
+ public function get_element_types()
+ {
+
+ }
+
+ public function get_container_types()
+ {
+
+ }
+
+ public function get_element_from_id($element_id, $object)
+ {
+ $element = new Bridge_Api_Apitest_Element();
+ $element->id = $element_id;
+ $element->type = $object;
+
+ return $element;
+ }
+
+ public function get_container_from_id($element_id, $object)
+ {
+ $container = new Bridge_Api_Apitest_Containers();
+ $container->id = $element_id;
+ $container->type = $object;
+
+ return $container;
+ }
+
+ public function get_category_list()
+ {
+
+ }
+
+ public function get_user_name()
+ {
+ return "coucou";
+ }
+
+ public function get_user_id()
+ {
+ return 'kirikoo';
+ }
+
+ public function list_elements($type, $offset_start = 0, $quantity = 10)
+ {
+ $element_collection = new Bridge_Api_ElementCollection();
+ $i = 0;
+ while ($i < 5) {
+ $element_collection->add_element(new Bridge_Api_Apitest_Element());
+ $i ++;
+ }
+
+ return $element_collection;
+ }
+
+ public function list_containers($type, $offset_start = 0, $quantity = 10)
+ {
+ $container_collection = new Bridge_Api_ContainerCollection();
+ $i = 0;
+ while ($i < 5) {
+ $container_collection->add_element(new Bridge_Api_Apitest_Containers());
+ $i ++;
+ }
+
+ return $container_collection;
+ }
+
+ public function update_element($object, $object_id, Array $datas)
+ {
+
+ }
+
+ public function create_container($container_type, \Symfony\Component\HttpFoundation\Request $request)
+ {
+ if (self::$hasException) {
+ self::$hasException = false;
+ throw new \Exception("une erreur");
+ }
+ }
+
+ public function add_element_to_container($element_type, $element_id, $destination, $container_id)
+ {
+ if (self::$hasException) {
+ self::$hasException = false;
+ throw new \Exception("une erreur");
+ }
+ }
+
+ public function delete_object($object, $object_id)
+ {
+ if (self::$hasException) {
+ self::$hasException = false;
+ throw new \Exception("une erreur");
+ }
+ }
+
+ /**
+ *
+ * @return Closure
+ */
+ public function acceptable_records()
+ {
+ $func = function($record) {
+ return true;
};
- return $func;
- }
-
- public function get_element_status(Bridge_Element $element)
- {
-
- }
-
- public function map_connector_to_element_status($status)
- {
-
- }
-
- public function get_error_message_from_status($connector_status)
- {
-
- }
-
- public function upload(record_adapter &$record, array $options = array())
- {
-
- }
-
- public function is_valid_object_id($object_id)
- {
-
- }
-
- public function is_configured()
- {
- return true;
- }
-
- public function check_upload_constraints(array $datas, record_adapter $record)
- {
- if (self::$hasError)
- {
- self::$hasError = false;
-
- return array('title' => 'too long');
+ return $func;
}
- return array();
- }
-
- public function get_upload_datas(\Symfony\Component\HttpFoundation\Request $request, record_adapter $record)
- {
- return array();
- }
-
- public function is_multiple_upload()
- {
-
- }
-
- public function check_update_constraints(Array $datas)
- {
- if (!self::$hasError)
+ public function get_element_status(Bridge_Element $element)
{
- if (self::$hasException)
- {
- self::$hasException = false;
- throw new \Exception('une erreur');
- }
- return array();
}
- elseif (self::$hasError)
+
+ public function map_connector_to_element_status($status)
{
- self::$hasError = false;
- return array('title' => 'too long');
}
- }
- public function get_update_datas(\Symfony\Component\HttpFoundation\Request $request)
- {
- return array();
- }
+ public function get_error_message_from_status($connector_status)
+ {
+ }
+
+ public function upload(record_adapter &$record, array $options = array())
+ {
+
+ }
+
+ public function is_valid_object_id($object_id)
+ {
+
+ }
+
+ public function is_configured()
+ {
+ return true;
+ }
+
+ public function check_upload_constraints(array $datas, record_adapter $record)
+ {
+ if (self::$hasError) {
+ self::$hasError = false;
+
+ return array('title' => 'too long');
+ }
+
+ return array();
+ }
+
+ public function get_upload_datas(\Symfony\Component\HttpFoundation\Request $request, record_adapter $record)
+ {
+ return array();
+ }
+
+ public function is_multiple_upload()
+ {
+
+ }
+
+ public function check_update_constraints(Array $datas)
+ {
+ if ( ! self::$hasError) {
+ if (self::$hasException) {
+ self::$hasException = false;
+ throw new \Exception('une erreur');
+ }
+
+ return array();
+ } elseif (self::$hasError) {
+ self::$hasError = false;
+
+ return array('title' => 'too long');
+ }
+ }
+
+ public function get_update_datas(\Symfony\Component\HttpFoundation\Request $request)
+ {
+ return array();
+ }
}
class Bridge_Api_Auth_None extends Bridge_Api_Auth_Abstract implements Bridge_Api_Auth_Interface
{
- public function connect($param)
- {
+ public function connect($param)
+ {
- }
+ }
- public function parse_request_token()
- {
+ public function parse_request_token()
+ {
- }
+ }
- public function reconnect()
- {
- $this->settings->set('access_token', 'biloute');
- }
+ public function reconnect()
+ {
+ $this->settings->set('access_token', 'biloute');
+ }
- public function disconnect()
- {
- $this->settings->set('auth_token', null);
- }
+ public function disconnect()
+ {
+ $this->settings->set('auth_token', null);
+ }
- public function is_connected()
- {
- return $this->settings->get('auth_token', null) !== null;
- }
+ public function is_connected()
+ {
+ return $this->settings->get('auth_token', null) !== null;
+ }
- public function get_auth_url(Array $supp_parameters = array())
- {
- return 'kameamea';
- }
+ public function get_auth_url(Array $supp_parameters = array())
+ {
+ return 'kameamea';
+ }
- public function get_auth_signatures()
- {
+ public function get_auth_signatures()
+ {
- }
+ }
- public function set_parameters(Array $parameters)
- {
-
- }
+ public function set_parameters(Array $parameters)
+ {
+ }
}
diff --git a/tests/Doctrine/Entities/BasketTest.php b/tests/Doctrine/Entities/BasketTest.php
index 02945673fe..4e6eae0e18 100644
--- a/tests/Doctrine/Entities/BasketTest.php
+++ b/tests/Doctrine/Entities/BasketTest.php
@@ -1,195 +1,172 @@
em = self::$core->getEntityManager();
+ $this->basket = $this->insertOneBasket();
+ }
- public function setUp()
- {
- parent::setUp();
- $this->em = self::$core->getEntityManager();
- $this->basket = $this->insertOneBasket();
- }
+ public function testGetId()
+ {
+ $this->assertTrue(is_int($this->basket->getId()));
+ $otherBasket = $this->insertOneBasket();
+ $this->assertGreaterThan($this->basket->getId(), $otherBasket->getId());
+ }
- public function tearDown()
- {
- parent::tearDown();
- }
+ public function testGetName()
+ {
+ $this->basket->setName('one name');
+ $this->em->persist($this->basket);
+ $this->em->flush();
+ $this->assertEquals('one name', $this->basket->getName());
+ }
- public function testGetId()
- {
- $this->assertTrue(is_int($this->basket->getId()));
- $otherBasket = $this->insertOneBasket();
- $this->assertGreaterThan($this->basket->getId(), $otherBasket->getId());
- }
+ public function testGetDescription()
+ {
+ $this->basket->setDescription('une jolie description pour mon super panier');
+ $this->em->persist($this->basket);
+ $this->em->flush();
+ $this->assertEquals('une jolie description pour mon super panier', $this->basket->getDescription());
+ }
- public function testGetName()
- {
- $this->basket->setName('one name');
- $this->em->persist($this->basket);
- $this->em->flush();
- $this->assertEquals('one name', $this->basket->getName());
- }
+ public function testGetUsrId()
+ {
+ $this->basket->setUsrId(1);
+ $this->em->persist($this->basket);
+ $this->em->flush();
+ $this->assertEquals(1, $this->basket->getUsrId());
+ }
- public function testGetDescription()
- {
- $this->basket->setDescription('une jolie description pour mon super panier');
- $this->em->persist($this->basket);
- $this->em->flush();
- $this->assertEquals('une jolie description pour mon super panier', $this->basket->getDescription());
- }
+ public function testGetPusherId()
+ {
+ $this->basket->setPusherId(1);
+ $this->em->persist($this->basket);
+ $this->em->flush();
+ $this->assertEquals(1, $this->basket->getPusherId());
+ }
- public function testGetUsrId()
- {
- $this->basket->setUsrId(1);
- $this->em->persist($this->basket);
- $this->em->flush();
- $this->assertEquals(1, $this->basket->getUsrId());
- }
+ public function testGetArchived()
+ {
+ $this->basket->setArchived(true);
+ $this->em->persist($this->basket);
+ $this->em->flush();
+ $this->assertTrue($this->basket->GetArchived());
+ $this->basket->setArchived(false);
+ $this->em->persist($this->basket);
+ $this->em->flush();
+ $this->assertFalse($this->basket->GetArchived());
+ }
- public function testGetPusherId()
- {
- $this->basket->setPusherId(1);
- $this->em->persist($this->basket);
- $this->em->flush();
- $this->assertEquals(1, $this->basket->getPusherId());
- }
+ public function testGetCreated()
+ {
+ $date = $this->basket->getCreated();
+ $this->assertInstanceOf('\DateTime', $date);
+ }
- public function testGetArchived()
- {
- $this->basket->setArchived(true);
- $this->em->persist($this->basket);
- $this->em->flush();
- $this->assertTrue($this->basket->GetArchived());
- $this->basket->setArchived(false);
- $this->em->persist($this->basket);
- $this->em->flush();
- $this->assertFalse($this->basket->GetArchived());
- }
+ public function testGetUpdated()
+ {
+ $date = $this->basket->getUpdated();
+ $this->assertInstanceOf('\DateTime', $date);
+ }
- public function testGetCreated()
- {
- $date = $this->basket->getCreated();
- $this->assertInstanceOf('\DateTime', $date);
- }
+ public function testGetElements()
+ {
+ $elements = $this->basket->getElements();
- public function testGetUpdated()
- {
- $date = $this->basket->getUpdated();
- $this->assertInstanceOf('\DateTime', $date);
+ $this->assertInstanceOf('\Doctrine\ORM\PersistentCollection', $elements);
- }
+ $this->assertEquals(0, $elements->count());
- public function testGetElements()
- {
- $elements = $this->basket->getElements();
+ $basketElement = new \Entities\BasketElement();
- $this->assertInstanceOf('\Doctrine\ORM\PersistentCollection', $elements);
+ $basketElement->setRecord(self::$record_1);
- $this->assertEquals(0, $elements->count());
+ $basketElement->setBasket($this->basket);
- $basketElement = new \Entities\BasketElement();
+ $this->em->persist($basketElement);
- $basketElement->setRecord(self::$record_1);
+ $this->em->flush();
- $basketElement->setBasket($this->basket);
+ $this->em->refresh($this->basket);
- $this->em->persist($basketElement);
+ $this->assertEquals(1, $this->basket->getElements()->count());
+ }
- $this->em->flush();
+ public function testGetPusher()
+ {
+ $this->assertNull($this->basket->getPusher()); //no pusher
+ $this->basket->setPusherId(self::$user->get_id());
+ $this->assertInstanceOf('\User_Adapter', $this->basket->getPusher());
+ $this->assertEquals($this->basket->getPusher()->get_id(), self::$user->get_id());
+ }
- $this->em->refresh($this->basket);
+ public function testGetOwner()
+ {
+ $this->assertNotNull($this->basket->getOwner()); //no owner
+ $this->basket->setUsrId(self::$user->get_id());
+ $this->assertInstanceOf('\User_Adapter', $this->basket->getOwner());
+ $this->assertEquals($this->basket->getOwner()->get_id(), self::$user->get_id());
+ }
- $this->assertEquals(1, $this->basket->getElements()->count());
- }
+ public function testGetValidation()
+ {
+ $this->assertNull($this->basket->getValidation());
- public function testGetPusher()
- {
- $this->assertNull($this->basket->getPusher()); //no pusher
- $this->basket->setPusherId(self::$user->get_id());
- $this->assertInstanceOf('\User_Adapter', $this->basket->getPusher());
- $this->assertEquals($this->basket->getPusher()->get_id(), self::$user->get_id());
- }
+ $validationSession = new \Entities\ValidationSession();
- public function testGetOwner()
- {
- $this->assertNotNull($this->basket->getOwner()); //no owner
- $this->basket->setUsrId(self::$user->get_id());
- $this->assertInstanceOf('\User_Adapter', $this->basket->getOwner());
- $this->assertEquals($this->basket->getOwner()->get_id(), self::$user->get_id());
- }
+ $validationSession->setBasket($this->basket);
- public function testGetValidation()
- {
- $this->assertNull($this->basket->getValidation());
+ $validationSession->setDescription('Une description au hasard');
- $validationSession = new \Entities\ValidationSession();
+ $validationSession->setName('Un nom de validation');
- $validationSession->setBasket($this->basket);
+ $expires = new \DateTime();
+ $expires->modify('+1 week');
- $validationSession->setDescription('Une description au hasard');
+ $validationSession->setExpires($expires);
- $validationSession->setName('Un nom de validation');
+ $validationSession->setInitiator(self::$user);
- $expires = new \DateTime();
- $expires->modify('+1 week');
+ $this->em->persist($validationSession);
- $validationSession->setExpires($expires);
+ $this->em->flush();
- $validationSession->setInitiator(self::$user);
+ $this->em->refresh($this->basket);
- $this->em->persist($validationSession);
+ $this->assertInstanceOf('\Entities\ValidationSession', $this->basket->getValidation());
+ }
- $this->em->flush();
+ public function testGetIsRead()
+ {
+ $this->markTestIncomplete();
+ }
- $this->em->refresh($this->basket);
-
- $this->assertInstanceOf('\Entities\ValidationSession', $this->basket->getValidation());
- }
-
- public function testGetIsRead()
- {
- $this->markTestIncomplete();
- }
-
- public function testGetSize()
- {
- $this->markTestIncomplete();
- }
-
- public function hasRecord()
- {
- $this->markTestIncomplete();
- }
+ public function testGetSize()
+ {
+ $this->markTestIncomplete();
+ }
+ public function hasRecord()
+ {
+ $this->markTestIncomplete();
+ }
}
diff --git a/tests/Feed/Entry/Feed_Entry_AdapterTest.php b/tests/Feed/Entry/Feed_Entry_AdapterTest.php
index 5229208f55..d3b2f14d4b 100644
--- a/tests/Feed/Entry/Feed_Entry_AdapterTest.php
+++ b/tests/Feed/Entry/Feed_Entry_AdapterTest.php
@@ -4,153 +4,147 @@ require_once __DIR__ . '/../../PhraseanetPHPUnitAuthenticatedAbstract.class.inc'
class Feed_Entry_AdapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
{
+ /**
+ *
+ * @var Feed_Entry_Adapter
+ */
+ protected static $object;
- /**
- *
- * @var Feed_Entry_Adapter
- */
- protected static $object;
- /**
- *
- * @var Feed_Adapter
- */
- protected static $feed;
- protected static $feed_title = 'Feed test';
- protected static $feed_subtitle = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?';
- protected static $title = 'entry title';
- protected static $subtitle = 'subtitle lalalala';
- protected static $author_name = 'Jean Bonno';
- protected static $author_email = 'Jean@bonno.fr';
+ /**
+ *
+ * @var Feed_Adapter
+ */
+ protected static $feed;
+ protected static $feed_title = 'Feed test';
+ protected static $feed_subtitle = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?';
+ protected static $title = 'entry title';
+ protected static $subtitle = 'subtitle lalalala';
+ protected static $author_name = 'Jean Bonno';
+ protected static $author_email = 'Jean@bonno.fr';
- public static function setUpBeforeClass()
- {
- parent::setUpBeforeClass();
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $auth = new Session_Authentication_None(self::$user);
- $appbox->get_session()->authenticate($auth);
-
- self::$feed = Feed_Adapter::create($appbox, self::$user, self::$feed_title, self::$feed_subtitle);
- $publisher = Feed_Publisher_Adapter::getPublisher($appbox, self::$feed, self::$user);
- self::$object = Feed_Entry_Adapter::create($appbox, self::$feed, $publisher, self::$title, self::$subtitle, self::$author_name, self::$author_email);
- }
-
- public static function tearDownAfterClass()
- {
- self::$feed->delete();
- parent::tearDownAfterClass();
- }
-
- public function testGet_feed()
- {
- $this->assertInstanceOf('Feed_Adapter', self::$object->get_feed());
- $this->assertEquals(self::$feed->get_id(), self::$object->get_feed()->get_id());
- }
-
- public function testGet_id()
- {
- $this->assertTrue(is_int(self::$object->get_id()));
- }
-
- public function testGet_title()
- {
- $this->assertEquals(self::$title, self::$object->get_title());
- }
-
- public function testGet_subtitle()
- {
- $this->assertEquals(self::$subtitle, self::$object->get_subtitle());
- }
-
- public function testSet_title()
- {
- $new_titre = 'UNnouveau titre';
- self::$object->set_title($new_titre);
- $this->assertEquals($new_titre, self::$object->get_title());
- $new_titre = 'UNnouveau titre encore';
- self::$object->set_title($new_titre);
- $this->assertNotEquals($new_titre, self::$object->get_title());
- $this->assertEquals(strip_tags($new_titre), self::$object->get_title());
- try
+ public static function setUpBeforeClass()
{
- self::$object->set_title('');
- $this->fail();
+ parent::setUpBeforeClass();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $auth = new Session_Authentication_None(self::$user);
+ $appbox->get_session()->authenticate($auth);
+
+ self::$feed = Feed_Adapter::create($appbox, self::$user, self::$feed_title, self::$feed_subtitle);
+ $publisher = Feed_Publisher_Adapter::getPublisher($appbox, self::$feed, self::$user);
+ self::$object = Feed_Entry_Adapter::create($appbox, self::$feed, $publisher, self::$title, self::$subtitle, self::$author_name, self::$author_email);
}
- catch (Exception_InvalidArgument $e)
+
+ public static function tearDownAfterClass()
{
-
+ self::$feed->delete();
+ parent::tearDownAfterClass();
}
- }
- public function testSet_subtitle()
- {
- $new_subtitle = 'PROUT
+ public function testGet_feed()
+ {
+ $this->assertInstanceOf('Feed_Adapter', self::$object->get_feed());
+ $this->assertEquals(self::$feed->get_id(), self::$object->get_feed()->get_id());
+ }
+
+ public function testGet_id()
+ {
+ $this->assertTrue(is_int(self::$object->get_id()));
+ }
+
+ public function testGet_title()
+ {
+ $this->assertEquals(self::$title, self::$object->get_title());
+ }
+
+ public function testGet_subtitle()
+ {
+ $this->assertEquals(self::$subtitle, self::$object->get_subtitle());
+ }
+
+ public function testSet_title()
+ {
+ $new_titre = 'UNnouveau titre';
+ self::$object->set_title($new_titre);
+ $this->assertEquals($new_titre, self::$object->get_title());
+ $new_titre = 'UNnouveau titre encore';
+ self::$object->set_title($new_titre);
+ $this->assertNotEquals($new_titre, self::$object->get_title());
+ $this->assertEquals(strip_tags($new_titre), self::$object->get_title());
+ try {
+ self::$object->set_title('');
+ $this->fail();
+ } catch (Exception_InvalidArgument $e) {
+
+ }
+ }
+
+ public function testSet_subtitle()
+ {
+ $new_subtitle = 'PROUT
ET PROUT';
- self::$object->set_subtitle($new_subtitle);
- $this->assertEquals($new_subtitle, self::$object->get_subtitle());
- $new_subtitle = '';
- self::$object->set_subtitle($new_subtitle);
- $this->assertEquals($new_subtitle, self::$object->get_subtitle());
- }
+ self::$object->set_subtitle($new_subtitle);
+ $this->assertEquals($new_subtitle, self::$object->get_subtitle());
+ $new_subtitle = '';
+ self::$object->set_subtitle($new_subtitle);
+ $this->assertEquals($new_subtitle, self::$object->get_subtitle());
+ }
- public function testSet_author_name()
- {
- $new_author = 'Tintin et Milou';
- self::$object->set_author_name($new_author);
- $this->assertEquals($new_author, self::$object->get_author_name());
- self::$object->set_author_name(self::$author_name);
- $this->assertEquals(self::$author_name, self::$object->get_author_name());
- }
+ public function testSet_author_name()
+ {
+ $new_author = 'Tintin et Milou';
+ self::$object->set_author_name($new_author);
+ $this->assertEquals($new_author, self::$object->get_author_name());
+ self::$object->set_author_name(self::$author_name);
+ $this->assertEquals(self::$author_name, self::$object->get_author_name());
+ }
- public function testSet_author_email()
- {
- $new_email = 'Tintin@herge.be';
- self::$object->set_author_email($new_email);
- $this->assertEquals($new_email, self::$object->get_author_email());
- self::$object->set_author_email(self::$author_email);
- $this->assertEquals(self::$author_email, self::$object->get_author_email());
- }
+ public function testSet_author_email()
+ {
+ $new_email = 'Tintin@herge.be';
+ self::$object->set_author_email($new_email);
+ $this->assertEquals($new_email, self::$object->get_author_email());
+ self::$object->set_author_email(self::$author_email);
+ $this->assertEquals(self::$author_email, self::$object->get_author_email());
+ }
- public function testGet_publisher()
- {
- $this->assertInstanceOf('Feed_Publisher_Adapter', self::$object->get_publisher());
- $this->assertEquals(self::$object->get_publisher()->get_user()->get_id(), self::$user->get_id());
- }
+ public function testGet_publisher()
+ {
+ $this->assertInstanceOf('Feed_Publisher_Adapter', self::$object->get_publisher());
+ $this->assertEquals(self::$object->get_publisher()->get_user()->get_id(), self::$user->get_id());
+ }
- public function testGet_created_on()
- {
- $this->assertInstanceOf('DateTime', self::$object->get_created_on());
- }
+ 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());
- }
+ public function testGet_updated_on()
+ {
+ $this->assertInstanceOf('DateTime', self::$object->get_updated_on());
+ }
- public function testGet_author_name()
- {
- $this->assertEquals(self::$author_name, self::$object->get_author_name());
- }
+ public function testGet_author_name()
+ {
+ $this->assertEquals(self::$author_name, self::$object->get_author_name());
+ }
- public function testGet_author_email()
- {
- $this->assertEquals(self::$author_email, self::$object->get_author_email());
- }
+ public function testGet_author_email()
+ {
+ $this->assertEquals(self::$author_email, self::$object->get_author_email());
+ }
- public function testGet_content()
- {
- $this->assertTrue(is_array(self::$object->get_content()));
- $this->assertEquals(0, count(self::$object->get_content()));
- }
+ public function testGet_content()
+ {
+ $this->assertTrue(is_array(self::$object->get_content()));
+ $this->assertEquals(0, count(self::$object->get_content()));
+ }
- public function testLoad_from_id()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $test_entry = Feed_Entry_Adapter::load_from_id($appbox, self::$object->get_id());
-
- $this->assertInstanceOf('Feed_Entry_Adapter', $test_entry);
- $this->assertEquals(self::$object->get_id(), $test_entry->get_id());
-
- }
+ public function testLoad_from_id()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $test_entry = Feed_Entry_Adapter::load_from_id($appbox, self::$object->get_id());
+ $this->assertInstanceOf('Feed_Entry_Adapter', $test_entry);
+ $this->assertEquals(self::$object->get_id(), $test_entry->get_id());
+ }
}
-
diff --git a/tests/Feed/Entry/Feed_Entry_CollectionTest.php b/tests/Feed/Entry/Feed_Entry_CollectionTest.php
index 6954f7f652..49a28ee5a2 100644
--- a/tests/Feed/Entry/Feed_Entry_CollectionTest.php
+++ b/tests/Feed/Entry/Feed_Entry_CollectionTest.php
@@ -4,66 +4,66 @@ require_once __DIR__ . '/../../PhraseanetPHPUnitAuthenticatedAbstract.class.inc'
class Feed_Entry_CollectionTest extends PhraseanetPHPUnitAuthenticatedAbstract
{
+ /**
+ * @var Feed_Entry_Collection
+ */
+ protected static $object;
- /**
- * @var Feed_Entry_Collection
- */
- protected static $object;
- /**
- *
- * @var Feed_Entry_Item
- */
- protected static $item;
- /**
- *
- * @var Feed_Entry_Adapter
- */
- protected static $entry;
- /**
- *
- * @var Feed_Adapter
- */
- protected static $feed;
- protected static $feed_title = 'Feed test';
- protected static $feed_subtitle = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?';
- protected static $title = 'entry title';
- protected static $subtitle = 'subtitle lalalala';
- protected static $author_name = 'Jean Bonno';
- protected static $author_email = 'Jean@bonno.fr';
- protected static $need_records = true;
+ /**
+ *
+ * @var Feed_Entry_Item
+ */
+ protected static $item;
- public static function setUpBeforeClass()
- {
- parent::setUpBeforeClass();
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $auth = new Session_Authentication_None(self::$user);
- $appbox->get_session()->authenticate($auth);
+ /**
+ *
+ * @var Feed_Entry_Adapter
+ */
+ protected static $entry;
- self::$feed = Feed_Adapter::create($appbox, self::$user, self::$feed_title, self::$feed_subtitle);
- $publisher = Feed_Publisher_Adapter::getPublisher($appbox, self::$feed, self::$user);
- self::$entry = Feed_Entry_Adapter::create($appbox, self::$feed, $publisher, self::$title, self::$subtitle, self::$author_name, self::$author_email);
+ /**
+ *
+ * @var Feed_Adapter
+ */
+ protected static $feed;
+ protected static $feed_title = 'Feed test';
+ protected static $feed_subtitle = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?';
+ protected static $title = 'entry title';
+ protected static $subtitle = 'subtitle lalalala';
+ protected static $author_name = 'Jean Bonno';
+ protected static $author_email = 'Jean@bonno.fr';
+ protected static $need_records = true;
- self::$item = Feed_Entry_Item::create($appbox, self::$entry, self::$record_1);
+ public static function setUpBeforeClass()
+ {
+ parent::setUpBeforeClass();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $auth = new Session_Authentication_None(self::$user);
+ $appbox->get_session()->authenticate($auth);
- self::$object = new Feed_Entry_Collection();
- }
+ self::$feed = Feed_Adapter::create($appbox, self::$user, self::$feed_title, self::$feed_subtitle);
+ $publisher = Feed_Publisher_Adapter::getPublisher($appbox, self::$feed, self::$user);
+ self::$entry = Feed_Entry_Adapter::create($appbox, self::$feed, $publisher, self::$title, self::$subtitle, self::$author_name, self::$author_email);
- public static function tearDownAfterClass()
- {
- self::$feed->delete();
- parent::tearDownAfterClass();
- }
+ self::$item = Feed_Entry_Item::create($appbox, self::$entry, self::$record_1);
- public function testAdd_entry()
- {
- self::$object->add_entry(self::$entry);
- }
+ self::$object = new Feed_Entry_Collection();
+ }
- public function testGet_entries()
- {
- $this->assertTrue(is_array(self::$object->get_entries()));
- $this->assertTrue(count(self::$object->get_entries()) == 1);
- }
+ public static function tearDownAfterClass()
+ {
+ self::$feed->delete();
+ parent::tearDownAfterClass();
+ }
+ public function testAdd_entry()
+ {
+ self::$object->add_entry(self::$entry);
+ }
+
+ public function testGet_entries()
+ {
+ $this->assertTrue(is_array(self::$object->get_entries()));
+ $this->assertTrue(count(self::$object->get_entries()) == 1);
+ }
}
-
diff --git a/tests/Feed/Entry/Feed_Entry_ItemTest.php b/tests/Feed/Entry/Feed_Entry_ItemTest.php
index d0415db48d..f1ed4efaa2 100644
--- a/tests/Feed/Entry/Feed_Entry_ItemTest.php
+++ b/tests/Feed/Entry/Feed_Entry_ItemTest.php
@@ -4,73 +4,72 @@ require_once __DIR__ . '/../../PhraseanetPHPUnitAuthenticatedAbstract.class.inc'
class Feed_Entry_ItemTest extends PhraseanetPHPUnitAuthenticatedAbstract
{
+ /**
+ *
+ * @var Feed_Entry_Item
+ */
+ protected static $object;
- /**
- *
- * @var Feed_Entry_Item
- */
- protected static $object;
- /**
- *
- * @var Feed_Entry_Adapter
- */
- protected static $entry;
- /**
- *
- * @var Feed_Adapter
- */
- protected static $feed;
- protected static $feed_title = 'Feed test';
- protected static $feed_subtitle = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?';
- protected static $title = 'entry title';
- protected static $subtitle = 'subtitle lalalala';
- protected static $author_name = 'Jean Bonno';
- protected static $author_email = 'Jean@bonno.fr';
- protected static $need_records = true;
+ /**
+ *
+ * @var Feed_Entry_Adapter
+ */
+ protected static $entry;
- public static function setUpBeforeClass()
- {
- parent::setUpBeforeClass();
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $auth = new Session_Authentication_None(self::$user);
- $appbox->get_session()->authenticate($auth);
+ /**
+ *
+ * @var Feed_Adapter
+ */
+ protected static $feed;
+ protected static $feed_title = 'Feed test';
+ protected static $feed_subtitle = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?';
+ protected static $title = 'entry title';
+ protected static $subtitle = 'subtitle lalalala';
+ protected static $author_name = 'Jean Bonno';
+ protected static $author_email = 'Jean@bonno.fr';
+ protected static $need_records = true;
- self::$feed = Feed_Adapter::create($appbox, self::$user, self::$feed_title, self::$feed_subtitle);
- $publisher = Feed_Publisher_Adapter::getPublisher($appbox, self::$feed, self::$user);
- self::$entry = Feed_Entry_Adapter::create($appbox, self::$feed, $publisher, self::$title, self::$subtitle, self::$author_name, self::$author_email);
+ public static function setUpBeforeClass()
+ {
+ parent::setUpBeforeClass();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $auth = new Session_Authentication_None(self::$user);
+ $appbox->get_session()->authenticate($auth);
- self::$object = Feed_Entry_Item::create($appbox, self::$entry, self::$record_1);
- }
+ self::$feed = Feed_Adapter::create($appbox, self::$user, self::$feed_title, self::$feed_subtitle);
+ $publisher = Feed_Publisher_Adapter::getPublisher($appbox, self::$feed, self::$user);
+ self::$entry = Feed_Entry_Adapter::create($appbox, self::$feed, $publisher, self::$title, self::$subtitle, self::$author_name, self::$author_email);
- public static function tearDownAfterClass()
- {
- self::$feed->delete();
- parent::tearDownAfterClass();
- }
+ self::$object = Feed_Entry_Item::create($appbox, self::$entry, self::$record_1);
+ }
- public function testGet_id()
- {
- $this->assertTrue(is_int(self::$object->get_id()));
- }
+ public static function tearDownAfterClass()
+ {
+ self::$feed->delete();
+ parent::tearDownAfterClass();
+ }
- public function testGet_record()
- {
- $this->assertInstanceOf('record_adapter',self::$object->get_record());
- $this->assertEquals(self::$record_1->get_record_id(), self::$object->get_record()->get_record_id());
- $this->assertEquals(self::$record_1->get_sbas_id(), self::$object->get_record()->get_sbas_id());
- $this->assertEquals(self::$record_1->get_base_id(), self::$object->get_record()->get_base_id());
- }
+ public function testGet_id()
+ {
+ $this->assertTrue(is_int(self::$object->get_id()));
+ }
- public function testGet_ord()
- {
- $this->assertTrue(is_int(self::$object->get_ord()));
- }
+ public function testGet_record()
+ {
+ $this->assertInstanceOf('record_adapter', self::$object->get_record());
+ $this->assertEquals(self::$record_1->get_record_id(), self::$object->get_record()->get_record_id());
+ $this->assertEquals(self::$record_1->get_sbas_id(), self::$object->get_record()->get_sbas_id());
+ $this->assertEquals(self::$record_1->get_base_id(), self::$object->get_record()->get_base_id());
+ }
- public function testGet_entry()
- {
- $this->assertInstanceOf('Feed_Entry_Adapter', self::$object->get_entry());
- $this->assertEquals(self::$entry->get_id(),self::$object->get_entry()->get_id());
- }
+ public function testGet_ord()
+ {
+ $this->assertTrue(is_int(self::$object->get_ord()));
+ }
+ public function testGet_entry()
+ {
+ $this->assertInstanceOf('Feed_Entry_Adapter', self::$object->get_entry());
+ $this->assertEquals(self::$entry->get_id(), self::$object->get_entry()->get_id());
+ }
}
-
diff --git a/tests/Feed/Feed_AdapterTest.php b/tests/Feed/Feed_AdapterTest.php
index 5c87f78e9e..b9090da141 100644
--- a/tests/Feed/Feed_AdapterTest.php
+++ b/tests/Feed/Feed_AdapterTest.php
@@ -268,4 +268,3 @@ class Feed_AdapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
$this->assertInstanceOf('DateTime', self::$object->get_updated_on());
}
}
-
diff --git a/tests/Feed/Feed_AggregateTest.php b/tests/Feed/Feed_AggregateTest.php
index 872ae7f048..b9b503074e 100644
--- a/tests/Feed/Feed_AggregateTest.php
+++ b/tests/Feed/Feed_AggregateTest.php
@@ -4,94 +4,92 @@ require_once __DIR__ . '/../PhraseanetPHPUnitAuthenticatedAbstract.class.inc';
class Feed_AggregateTest extends PhraseanetPHPUnitAuthenticatedAbstract
{
+ /**
+ * @var Feed_Aggregate
+ */
+ protected static $object;
+ protected static $feeds;
+ protected static $title = 'Feed test';
+ protected static $subtitle = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?';
- /**
- * @var Feed_Aggregate
- */
- protected static $object;
- protected static $feeds;
- protected static $title = 'Feed test';
- protected static $subtitle = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?';
+ public static function setUpBeforeClass()
+ {
+ parent::setUpBeforeClass();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $auth = new Session_Authentication_None(self::$user);
+ $appbox->get_session()->authenticate($auth);
+ $objects[] = Feed_Adapter::create($appbox, self::$user, self::$title, self::$subtitle);
+ $objects[] = Feed_Adapter::create($appbox, self::$user, self::$title, self::$subtitle);
- public static function setUpBeforeClass()
- {
- parent::setUpBeforeClass();
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $auth = new Session_Authentication_None(self::$user);
- $appbox->get_session()->authenticate($auth);
- $objects[] = Feed_Adapter::create($appbox, self::$user, self::$title, self::$subtitle);
- $objects[] = Feed_Adapter::create($appbox, self::$user, self::$title, self::$subtitle);
+ self::$feeds = $objects;
+ self::$object = new Feed_Aggregate($appbox, self::$feeds);
+ }
- self::$feeds = $objects;
- self::$object = new Feed_Aggregate($appbox, self::$feeds);
- }
+ public static function tearDownAfterClass()
+ {
+ foreach (self::$feeds as $feed) {
+ $feed->delete();
+ }
+ parent::tearDownAfterClass();
+ }
- public static function tearDownAfterClass()
- {
- foreach (self::$feeds as $feed)
- $feed->delete();
- parent::tearDownAfterClass();
- }
+ public function testGet_icon_url()
+ {
+ $this->assertEquals('/skins/icons/rss32.gif', self::$object->get_icon_url());
+ }
- public function testGet_icon_url()
- {
- $this->assertEquals('/skins/icons/rss32.gif', self::$object->get_icon_url());
- }
+ public function testIs_aggregated()
+ {
+ $this->assertTrue(self::$object->is_aggregated());
+ }
- public function testIs_aggregated()
- {
- $this->assertTrue(self::$object->is_aggregated());
- }
+ 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_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_count_total_entries()
+ {
+ $this->assertEquals(0, self::$object->get_count_total_entries());
+ }
- public function testGet_count_total_entries()
- {
- $this->assertEquals(0, self::$object->get_count_total_entries());
- }
+ public function testGet_homepage_link()
+ {
+ $registry = registry::get_instance();
+ $link = self::$object->get_homepage_link($registry, Feed_Adapter::FORMAT_ATOM);
+ $this->assertInstanceOf('Feed_Link', $link);
+ $this->assertEquals($registry->get('GV_ServerName') . 'feeds/aggregated/atom/', $link->get_href());
+ }
- public function testGet_homepage_link()
- {
- $registry = registry::get_instance();
- $link = self::$object->get_homepage_link($registry, Feed_Adapter::FORMAT_ATOM);
- $this->assertInstanceOf('Feed_Link', $link);
- $this->assertEquals($registry->get('GV_ServerName') . 'feeds/aggregated/atom/', $link->get_href());
- }
+ public function testGet_user_link()
+ {
+ $registry = registry::get_instance();
- public function testGet_user_link()
- {
- $registry = registry::get_instance();
+ $link = self::$object->get_user_link($registry, self::$user, Feed_Adapter::FORMAT_ATOM);
+ $supposed = '/feeds\/userfeed\/aggregated\/([a-zA-Z0-9]{12})\/atom\//';
- $link = self::$object->get_user_link($registry, self::$user, Feed_Adapter::FORMAT_ATOM);
- $supposed = '/feeds\/userfeed\/aggregated\/([a-zA-Z0-9]{12})\/atom\//';
+ $atom = $link->get_href();
- $atom = $link->get_href();
+ $this->assertRegExp($supposed, str_replace($registry->get('GV_ServerName'), '', $atom));
+ $this->assertEquals($atom, self::$object->get_user_link($registry, self::$user, Feed_Adapter::FORMAT_ATOM)->get_href());
+ $this->assertEquals($atom, self::$object->get_user_link($registry, self::$user, Feed_Adapter::FORMAT_ATOM)->get_href());
- $this->assertRegExp($supposed, str_replace($registry->get('GV_ServerName'), '', $atom));
- $this->assertEquals($atom, self::$object->get_user_link($registry, self::$user, Feed_Adapter::FORMAT_ATOM)->get_href());
- $this->assertEquals($atom, self::$object->get_user_link($registry, self::$user, Feed_Adapter::FORMAT_ATOM)->get_href());
+ $this->assertNotEquals($atom, self::$object->get_user_link($registry, self::$user, Feed_Adapter::FORMAT_ATOM, null, true)->get_href());
- $this->assertNotEquals($atom, self::$object->get_user_link($registry, self::$user, Feed_Adapter::FORMAT_ATOM, null, true)->get_href());
+ $link = self::$object->get_user_link($registry, self::$user, Feed_Adapter::FORMAT_RSS);
+ $supposed = '/feeds\/userfeed\/aggregated\/([a-zA-Z0-9]{12})\/rss\//';
+ $this->assertRegExp($supposed, str_replace($registry->get('GV_ServerName'), '', $link->get_href()));
+ }
- $link = self::$object->get_user_link($registry, self::$user, Feed_Adapter::FORMAT_RSS);
- $supposed = '/feeds\/userfeed\/aggregated\/([a-zA-Z0-9]{12})\/rss\//';
- $this->assertRegExp($supposed, str_replace($registry->get('GV_ServerName'), '', $link->get_href()));
- }
-
- 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());
- }
+ 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());
+ }
}
-
diff --git a/tests/Feed/Feed_CollectionTest.php b/tests/Feed/Feed_CollectionTest.php
index c4f73672aa..853ed9f168 100644
--- a/tests/Feed/Feed_CollectionTest.php
+++ b/tests/Feed/Feed_CollectionTest.php
@@ -4,70 +4,65 @@ require_once __DIR__ . '/../PhraseanetPHPUnitAuthenticatedAbstract.class.inc';
class Feed_CollectionTest extends PhraseanetPHPUnitAuthenticatedAbstract
{
+ /**
+ *
+ * @var Feed_Adapter
+ */
+ protected static $object;
+ protected static $title = 'Feed test';
+ protected static $subtitle = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?';
- /**
- *
- * @var Feed_Adapter
- */
- protected static $object;
- protected static $title = 'Feed test';
- protected static $subtitle = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?';
-
- public static function setUpBeforeClass()
- {
- parent::setUpBeforeClass();
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $auth = new Session_Authentication_None(self::$user);
- $appbox->get_session()->authenticate($auth);
- self::$object = Feed_Adapter::create($appbox, self::$user, self::$title, self::$subtitle);
- self::$object->set_public(true);
- }
-
- public static function tearDownAfterClass()
- {
- self::$object->delete();
- }
-
- public function testLoad_all()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $coll = Feed_Collection::load_all($appbox, self::$user);
-
- foreach ($coll->get_feeds() as $feed)
+ public static function setUpBeforeClass()
{
- $this->assertInstanceOf('Feed_Adapter', $feed);
+ parent::setUpBeforeClass();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $auth = new Session_Authentication_None(self::$user);
+ $appbox->get_session()->authenticate($auth);
+ self::$object = Feed_Adapter::create($appbox, self::$user, self::$title, self::$subtitle);
+ self::$object->set_public(true);
}
- }
- public function testGet_feeds()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $coll = Feed_Collection::load_public_feeds($appbox);
-
- foreach ($coll->get_feeds() as $feed)
+ public static function tearDownAfterClass()
{
- $this->assertInstanceOf('Feed_Adapter', $feed);
+ self::$object->delete();
+ parent::tearDownAfterClass();
}
- }
- public function testGet_aggregate()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $coll = Feed_Collection::load_public_feeds($appbox);
-
- $this->assertInstanceOf('Feed_Aggregate', $coll->get_aggregate());
- }
-
- public function testLoad_public_feeds()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $coll = Feed_Collection::load_public_feeds($appbox);
-
- foreach ($coll->get_feeds() as $feed)
+ public function testLoad_all()
{
- $this->assertTrue($feed->is_public());
- }
- }
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $coll = Feed_Collection::load_all($appbox, self::$user);
+ foreach ($coll->get_feeds() as $feed) {
+ $this->assertInstanceOf('Feed_Adapter', $feed);
+ }
+ }
+
+ public function testGet_feeds()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $coll = Feed_Collection::load_public_feeds($appbox);
+
+ foreach ($coll->get_feeds() as $feed) {
+ $this->assertInstanceOf('Feed_Adapter', $feed);
+ }
+ }
+
+ public function testGet_aggregate()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $coll = Feed_Collection::load_public_feeds($appbox);
+
+ $this->assertInstanceOf('Feed_Aggregate', $coll->get_aggregate());
+ }
+
+ public function testLoad_public_feeds()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $coll = Feed_Collection::load_public_feeds($appbox);
+
+ foreach ($coll->get_feeds() as $feed) {
+ $this->assertTrue($feed->is_public());
+ }
+ }
}
-
diff --git a/tests/Feed/Feed_LinkTest.php b/tests/Feed/Feed_LinkTest.php
index 11bc83a184..8f8635f14c 100644
--- a/tests/Feed/Feed_LinkTest.php
+++ b/tests/Feed/Feed_LinkTest.php
@@ -4,33 +4,32 @@ require_once __DIR__ . '/../PhraseanetPHPUnitAbstract.class.inc';
class Feed_LinkTest extends PhraseanetPHPUnitAbstract
{
+ /**
+ * @var Feed_Link
+ */
+ protected $object;
+ protected $href = "http://www.google.fr/";
+ protected $title = "google";
+ protected $mime = "html/text";
- /**
- * @var Feed_Link
- */
- protected $object;
- protected $href = "http://www.google.fr/";
- protected $title = "google";
- protected $mime = "html/text";
+ public function setUp()
+ {
+ parent::setUp();
+ $this->object = new Feed_Link($this->href, $this->title, $this->mime);
+ }
- public function setUp()
- {
- $this->object = new Feed_Link($this->href, $this->title, $this->mime);
- }
+ public function testGet_mimetype()
+ {
+ $this->assertEquals($this->mime, $this->object->get_mimetype());
+ }
- public function testGet_mimetype()
- {
- $this->assertEquals($this->mime, $this->object->get_mimetype());
- }
-
- public function testGet_title()
- {
- $this->assertEquals($this->title, $this->object->get_title());
- }
-
- public function testGet_href()
- {
- $this->assertEquals($this->href, $this->object->get_href());
- }
+ public function testGet_title()
+ {
+ $this->assertEquals($this->title, $this->object->get_title());
+ }
+ public function testGet_href()
+ {
+ $this->assertEquals($this->href, $this->object->get_href());
+ }
}
diff --git a/tests/Feed/Publisher/Feed_Publisher_AdapterTest.php b/tests/Feed/Publisher/Feed_Publisher_AdapterTest.php
index 1759befea4..b43dcc628a 100644
--- a/tests/Feed/Publisher/Feed_Publisher_AdapterTest.php
+++ b/tests/Feed/Publisher/Feed_Publisher_AdapterTest.php
@@ -4,59 +4,57 @@ require_once __DIR__ . '/../../PhraseanetPHPUnitAuthenticatedAbstract.class.inc'
class Feed_Publisher_AdapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
{
+ /**
+ * @var Feed_Publisher_Adapter
+ */
+ protected static $object;
+ protected static $title = 'Feed test';
+ protected static $subtitle = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?';
- /**
- * @var Feed_Publisher_Adapter
- */
- protected static $object;
- protected static $title = 'Feed test';
- protected static $subtitle = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?';
- /**
- * @var Feed_Adapter
- */
- protected static $feed;
+ /**
+ * @var Feed_Adapter
+ */
+ protected static $feed;
- public static function setUpBeforeClass()
- {
- parent::setUpBeforeClass();
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $auth = new Session_Authentication_None(self::$user);
- $appbox->get_session()->authenticate($auth);
- self::$feed = Feed_Adapter::create($appbox, self::$user, self::$title, self::$subtitle);
- self::$object = array_pop(self::$feed->get_publishers());
- }
+ public static function setUpBeforeClass()
+ {
+ parent::setUpBeforeClass();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $auth = new Session_Authentication_None(self::$user);
+ $appbox->get_session()->authenticate($auth);
+ self::$feed = Feed_Adapter::create($appbox, self::$user, self::$title, self::$subtitle);
+ self::$object = array_pop(self::$feed->get_publishers());
+ }
- public static function tearDownAfterClass()
- {
- self::$feed->delete();
- parent::tearDownAfterClass();
- }
+ public static function tearDownAfterClass()
+ {
+ self::$feed->delete();
+ parent::tearDownAfterClass();
+ }
- public function testGet_user()
- {
- $this->assertInstanceOf('user_Adapter', self::$object->get_user());
- $this->assertEquals(self::$user->get_id(), self::$object->get_user()->get_id());
- }
+ public function testGet_user()
+ {
+ $this->assertInstanceOf('user_Adapter', self::$object->get_user());
+ $this->assertEquals(self::$user->get_id(), self::$object->get_user()->get_id());
+ }
- public function testIs_owner()
- {
- $this->assertTrue(self::$object->is_owner());
- }
+ public function testIs_owner()
+ {
+ $this->assertTrue(self::$object->is_owner());
+ }
- public function testGet_created_on()
- {
- $this->assertInstanceOf('DateTime', self::$object->get_created_on());
- }
+ public function testGet_created_on()
+ {
+ $this->assertInstanceOf('DateTime', self::$object->get_created_on());
+ }
- public function testGet_added_by()
- {
- $this->assertInstanceOf('User_Adapter', self::$object->get_added_by());
- }
-
- public function testGet_id()
- {
- $this->assertTrue(is_int(self::$object->get_id()));
- }
+ public function testGet_added_by()
+ {
+ $this->assertInstanceOf('User_Adapter', self::$object->get_added_by());
+ }
+ public function testGet_id()
+ {
+ $this->assertTrue(is_int(self::$object->get_id()));
+ }
}
-
diff --git a/tests/Feed/XML/Feed_XML_AtomTest.php b/tests/Feed/XML/Feed_XML_AtomTest.php
index d71073e937..f5cdf01e24 100644
--- a/tests/Feed/XML/Feed_XML_AtomTest.php
+++ b/tests/Feed/XML/Feed_XML_AtomTest.php
@@ -4,213 +4,208 @@ require_once __DIR__ . '/../../PhraseanetPHPUnitAbstract.class.inc';
class Feed_XML_AtomTest extends PhraseanetPHPUnitAbstract
{
+ /**
+ *
+ * @var Feed_XML_Atom
+ */
+ protected static $atom;
- /**
- *
- * @var Feed_XML_Atom
- */
- protected static $atom;
-
- public static function setUpBeforeClass()
- {
- parent::setUpBeforeClass();
- self::$atom = new Feed_XML_Atom();
- }
-
- public function testRender()
- {
- $sxe = simplexml_load_string(self::$atom->render());
- $this->assertInstanceOf('SimpleXMLElement', $sxe);
- }
-
- public function testSet_author_name()
- {
- self::$atom->set_author_name('boulbil');
- $sxe = simplexml_load_string(self::$atom->render());
- $this->assertInstanceOf('SimpleXMLElement', $sxe);
- $this->assertEquals('boulbil', (string) $sxe->author->name);
-
- self::$atom->set_author_name('boubi bouba');
- $sxe = simplexml_load_string(self::$atom->render());
- $this->assertInstanceOf('SimpleXMLElement', $sxe);
- $this->assertEquals('boubi bouba', (string) $sxe->author->name);
- }
-
- public function testSet_author_email()
- {
- self::$atom->set_author_email('bouba@example.net');
- $sxe = simplexml_load_string(self::$atom->render());
- $this->assertInstanceOf('SimpleXMLElement', $sxe);
- $this->assertEquals('bouba@example.net', (string) $sxe->author->email);
-
- self::$atom->set_author_email('email+test@example.org');
- $sxe = simplexml_load_string(self::$atom->render());
- $this->assertInstanceOf('SimpleXMLElement', $sxe);
- $this->assertEquals('email+test@example.org', (string) $sxe->author->email);
- }
-
- public function testSet_author_url()
- {
- self::$atom->set_author_url('http://example.net/');
- $sxe = simplexml_load_string(self::$atom->render());
- $this->assertInstanceOf('SimpleXMLElement', $sxe);
- $this->assertEquals('http://example.net/', (string) $sxe->author->uri);
- }
-
- public function testSet_title()
- {
- $title = 'Un joli titre';
- self::$atom->set_title($title);
- self::$atom->set_title($title);
-
- $xml = self::$atom->render();
- $sxe = simplexml_load_string($xml);
- $namespaces = $sxe->getDocNamespaces();
- $sxe->registerXPathNamespace('__empty_ns', $namespaces['']);
- $this->assertInstanceOf('SimpleXMLElement', $sxe);
- $obj = $sxe->xpath('/__empty_ns:feed/__empty_ns:title');
-
- $this->assertEquals(1, count($obj));
-
- $this->assertEquals($title, (string) $obj[0]);
- }
-
- public function testSet_updated_on()
- {
- $date_obj = new DateTime();
- self::$atom->set_updated_on($date_obj);
-
- $sxe = simplexml_load_string(self::$atom->render());
- $this->assertInstanceOf('SimpleXMLElement', $sxe);
- $this->assertEquals($date_obj->format(DATE_ATOM), (string) $sxe->updated);
- }
-
- public function testSet_subtitle()
- {
- $subtitle = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.';
- self::$atom->set_subtitle($subtitle);
- self::$atom->set_subtitle($subtitle);
-
- $xml = self::$atom->render();
- $sxe = simplexml_load_string($xml);
- $namespaces = $sxe->getDocNamespaces();
- $sxe->registerXPathNamespace('__empty_ns', $namespaces['']);
- $this->assertInstanceOf('SimpleXMLElement', $sxe);
- $obj = $sxe->xpath('/__empty_ns:feed/__empty_ns:subtitle');
-
- $this->assertEquals(1, count($obj));
-
- $this->assertEquals($subtitle, (string) $obj[0]);
- }
-
- public function testSet_link()
- {
- $href = 'http://www.example.org/?page=24';
- $current_page = new Feed_Link($href, 'example next page', 'application/atom+xml');
- self::$atom->set_link($current_page);
- self::$atom->set_link($current_page);
-
- $xml = self::$atom->render();
- $sxe = simplexml_load_string($xml);
- $namespaces = $sxe->getDocNamespaces();
- $sxe->registerXPathNamespace('__empty_ns', $namespaces['']);
- $this->assertInstanceOf('SimpleXMLElement', $sxe);
- $obj = $sxe->xpath('/__empty_ns:feed/__empty_ns:link[@rel="self"]');
-
- $this->assertEquals(1, count($obj));
- $found = false;
-
- foreach ($obj[0]->attributes() as $attr => $attr_value)
+ public static function setUpBeforeClass()
{
- if ($attr != 'href')
- continue;
- $found = true;
- $this->assertEquals($href, (string) $attr_value);
+ parent::setUpBeforeClass();
+ self::$atom = new Feed_XML_Atom();
}
- if (!$found)
- $this->fail();
- }
-
- public function testSet_next_page()
- {
- $href = 'http://www.example.org/?page=23';
- $next_page = new Feed_Link($href, 'example next page', 'application/atom+xml');
- self::$atom->set_next_page($next_page);
- self::$atom->set_next_page($next_page);
-
- $xml = self::$atom->render();
- $sxe = simplexml_load_string($xml);
- $namespaces = $sxe->getDocNamespaces();
- $sxe->registerXPathNamespace('__empty_ns', $namespaces['']);
- $this->assertInstanceOf('SimpleXMLElement', $sxe);
- $obj = $sxe->xpath('/__empty_ns:feed/__empty_ns:link[@rel="next"]');
-
- $this->assertEquals(1, count($obj));
- $found = false;
-
- foreach ($obj[0]->attributes() as $attr => $attr_value)
+ public function testRender()
{
- if ($attr != 'href')
- continue;
- $found = true;
- $this->assertEquals($href, (string) $attr_value);
+ $sxe = simplexml_load_string(self::$atom->render());
+ $this->assertInstanceOf('SimpleXMLElement', $sxe);
}
- if (!$found)
- $this->fail();
- }
-
- public function testSet_previous_page()
- {
- $href = 'http://www.example.org/?page=25';
- $prev_page = new Feed_Link($href, 'example next page', 'application/atom+xml');
- self::$atom->set_previous_page($prev_page);
- self::$atom->set_previous_page($prev_page);
-
- $xml = self::$atom->render();
- $sxe = simplexml_load_string($xml);
- $namespaces = $sxe->getDocNamespaces();
- $sxe->registerXPathNamespace('__empty_ns', $namespaces['']);
- $this->assertInstanceOf('SimpleXMLElement', $sxe);
- $obj = $sxe->xpath('/__empty_ns:feed/__empty_ns:link[@rel="previous"]');
-
- $this->assertEquals(1, count($obj));
- $found = false;
-
- foreach ($obj[0]->attributes() as $attr => $attr_value)
+ public function testSet_author_name()
{
- if ($attr != 'href')
- continue;
- $found = true;
- $this->assertEquals($href, (string) $attr_value);
+ self::$atom->set_author_name('boulbil');
+ $sxe = simplexml_load_string(self::$atom->render());
+ $this->assertInstanceOf('SimpleXMLElement', $sxe);
+ $this->assertEquals('boulbil', (string) $sxe->author->name);
+
+ self::$atom->set_author_name('boubi bouba');
+ $sxe = simplexml_load_string(self::$atom->render());
+ $this->assertInstanceOf('SimpleXMLElement', $sxe);
+ $this->assertEquals('boubi bouba', (string) $sxe->author->name);
}
- if (!$found)
- $this->fail();
- }
+ public function testSet_author_email()
+ {
+ self::$atom->set_author_email('bouba@example.net');
+ $sxe = simplexml_load_string(self::$atom->render());
+ $this->assertInstanceOf('SimpleXMLElement', $sxe);
+ $this->assertEquals('bouba@example.net', (string) $sxe->author->email);
- public function testSet_generator()
- {
- $generator = 'Arnold Schwarzenegger';
- self::$atom->set_generator($generator);
- self::$atom->set_generator($generator);
+ self::$atom->set_author_email('email+test@example.org');
+ $sxe = simplexml_load_string(self::$atom->render());
+ $this->assertInstanceOf('SimpleXMLElement', $sxe);
+ $this->assertEquals('email+test@example.org', (string) $sxe->author->email);
+ }
- $xml = self::$atom->render();
- $sxe = simplexml_load_string($xml);
- $namespaces = $sxe->getDocNamespaces();
- $sxe->registerXPathNamespace('__empty_ns', $namespaces['']);
- $this->assertInstanceOf('SimpleXMLElement', $sxe);
- $obj = $sxe->xpath('/__empty_ns:feed/__empty_ns:generator');
+ public function testSet_author_url()
+ {
+ self::$atom->set_author_url('http://example.net/');
+ $sxe = simplexml_load_string(self::$atom->render());
+ $this->assertInstanceOf('SimpleXMLElement', $sxe);
+ $this->assertEquals('http://example.net/', (string) $sxe->author->uri);
+ }
- $this->assertEquals(1, count($obj));
+ public function testSet_title()
+ {
+ $title = 'Un joli titre';
+ self::$atom->set_title($title);
+ self::$atom->set_title($title);
- $this->assertEquals($generator, (string) $obj[0]);
- }
+ $xml = self::$atom->render();
+ $sxe = simplexml_load_string($xml);
+ $namespaces = $sxe->getDocNamespaces();
+ $sxe->registerXPathNamespace('__empty_ns', $namespaces['']);
+ $this->assertInstanceOf('SimpleXMLElement', $sxe);
+ $obj = $sxe->xpath('/__empty_ns:feed/__empty_ns:title');
- public function testGet_mimetype()
- {
- $this->assertEquals('application/atom+xml', self::$atom->get_mimetype());
- }
+ $this->assertEquals(1, count($obj));
+ $this->assertEquals($title, (string) $obj[0]);
+ }
+
+ public function testSet_updated_on()
+ {
+ $date_obj = new DateTime();
+ self::$atom->set_updated_on($date_obj);
+
+ $sxe = simplexml_load_string(self::$atom->render());
+ $this->assertInstanceOf('SimpleXMLElement', $sxe);
+ $this->assertEquals($date_obj->format(DATE_ATOM), (string) $sxe->updated);
+ }
+
+ public function testSet_subtitle()
+ {
+ $subtitle = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.';
+ self::$atom->set_subtitle($subtitle);
+ self::$atom->set_subtitle($subtitle);
+
+ $xml = self::$atom->render();
+ $sxe = simplexml_load_string($xml);
+ $namespaces = $sxe->getDocNamespaces();
+ $sxe->registerXPathNamespace('__empty_ns', $namespaces['']);
+ $this->assertInstanceOf('SimpleXMLElement', $sxe);
+ $obj = $sxe->xpath('/__empty_ns:feed/__empty_ns:subtitle');
+
+ $this->assertEquals(1, count($obj));
+
+ $this->assertEquals($subtitle, (string) $obj[0]);
+ }
+
+ public function testSet_link()
+ {
+ $href = 'http://www.example.org/?page=24';
+ $current_page = new Feed_Link($href, 'example next page', 'application/atom+xml');
+ self::$atom->set_link($current_page);
+ self::$atom->set_link($current_page);
+
+ $xml = self::$atom->render();
+ $sxe = simplexml_load_string($xml);
+ $namespaces = $sxe->getDocNamespaces();
+ $sxe->registerXPathNamespace('__empty_ns', $namespaces['']);
+ $this->assertInstanceOf('SimpleXMLElement', $sxe);
+ $obj = $sxe->xpath('/__empty_ns:feed/__empty_ns:link[@rel="self"]');
+
+ $this->assertEquals(1, count($obj));
+ $found = false;
+
+ foreach ($obj[0]->attributes() as $attr => $attr_value) {
+ if ($attr != 'href')
+ continue;
+ $found = true;
+ $this->assertEquals($href, (string) $attr_value);
+ }
+
+ if ( ! $found)
+ $this->fail();
+ }
+
+ public function testSet_next_page()
+ {
+ $href = 'http://www.example.org/?page=23';
+ $next_page = new Feed_Link($href, 'example next page', 'application/atom+xml');
+ self::$atom->set_next_page($next_page);
+ self::$atom->set_next_page($next_page);
+
+ $xml = self::$atom->render();
+ $sxe = simplexml_load_string($xml);
+ $namespaces = $sxe->getDocNamespaces();
+ $sxe->registerXPathNamespace('__empty_ns', $namespaces['']);
+ $this->assertInstanceOf('SimpleXMLElement', $sxe);
+ $obj = $sxe->xpath('/__empty_ns:feed/__empty_ns:link[@rel="next"]');
+
+ $this->assertEquals(1, count($obj));
+ $found = false;
+
+ foreach ($obj[0]->attributes() as $attr => $attr_value) {
+ if ($attr != 'href')
+ continue;
+ $found = true;
+ $this->assertEquals($href, (string) $attr_value);
+ }
+
+ if ( ! $found)
+ $this->fail();
+ }
+
+ public function testSet_previous_page()
+ {
+ $href = 'http://www.example.org/?page=25';
+ $prev_page = new Feed_Link($href, 'example next page', 'application/atom+xml');
+ self::$atom->set_previous_page($prev_page);
+ self::$atom->set_previous_page($prev_page);
+
+ $xml = self::$atom->render();
+ $sxe = simplexml_load_string($xml);
+ $namespaces = $sxe->getDocNamespaces();
+ $sxe->registerXPathNamespace('__empty_ns', $namespaces['']);
+ $this->assertInstanceOf('SimpleXMLElement', $sxe);
+ $obj = $sxe->xpath('/__empty_ns:feed/__empty_ns:link[@rel="previous"]');
+
+ $this->assertEquals(1, count($obj));
+ $found = false;
+
+ foreach ($obj[0]->attributes() as $attr => $attr_value) {
+ if ($attr != 'href')
+ continue;
+ $found = true;
+ $this->assertEquals($href, (string) $attr_value);
+ }
+
+ if ( ! $found)
+ $this->fail();
+ }
+
+ public function testSet_generator()
+ {
+ $generator = 'Arnold Schwarzenegger';
+ self::$atom->set_generator($generator);
+ self::$atom->set_generator($generator);
+
+ $xml = self::$atom->render();
+ $sxe = simplexml_load_string($xml);
+ $namespaces = $sxe->getDocNamespaces();
+ $sxe->registerXPathNamespace('__empty_ns', $namespaces['']);
+ $this->assertInstanceOf('SimpleXMLElement', $sxe);
+ $obj = $sxe->xpath('/__empty_ns:feed/__empty_ns:generator');
+
+ $this->assertEquals(1, count($obj));
+
+ $this->assertEquals($generator, (string) $obj[0]);
+ }
+
+ public function testGet_mimetype()
+ {
+ $this->assertEquals('application/atom+xml', self::$atom->get_mimetype());
+ }
}
diff --git a/tests/Feed/XML/Feed_XML_RSSTest.php b/tests/Feed/XML/Feed_XML_RSSTest.php
index 82cdb2f3f4..4624427fad 100644
--- a/tests/Feed/XML/Feed_XML_RSSTest.php
+++ b/tests/Feed/XML/Feed_XML_RSSTest.php
@@ -4,200 +4,190 @@ require_once __DIR__ . '/../../PhraseanetPHPUnitAbstract.class.inc';
class Feed_XML_RSSTest extends PhraseanetPHPUnitAbstract
{
+ /**
+ * @var Feed_XML_RSS
+ */
+ protected static $rss;
- /**
- * @var Feed_XML_RSS
- */
- protected static $rss;
-
- public function setUp()
- {
- parent::setUp();
- self::$rss = new Feed_XML_RSS();
- }
-
- public function testSet_language()
- {
- $language = 'fr-fr';
- self::$rss->set_language($language);
-
- $xml = self::$rss->render();
- $sxe = simplexml_load_string($xml);
- $this->assertInstanceOf('SimpleXMLElement', $sxe);
- $this->assertEquals($language, (string) $sxe->channel->language);
- }
-
- public function testSet_copyright()
- {
- $copyright = '2006-2014 No copyright';
- self::$rss->set_copyright($copyright);
-
- $xml = self::$rss->render();
- $sxe = simplexml_load_string($xml);
- $this->assertInstanceOf('SimpleXMLElement', $sxe);
- $this->assertEquals($copyright, (string) $sxe->channel->copyright);
- }
-
- public function testSet_managingEditor()
- {
- $email = 'manager@example.org';
- self::$rss->set_managingEditor($email);
-
- $xml = self::$rss->render();
- $sxe = simplexml_load_string($xml);
- $this->assertInstanceOf('SimpleXMLElement', $sxe);
- $this->assertEquals($email, (string) $sxe->channel->managingEditor);
- }
-
- public function testSet_webMaster()
- {
- $email = 'webmaster@example.org';
- self::$rss->set_webMaster($email);
-
- $xml = self::$rss->render();
- $sxe = simplexml_load_string($xml);
- $this->assertInstanceOf('SimpleXMLElement', $sxe);
- $this->assertEquals($email, (string) $sxe->channel->webMaster);
- }
-
- public function testSet_lastBuildDate()
- {
- $last_build = new DateTime('-2 hours');
- self::$rss->set_lastBuildDate($last_build);
-
-
- $xml = self::$rss->render();
- $sxe = simplexml_load_string($xml);
- $this->assertInstanceOf('SimpleXMLElement', $sxe);
- $this->assertEquals($last_build->format(DATE_RFC2822), (string) $sxe->channel->lastBuildDate);
- }
-
- public function testSet_category()
- {
- $categories = array('banana' => 'banana', 'prout' => 'prout');
- foreach ($categories as $category)
+ public function setUp()
{
- self::$rss->set_category($category);
+ parent::setUp();
+ self::$rss = new Feed_XML_RSS();
}
- $xml = self::$rss->render();
- $sxe = simplexml_load_string($xml);
- $this->assertInstanceOf('SimpleXMLElement', $sxe);
-
- $cat_objs = $sxe->xpath('//channel/category');
- $this->assertEquals(count($cat_objs), count($categories));
-
- foreach ($cat_objs as $cat_obj)
+ public function testSet_language()
{
- $str_cat = (string) $cat_obj;
- $this->assertArrayHasKey($str_cat, $categories);
- unset($categories[$str_cat]);
+ $language = 'fr-fr';
+ self::$rss->set_language($language);
+
+ $xml = self::$rss->render();
+ $sxe = simplexml_load_string($xml);
+ $this->assertInstanceOf('SimpleXMLElement', $sxe);
+ $this->assertEquals($language, (string) $sxe->channel->language);
}
- $this->assertTrue((count($categories) === 0));
- }
-
- public function testSet_docs()
- {
- $xml = self::$rss->render();
- $sxe = simplexml_load_string($xml);
- $this->assertInstanceOf('SimpleXMLElement', $sxe);
-
- $this->assertEquals('http://blogs.law.harvard.edu/tech/rss', (string) $sxe->channel->docs);
-
- self::$rss->set_docs('http://www.example.org');
- $xml = self::$rss->render();
- $sxe = simplexml_load_string($xml);
- $this->assertInstanceOf('SimpleXMLElement', $sxe);
-
- $this->assertEquals('http://www.example.org', (string) $sxe->channel->docs);
- }
-
- public function testSet_ttl()
- {
- self::$rss->set_ttl(240);
- $xml = self::$rss->render();
- $sxe = simplexml_load_string($xml);
- $this->assertInstanceOf('SimpleXMLElement', $sxe);
-
- $this->assertEquals(240, (string) $sxe->channel->ttl);
- }
-
- public function testSet_image()
- {
- $link = 'http://www.example.org';
- $title = 'Un beau titre';
- $url = 'http://www.example.org/image.jpg';
- $image = new Feed_XML_RSS_Image($url, $title, $link);
- $width = 42;
- $height = 30;
- $description = 'KIKOO';
- $image->set_width($width);
- $image->set_height($height);
- $image->set_description($description);
-
-
- self::$rss->set_image($image);
- $xml = self::$rss->render();
- $sxe = simplexml_load_string($xml);
- $this->assertInstanceOf('SimpleXMLElement', $sxe);
-
- $this->assertEquals($title, (string) $sxe->channel->image->title);
- $this->assertEquals($link, (string) $sxe->channel->image->link);
- $this->assertEquals($url, (string) $sxe->channel->image->url);
- $this->assertEquals($height, (string) $sxe->channel->image->height);
- $this->assertEquals($width, (string) $sxe->channel->image->width);
- $this->assertEquals($description, (string) $sxe->channel->image->description);
-
- }
-
- public function testSet_skipHours()
- {
- $hours = array('4' => '4', '8' => '8', '12' => '12');
- foreach ($hours as $hour)
+ public function testSet_copyright()
{
- self::$rss->set_skipHour($hour);
- }
- $xml = self::$rss->render();
- $sxe = simplexml_load_string($xml);
- $this->assertInstanceOf('SimpleXMLElement', $sxe);
+ $copyright = '2006-2014 No copyright';
+ self::$rss->set_copyright($copyright);
- foreach ($sxe->channel->skipHours->hour as $sx_hour)
- {
- $sx_hour = (string) $sx_hour;
- $this->assertArrayHasKey($sx_hour, $hours);
- unset($hours[$sx_hour]);
+ $xml = self::$rss->render();
+ $sxe = simplexml_load_string($xml);
+ $this->assertInstanceOf('SimpleXMLElement', $sxe);
+ $this->assertEquals($copyright, (string) $sxe->channel->copyright);
}
- $this->assertTrue(empty($hours));
- }
-
- public function testSet_skipDays()
- {
- $days = array('sunday' => 'sunday', 'saturday' => 'saturday', 'monday' => 'monday');
- foreach ($days as $day)
+ public function testSet_managingEditor()
{
- self::$rss->set_skipDays($day);
- }
- $xml = self::$rss->render();
- $sxe = simplexml_load_string($xml);
- $this->assertInstanceOf('SimpleXMLElement', $sxe);
+ $email = 'manager@example.org';
+ self::$rss->set_managingEditor($email);
- foreach ($sxe->channel->skipDays->day as $sx_day)
- {
- $sx_day = (string) $sx_day;
- $this->assertArrayHasKey($sx_day, $days);
- unset($days[$sx_day]);
+ $xml = self::$rss->render();
+ $sxe = simplexml_load_string($xml);
+ $this->assertInstanceOf('SimpleXMLElement', $sxe);
+ $this->assertEquals($email, (string) $sxe->channel->managingEditor);
}
- $this->assertTrue(empty($days));
- }
+ public function testSet_webMaster()
+ {
+ $email = 'webmaster@example.org';
+ self::$rss->set_webMaster($email);
- public function testRender()
- {
- $sxe = simplexml_load_string(self::$rss->render());
- $this->assertInstanceOf('SimpleXMLElement', $sxe);
- }
+ $xml = self::$rss->render();
+ $sxe = simplexml_load_string($xml);
+ $this->assertInstanceOf('SimpleXMLElement', $sxe);
+ $this->assertEquals($email, (string) $sxe->channel->webMaster);
+ }
+ public function testSet_lastBuildDate()
+ {
+ $last_build = new DateTime('-2 hours');
+ self::$rss->set_lastBuildDate($last_build);
+
+
+ $xml = self::$rss->render();
+ $sxe = simplexml_load_string($xml);
+ $this->assertInstanceOf('SimpleXMLElement', $sxe);
+ $this->assertEquals($last_build->format(DATE_RFC2822), (string) $sxe->channel->lastBuildDate);
+ }
+
+ public function testSet_category()
+ {
+ $categories = array('banana' => 'banana', 'prout' => 'prout');
+ foreach ($categories as $category) {
+ self::$rss->set_category($category);
+ }
+
+ $xml = self::$rss->render();
+ $sxe = simplexml_load_string($xml);
+ $this->assertInstanceOf('SimpleXMLElement', $sxe);
+
+ $cat_objs = $sxe->xpath('//channel/category');
+ $this->assertEquals(count($cat_objs), count($categories));
+
+ foreach ($cat_objs as $cat_obj) {
+ $str_cat = (string) $cat_obj;
+ $this->assertArrayHasKey($str_cat, $categories);
+ unset($categories[$str_cat]);
+ }
+
+ $this->assertTrue((count($categories) === 0));
+ }
+
+ public function testSet_docs()
+ {
+ $xml = self::$rss->render();
+ $sxe = simplexml_load_string($xml);
+ $this->assertInstanceOf('SimpleXMLElement', $sxe);
+
+ $this->assertEquals('http://blogs.law.harvard.edu/tech/rss', (string) $sxe->channel->docs);
+
+ self::$rss->set_docs('http://www.example.org');
+ $xml = self::$rss->render();
+ $sxe = simplexml_load_string($xml);
+ $this->assertInstanceOf('SimpleXMLElement', $sxe);
+
+ $this->assertEquals('http://www.example.org', (string) $sxe->channel->docs);
+ }
+
+ public function testSet_ttl()
+ {
+ self::$rss->set_ttl(240);
+ $xml = self::$rss->render();
+ $sxe = simplexml_load_string($xml);
+ $this->assertInstanceOf('SimpleXMLElement', $sxe);
+
+ $this->assertEquals(240, (string) $sxe->channel->ttl);
+ }
+
+ public function testSet_image()
+ {
+ $link = 'http://www.example.org';
+ $title = 'Un beau titre';
+ $url = 'http://www.example.org/image.jpg';
+ $image = new Feed_XML_RSS_Image($url, $title, $link);
+ $width = 42;
+ $height = 30;
+ $description = 'KIKOO';
+ $image->set_width($width);
+ $image->set_height($height);
+ $image->set_description($description);
+
+
+ self::$rss->set_image($image);
+ $xml = self::$rss->render();
+ $sxe = simplexml_load_string($xml);
+ $this->assertInstanceOf('SimpleXMLElement', $sxe);
+
+ $this->assertEquals($title, (string) $sxe->channel->image->title);
+ $this->assertEquals($link, (string) $sxe->channel->image->link);
+ $this->assertEquals($url, (string) $sxe->channel->image->url);
+ $this->assertEquals($height, (string) $sxe->channel->image->height);
+ $this->assertEquals($width, (string) $sxe->channel->image->width);
+ $this->assertEquals($description, (string) $sxe->channel->image->description);
+ }
+
+ public function testSet_skipHours()
+ {
+ $hours = array('4' => '4', '8' => '8', '12' => '12');
+ foreach ($hours as $hour) {
+ self::$rss->set_skipHour($hour);
+ }
+ $xml = self::$rss->render();
+ $sxe = simplexml_load_string($xml);
+ $this->assertInstanceOf('SimpleXMLElement', $sxe);
+
+ foreach ($sxe->channel->skipHours->hour as $sx_hour) {
+ $sx_hour = (string) $sx_hour;
+ $this->assertArrayHasKey($sx_hour, $hours);
+ unset($hours[$sx_hour]);
+ }
+
+ $this->assertTrue(empty($hours));
+ }
+
+ public function testSet_skipDays()
+ {
+ $days = array('sunday' => 'sunday', 'saturday' => 'saturday', 'monday' => 'monday');
+ foreach ($days as $day) {
+ self::$rss->set_skipDays($day);
+ }
+ $xml = self::$rss->render();
+ $sxe = simplexml_load_string($xml);
+ $this->assertInstanceOf('SimpleXMLElement', $sxe);
+
+ foreach ($sxe->channel->skipDays->day as $sx_day) {
+ $sx_day = (string) $sx_day;
+ $this->assertArrayHasKey($sx_day, $days);
+ unset($days[$sx_day]);
+ }
+
+ $this->assertTrue(empty($days));
+ }
+
+ public function testRender()
+ {
+ $sxe = simplexml_load_string(self::$rss->render());
+ $this->assertInstanceOf('SimpleXMLElement', $sxe);
+ }
}
-
diff --git a/tests/Feed/XML/RSS/Feed_XML_RSS_ImageTest.php b/tests/Feed/XML/RSS/Feed_XML_RSS_ImageTest.php
index b991338031..43ae6b3edc 100644
--- a/tests/Feed/XML/RSS/Feed_XML_RSS_ImageTest.php
+++ b/tests/Feed/XML/RSS/Feed_XML_RSS_ImageTest.php
@@ -4,84 +4,80 @@ require_once __DIR__ . '/../../../PhraseanetPHPUnitAbstract.class.inc';
class Feed_XML_RSS_ImageTest extends PhraseanetPHPUnitAbstract
{
+ /**
+ * @var Feed_XML_RSS_Image
+ */
+ protected $object;
+ protected $url;
+ protected $title;
+ protected $link;
+ protected $description;
+ protected $width;
+ protected $height;
- /**
- * @var Feed_XML_RSS_Image
- */
- protected $object;
- protected $url;
- protected $title;
- protected $link;
- protected $description;
- protected $width;
- protected $height;
+ public function setUp()
+ {
+ parent::setUp();
+ $this->link = 'http://www.example.org';
+ $this->title = 'Un beau titre';
+ $this->url = 'http://www.example.org/image.jpg';
+ $this->width = 42;
+ $this->height = 30;
+ $this->description = 'KIKOO';
+ $this->object = new Feed_XML_RSS_Image($this->url, $this->title, $this->link);
+ $this->object->set_width($this->width);
+ $this->object->set_height($this->height);
+ $this->object->set_description($this->description);
+ }
- public function setUp()
- {
- parent::setUp();
- $this->link = 'http://www.example.org';
- $this->title = 'Un beau titre';
- $this->url = 'http://www.example.org/image.jpg';
- $this->width = 42;
- $this->height = 30;
- $this->description = 'KIKOO';
- $this->object = new Feed_XML_RSS_Image($this->url, $this->title, $this->link);
- $this->object->set_width($this->width);
- $this->object->set_height($this->height);
- $this->object->set_description($this->description);
+ public function testGet_url()
+ {
+ $this->assertEquals($this->url, $this->object->get_url());
+ }
- }
+ public function testGet_title()
+ {
+ $this->assertEquals($this->title, $this->object->get_title());
+ }
- public function testGet_url()
- {
- $this->assertEquals($this->url, $this->object->get_url());
- }
+ public function testGet_link()
+ {
+ $this->assertEquals($this->link, $this->object->get_link());
+ }
- public function testGet_title()
- {
- $this->assertEquals($this->title, $this->object->get_title());
- }
+ public function testGet_description()
+ {
+ $this->assertEquals($this->description, $this->object->get_description());
+ }
- public function testGet_link()
- {
- $this->assertEquals($this->link, $this->object->get_link());
- }
+ public function testGet_height()
+ {
+ $this->assertEquals($this->height, $this->object->get_height());
+ }
- public function testGet_description()
- {
- $this->assertEquals($this->description, $this->object->get_description());
- }
+ public function testGet_width()
+ {
+ $this->assertEquals($this->width, $this->object->get_width());
+ }
- public function testGet_height()
- {
- $this->assertEquals($this->height, $this->object->get_height());
- }
+ public function testSet_description()
+ {
+ $new_desc = 'une nouvelle';
+ $this->object->set_description($new_desc);
+ $this->assertEquals($new_desc, $this->object->get_description());
+ }
- public function testGet_width()
- {
- $this->assertEquals($this->width, $this->object->get_width());
- }
-
- public function testSet_description()
- {
- $new_desc = 'une nouvelle';
- $this->object->set_description($new_desc);
- $this->assertEquals($new_desc, $this->object->get_description());
- }
-
- public function testSet_height()
- {
- $new_height = 27;
- $this->object->set_height($new_height);
- $this->assertEquals($new_height, $this->object->get_height());
- }
-
- public function testSet_width()
- {
- $new_width = 14;
- $this->object->set_width($new_width);
- $this->assertEquals($new_width, $this->object->get_width());
- }
+ public function testSet_height()
+ {
+ $new_height = 27;
+ $this->object->set_height($new_height);
+ $this->assertEquals($new_height, $this->object->get_height());
+ }
+ public function testSet_width()
+ {
+ $new_width = 14;
+ $this->object->set_width($new_width);
+ $this->assertEquals($new_width, $this->object->get_width());
+ }
}
-
diff --git a/tests/FeedValidator.inc b/tests/FeedValidator.inc
index 04a371dd88..d70731ec66 100644
--- a/tests/FeedValidator.inc
+++ b/tests/FeedValidator.inc
@@ -14,13 +14,11 @@ class W3CFeedValidatorException extends Exception
*/
abstract class W3CFeedValidator
{
-
- const VALIDATOR_ENDPOINT = "http://validator.w3.org/feed/check.cgi";
- const OUTPOUT = "soap12";
+ const VALIDATOR_ENDPOINT = "http://validator.w3.org/feed/check.cgi";
+ const OUTPOUT = "soap12";
const TIME_BETWEEN_REQUEST = 2;
public abstract function validate();
-
}
/**
@@ -29,7 +27,6 @@ abstract class W3CFeedValidator
*/
class W3CFeedUrlValidator extends W3CFeedValidator
{
-
/**
* The URL of the document to validate
* @var string
@@ -60,9 +57,8 @@ class W3CFeedUrlValidator extends W3CFeedValidator
{
$url_validator = sprintf("%s?url=%s&output=%s", self::VALIDATOR_ENDPOINT, $this->url, self::OUTPOUT);
sleep(self::TIME_BETWEEN_REQUEST);
- $response = @file_get_contents($url_validator);
- if ( ! $response)
- {
+ $response = @file_get_contents($url_validator);
+ if ( ! $response) {
throw new W3CFeedValidatorException("Unable to request W3C API");
}
@@ -78,7 +74,6 @@ class W3CFeedUrlValidator extends W3CFeedValidator
{
return filter_var($url, FILTER_VALIDATE_URL);
}
-
}
/**
@@ -113,7 +108,6 @@ class W3CFeedUrlValidator extends W3CFeedValidator
*/
class W3CFeedRawValidator extends W3CFeedValidator
{
-
/**
* The source of the document to validate
* @var string
@@ -139,26 +133,24 @@ class W3CFeedRawValidator extends W3CFeedValidator
public function validate()
{
$context = stream_context_create(array(
- 'http' => array(
- 'method' => 'POST',
- 'header' => 'Content-type: application/x-www-form-urlencoded',
- 'content' => http_build_query(array(
- 'rawdata' => $this->rawData,
- 'manual' => 1,
- 'output' => self::OUTPOUT)),
- 'timeout' => 5,
- ),
- ));
+ 'http' => array(
+ 'method' => 'POST',
+ 'header' => 'Content-type: application/x-www-form-urlencoded',
+ 'content' => http_build_query(array(
+ 'rawdata' => $this->rawData,
+ 'manual' => 1,
+ 'output' => self::OUTPOUT)),
+ 'timeout' => 5,
+ ),
+ ));
sleep(self::TIME_BETWEEN_REQUEST);
$response = @file_get_contents(self::VALIDATOR_ENDPOINT, false, $context);
- if ( ! $response)
- {
+ if ( ! $response) {
throw new W3CFeedValidatorException("Unable to request W3C API");
}
return new W3CFeedValidatorResponse($response);
}
-
}
/**
@@ -166,7 +158,6 @@ class W3CFeedRawValidator extends W3CFeedValidator
*/
class W3CFeedValidatorResponse
{
-
/**
* XML W3C response
* @var string
@@ -192,8 +183,7 @@ class W3CFeedValidatorResponse
public function __construct($xml)
{
$this->DOMDocument = new DOMDocument();
- if ( ! $this->DOMDocument->loadXML($xml))
- {
+ if ( ! $this->DOMDocument->loadXML($xml)) {
throw new W3CFeedValidatorException("Unable to parse XML");
}
$this->DOMXpath = new DOMXPath($this->DOMDocument);
@@ -206,11 +196,9 @@ class W3CFeedValidatorResponse
public function __toString()
{
$string = "";
- foreach ($this->getErrors() as $error)
- {
+ foreach ($this->getErrors() as $error) {
$string .= "\nERROR\n";
- foreach ($error as $name => $detail)
- {
+ foreach ($error as $name => $detail) {
$string .= $name . "=>" . $detail . "\n";
}
}
@@ -286,12 +274,10 @@ class W3CFeedValidatorResponse
public function getWarnings()
{
$warnings = array();
- $xPathQuery = "/env:Envelope/env:Body/m:feedvalidationresponse/m:warnings/m:warninglist/*";
+ $xPathQuery = "/env:Envelope/env:Body/m:feedvalidationresponse/m:warnings/m:warninglist/*";
$warningList = $this->DOMXpath->query($xPathQuery);
- if ($warningList->length > 0)
- {
- foreach ($warningList as $warning)
- {
+ if ($warningList->length > 0) {
+ foreach ($warningList as $warning) {
$warnings[] = $this->domNodeToArray($warning);
}
}
@@ -307,11 +293,9 @@ class W3CFeedValidatorResponse
{
$errors = array();
$xPathQuery = "/env:Envelope/env:Body/m:feedvalidationresponse/m:errors/m:errorlist/*";
- $errorList = $this->DOMXpath->query($xPathQuery);
- if ($errorList->length > 0)
- {
- foreach ($errorList as $error)
- {
+ $errorList = $this->DOMXpath->query($xPathQuery);
+ if ($errorList->length > 0) {
+ foreach ($errorList as $error) {
$errors[] = $this->domNodeToArray($error);
}
}
@@ -334,36 +318,26 @@ class W3CFeedValidatorResponse
{
$ret = '';
- if ($node->hasChildNodes())
- {
- if ($node->firstChild === $node->lastChild && $node->firstChild->nodeType === XML_TEXT_NODE)
- {
+ if ($node->hasChildNodes()) {
+ if ($node->firstChild === $node->lastChild && $node->firstChild->nodeType === XML_TEXT_NODE) {
// Node contains nothing but a text node, return its value
$ret = trim($node->nodeValue);
- }
- else
- {
+ } else {
// Otherwise, do recursion
$ret = array();
- foreach ($node->childNodes as $child)
- {
- if ($child->nodeType !== XML_TEXT_NODE)
- {
+ foreach ($node->childNodes as $child) {
+ if ($child->nodeType !== XML_TEXT_NODE) {
// If there's more than one node with this node name on the
// current level, create an array
- if (isset($ret[$child->nodeName]))
- {
- if ( ! is_array($ret[$child->nodeName]) || ! isset($ret[$child->nodeName][0]))
- {
- $tmp = $ret[$child->nodeName];
+ if (isset($ret[$child->nodeName])) {
+ if ( ! is_array($ret[$child->nodeName]) || ! isset($ret[$child->nodeName][0])) {
+ $tmp = $ret[$child->nodeName];
$ret[$child->nodeName] = array();
$ret[$child->nodeName][] = $tmp;
}
$ret[$child->nodeName][] = $this->domNodeToArray($child);
- }
- else
- {
+ } else {
$ret[$child->nodeName] = $this->domNodeToArray($child);
}
}
@@ -373,5 +347,4 @@ class W3CFeedValidatorResponse
return $ret;
}
-
}
diff --git a/tests/PhraseanetPHPUnitAbstract.class.inc b/tests/PhraseanetPHPUnitAbstract.class.inc
index d8ecf445e1..d8d47c9a14 100644
--- a/tests/PhraseanetPHPUnitAbstract.class.inc
+++ b/tests/PhraseanetPHPUnitAbstract.class.inc
@@ -1,14 +1,5 @@
classesMetatdas
- * Load DoctrineTestServices
- *
- * @return
- */
- public function __construct()
- {
- //check if app is set up
- if (!setup::is_installed())
- {
- exit("\033[0;31mPhraseanet is not set up\033[0;37m\r\n");
- }
-
- //init core
- if (null === self::$core)
- {
- self::$core = \bootstrap::getCore();
- }
- }
-
- /**
- * Delete all ressources created during the test
- */
- public function __destruct()
- {
- self::deleteRessources();
-
- if (self::$time_start)
- {
- $stop = microtime(true);
- self::$time_start = null;
- }
- }
-
- /**
- * Implements abstract method from webtestcase
- */
- public function createApplication()
- {
- return;
- }
-
- public function setUp()
- {
- parent::setUp();
- //create a new core instance loaded with the test environment for each test
- self::$core = \bootstrap::execute('test');
- //$this->app['EM'] = self::$core->getEntityManager();
- //set Mozilla user agent as default
- $browser = Browser::getInstance();
- $browser->setUserAgent(self::USER_AGENT_FIREFOX8MAC);
-
- $this->purgeDatabase();
-
- self::$user->ACL()->revoke_access_from_bases(array(self::$collection_no_access->get_base_id()));
- }
-
- public function tearDown()
- {
- //unset static::$core
- self::$core = null;
- parent::tearDown();
- }
-
- /**
- * Insert fixture contained in the specified fixtureLoader
- * into sqlLite test temporary database
- *
- * @param Doctrine\Common\DataFixtures\Loader $fixtureLoader
- */
- public function insertFixtureInDatabase(Doctrine\Common\DataFixtures\Loader $fixtureLoader, $append = true)
- {
- $purger = new Doctrine\Common\DataFixtures\Purger\ORMPurger();
- $executor = new Doctrine\Common\DataFixtures\Executor\ORMExecutor(self::$core->getEntityManager(), $purger);
- $executor->execute($fixtureLoader->getFixtures(), $append);
- }
-
- /**
- * Purge sqlLite test temporary database by truncate all existing tables
- */
- protected function purgeDatabase()
- {
- $purger = new Doctrine\Common\DataFixtures\Purger\ORMPurger();
- $executor = new Doctrine\Common\DataFixtures\Executor\ORMExecutor(self::$core->getEntityManager(), $purger);
- $executor->execute(array());
- self::$core["CacheService"]->flushAll();
- }
-
- protected function assertDateAtom($date)
- {
- return $this->assertRegExp('/\d{4}[-]\d{2}[-]\d{2}[T]\d{2}[:]\d{2}[:]\d{2}[+]\d{2}[:]\d{2}/', $date);
- }
-
- protected function set_user_agent($user_agent)
- {
- $browser = Browser::getInstance();
- $browser->setUserAgent($user_agent);
- //reset twg instance
- $this->resetTwig();
- }
-
- /**
- * Insert one basket entry ans set current authenticated user as owner
- *
- * @return \Entities\Basket
- */
- protected function insertOneBasket()
- {
- try
- {
- $basketFixture = new PhraseaFixture\Basket\LoadOneBasket();
-
- $basketFixture->setUser(self::$user);
-
- $loader = new Loader();
- $loader->addFixture($basketFixture);
-
- $this->insertFixtureInDatabase($loader);
-
- return $basketFixture->basket;
- }
- catch (\Exception $e)
- {
- $this->fail('Fail load one Basket : ' . $e->getMessage());
- }
- }
-
-
- protected function insertOneUsrList(\User_Adapter $user)
- {
- try
- {
- $loader = new Loader();
-
- $UsrOwner = new PhraseaFixture\UsrLists\UsrListOwner();
- $UsrOwner->setUser($user);
-
- $loader->addFixture($UsrOwner);
-
- $UsrList = new PhraseaFixture\UsrLists\UsrList();
-
- $loader->addFixture($UsrList);
-
-
- $this->insertFixtureInDatabase($loader);
-
- return $UsrList->list;
- }
- catch (\Exception $e)
- {
- $this->fail('Fail load one UsrList : ' . $e->getMessage());
- }
- }
-
- /**
- *
- * @param \Entities\UsrList $UsrList
- * @return \Entities\UsrListEntry
- */
- protected function insertOneUsrListEntry(\User_adapter $owner, \User_adapter $user)
- {
- try
- {
- $loader = new Loader();
-
- $UsrOwner = new PhraseaFixture\UsrLists\UsrListOwner();
- $UsrOwner->setUser($owner);
-
- $loader->addFixture($UsrOwner);
-
- $UsrList = new PhraseaFixture\UsrLists\UsrList();
-
- $loader->addFixture($UsrList);
-
- $UsrEntry = new PhraseaFixture\UsrLists\UsrListEntry();
-// $UsrEntry->setList($UsrList);
- $UsrEntry->setUser($user);
-
- $loader->addFixture($UsrEntry);
-
-
- $this->insertFixtureInDatabase($loader);
-
- return $UsrEntry->entry;
- }
- catch (\Exception $e)
- {
- $this->fail('Fail load one UsrListEntry : ' . $e->getMessage());
- }
- }
-
- /**
- * Insert five baskets and set current authenticated user as owner
- *
- * @return \Entities\Basket
- */
- protected function insertFiveBasket()
- {
- try
- {
- $basketFixture = new PhraseaFixture\Basket\LoadFiveBaskets();
-
- $basketFixture->setUser(self::$user);
-
- $loader = new Loader();
- $loader->addFixture($basketFixture);
-
- $this->insertFixtureInDatabase($loader);
-
- return $basketFixture->baskets;
- }
- catch (\Exception $e)
- {
- $this->fail('Fail load five Basket : ' . $e->getMessage());
- }
- }
-
- /**
- *
- * @return \Entities\BasketElement
- */
- protected function insertOneBasketElement()
- {
- $basket = $this->insertOneBasket();
-
- $basketElement = new \Entities\BasketElement();
- $basketElement->setRecord(self::$record_1);
- $basketElement->setBasket($basket);
-
- $basket->addBasketElement($basketElement);
-
- $em = self::$core->getEntityManager();
-
- $em->persist($basketElement);
-
- $em->merge($basket);
-
- $em->flush();
-
- return $basketElement;
- }
-
- /**
- *
- * @return \Entities\Basket
- */
- protected function insertOneValidationBasket()
- {
- $em = self::$core->getEntityManager();
-
- $basketElement = $this->insertOneBasketElement();
- $basket = $basketElement->getBasket();
-
- $Validation = new Entities\ValidationSession();
- $Validation->setBasket($basket);
- $Validation->setInitiator(self::$user);
-
- $basket->setValidation($Validation);
-
- $em->persist($Validation);
- $em->merge($basket);
-
- $Participant = new Entities\ValidationParticipant();
- $Participant->setUser(self::$user);
- $Participant->setCanAgree(true);
- $Participant->setCanSeeOthers(true);
-
- $Validation->addValidationParticipant($Participant);
- $Participant->setSession($Validation);
-
- $em->persist($Participant);
- $em->merge($Validation);
-
- $Data = new Entities\ValidationData();
- $Data->setBasketElement($basketElement);
- $Data->setParticipant($Participant);
- $basketElement->addValidationData($Data);
-
- $em->persist($Data);
- $em->merge($basketElement);
-
- $em->flush();
-
- return $basket;
- }
-
- /**
- * Create a new basket with current auhtenticated user as owner
- * Create a new sessionValidation with the newly created basket
- * Set current authenticated user as sessionValidation initiator
- * Add 2 records as elments of the newly created basket
- * Add 2 participants to the newly created sessionValidation
- *
- * @return \Entities\Basket
- */
- protected function insertOneBasketEnv()
- {
- try
- {
- $em = self::$core->getEntityManager();
- /* @var $em \Doctrine\ORM\EntityManager */
-
- $basketFixture = new PhraseaFixture\Basket\LoadOneBasketEnv();
-
- $basketFixture->setUser(self::$user);
-
- $basketFixture->addParticipant(self::$user_alt1);
- $basketFixture->addParticipant(self::$user_alt2);
-
- $basketFixture->addBasketElement(self::$record_1);
- $basketFixture->addBasketElement(self::$record_2);
-
- $loader = new Loader();
- $loader->addFixture($basketFixture);
-
- $this->insertFixtureInDatabase($loader);
-
- return $basketFixture->basket;
- }
- catch (\Exception $e)
- {
- $this->fail('Fail load one Basket context : ' . $e->getMessage());
- }
- }
-
- /**
- * Load One WZ with
- * One basket
- * One story
- * One ValidationSession & one participant
- * @return
- */
- protected function insertOneWZ()
- {
- try
- {
- $currentUser = self::$user;
- $altUser = self::$user_alt1;
- //add one basket
- $basket = new PhraseaFixture\Basket\LoadOneBasket();
- $basket->setUser($currentUser);
- //add one story
- $story = new PhraseaFixture\Story\LoadOneStory();
- $story->setUser($currentUser);
- $story->setRecord(self::$record_1);
- //add a validation session initiated by alt user
- $validationSession = new PhraseaFixture\ValidationSession\LoadOneValidationSession();
- $validationSession->setUser($altUser);
-
- $loader = new Loader();
- $loader->addFixture($basket);
- $loader->addFixture($story);
- $loader->addFixture($validationSession);
-
- $this->insertFixtureInDatabase($loader);
-
- //add current user as participant
- $validationParticipant = new PhraseaFixture\ValidationParticipant\LoadParticipantWithSession();
- $validationParticipant->setSession($validationSession->validationSession);
- $validationParticipant->setUser($currentUser);
-
- $loader = new Loader();
- $loader->addFixture($validationParticipant);
- $this->insertFixtureInDatabase($loader);
- }
- catch (\Exception $e)
- {
- $this->fail('Fail load one WorkingZone : ' . $e->getMessage());
- }
-
- return;
- }
-
- /**
- * Create a new instance of Twig service
- * @return void
- */
- protected function resetTwig()
- {
- $configuration = self::$core->getConfiguration();
-
- $serviceName = $configuration->getTemplating();
- $confService = $configuration->getService($serviceName);
-
- $templateService = \Alchemy\Phrasea\Core\Service\Builder::create(
- self::$core
- , $confService
- );
-
- $this->app['Core']["Twig"] = $templateService->getDriver();
- }
-
- /**
- * Update the sql tables with the current schema
- * @return void
- */
- private static function updateTablesSchema()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
-
- if (!self::$updated)
- {
-
- if (file_exists(Setup_Upgrade::get_lock_file()))
- {
- unlink(Setup_Upgrade::get_lock_file());
- }
-
- if (null !== self::$core)
- {
- /* @var $em \Doctrine\ORM\EntityManager */
- $em = self::$core->getEntityManager();
-
- //get sqlite filePath
- $params = $em->getConnection()->getParams();
-
- //remove if exists
- if (is_file($params["path"]))
- {
- unlink($params["path"]);
+ //launch chrono
+ if ( ! self::$time_start) {
+ self::$time_start = microtime(true);
}
- //create schema
- $tool = new \Doctrine\ORM\Tools\SchemaTool($em);
- $metas = $em->getMetadataFactory()->getAllMetadata();
- $tool->createSchema($metas);
- }
+ self::updateTablesSchema();
- $upgrader = new Setup_Upgrade($appbox);
- $appbox->forceUpgrade($upgrader);
- unset($upgrader);
+ self::createSetOfUserTests();
- self::$updated = true;
+ self::giveRightsToUser(self::$user);
+
+ self::setCollection();
+
+ self::generateStories();
+
+ self::generateRecords();
+
+ self::generateSubdefs();
}
- set_time_limit(3600);
-
- return;
- }
-
- /**
- * Create a set of users for the test suite
- * self::$user
- * self::$user_alt1
- * self::$user_alt2
- *
- * @return void;
- */
- private static function createSetOfUserTests()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
-
- $usr_id = User_Adapter::get_usr_id_from_login('test_phpunit');
- $usr_alt1_id = User_Adapter::get_usr_id_from_login('test_phpunit_alt1');
- $usr_alt2_id = User_Adapter::get_usr_id_from_login('test_phpunit_alt2');
-
- if (!$usr_id)
+ /**
+ * This method is called after the last test of this test class is run.
+ */
+ public static function tearDownAfterClass()
{
- $user = User_Adapter::create($appbox, 'test_phpunit', random::generatePassword(), 'noone@example.com', false);
- $usr_id = $user->get_id();
- }
- if (!$usr_alt1_id)
- {
- $user = User_Adapter::create($appbox, 'test_phpunit_alt1', random::generatePassword(), 'noonealt1@example.com', false);
- $usr_alt1_id = $user->get_id();
- }
- if (!$usr_alt2_id)
- {
- $user = User_Adapter::create($appbox, 'test_phpunit_alt2', random::generatePassword(), 'noonealt2@example.com', false);
- $usr_alt2_id = $user->get_id();
+ parent::tearDownAfterClass();
}
- self::$user = User_Adapter::getInstance($usr_id, $appbox);
- self::$user_alt1 = User_Adapter::getInstance($usr_alt2_id, $appbox);
- self::$user_alt2 = User_Adapter::getInstance($usr_alt1_id, $appbox);
-
- return;
- }
-
- /**
- * Give Bases Rights to User
- *
- * @param \User_AAdapter $user
- */
- private static function giveRightsToUser(\User_Adapter $user)
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
-
- $user->ACL()->give_access_to_sbas(array_keys($appbox->get_databoxes()));
-
- foreach ($appbox->get_databoxes() as $databox)
+ /**
+ * Delete temporay sqlite database
+ * Create schema using $this->classesMetatdas
+ * Load DoctrineTestServices
+ *
+ * @return
+ */
+ public function __construct()
{
+ //check if app is set up
+ if ( ! setup::is_installed()) {
+ exit("\033[0;31mPhraseanet is not set up\033[0;37m\r\n");
+ }
- $rights = array(
- 'bas_manage' => '1'
- , 'bas_modify_struct' => '1'
- , 'bas_modif_th' => '1'
- , 'bas_chupub' => '1'
- );
+ //init core
+ if (null === self::$core) {
+ self::$core = \bootstrap::getCore();
+ }
+ }
- $user->ACL()->update_rights_to_sbas($databox->get_sbas_id(), $rights);
+ /**
+ * Delete all ressources created during the test
+ */
+ public function __destruct()
+ {
+ self::deleteRessources();
- foreach ($databox->get_collections() as $collection)
- {
- $base_id = $collection->get_base_id();
- $user->ACL()->give_access_to_base(array($base_id));
+ if (self::$time_start) {
+ $stop = microtime(true);
+ self::$time_start = null;
+ }
+ }
- set_exportorder::set_order_admins(array($user->get_id()), $base_id);
+ /**
+ * Implements abstract method from webtestcase
+ */
+ public function createApplication()
+ {
+ return;
+ }
- $rights = array(
- 'canputinalbum' => '1'
- , 'candwnldhd' => '1'
- , 'candwnldsubdef' => '1'
- , 'nowatermark' => '1'
- , 'candwnldpreview' => '1'
- , 'cancmd' => '1'
- , 'canadmin' => '1'
- , 'canreport' => '1'
- , 'canpush' => '1'
- , 'creationdate' => '1'
- , 'canaddrecord' => '1'
- , 'canmodifrecord' => '1'
- , 'candeleterecord' => '1'
- , 'chgstatus' => '1'
- , 'imgtools' => '1'
- , 'manage' => '1'
- , 'modify_struct' => '1'
- , 'manage' => '1'
- , 'bas_modify_struct' => '1'
+ public function setUp()
+ {
+ parent::setUp();
+ //create a new core instance loaded with the test environment for each test
+ self::$core = \bootstrap::execute('test');
+ //$this->app['EM'] = self::$core->getEntityManager();
+ //set Mozilla user agent as default
+ $browser = Browser::getInstance();
+ $browser->setUserAgent(self::USER_AGENT_FIREFOX8MAC);
+
+ $this->purgeDatabase();
+
+ self::$user->ACL()->revoke_access_from_bases(array(self::$collection_no_access->get_base_id()));
+ }
+
+ public function tearDown()
+ {
+ //unset static::$core
+ self::$core = null;
+ parent::tearDown();
+ }
+
+ /**
+ * Insert fixture contained in the specified fixtureLoader
+ * into sqlLite test temporary database
+ *
+ * @param Doctrine\Common\DataFixtures\Loader $fixtureLoader
+ */
+ public function insertFixtureInDatabase(Doctrine\Common\DataFixtures\Loader $fixtureLoader, $append = true)
+ {
+ $purger = new Doctrine\Common\DataFixtures\Purger\ORMPurger();
+ $executor = new Doctrine\Common\DataFixtures\Executor\ORMExecutor(self::$core->getEntityManager(), $purger);
+ $executor->execute($fixtureLoader->getFixtures(), $append);
+ }
+
+ /**
+ * Purge sqlLite test temporary database by truncate all existing tables
+ */
+ protected function purgeDatabase()
+ {
+ $purger = new Doctrine\Common\DataFixtures\Purger\ORMPurger();
+ $executor = new Doctrine\Common\DataFixtures\Executor\ORMExecutor(self::$core->getEntityManager(), $purger);
+ $executor->execute(array());
+ self::$core["CacheService"]->flushAll();
+ }
+
+ protected function assertDateAtom($date)
+ {
+ return $this->assertRegExp('/\d{4}[-]\d{2}[-]\d{2}[T]\d{2}[:]\d{2}[:]\d{2}[+]\d{2}[:]\d{2}/', $date);
+ }
+
+ protected function set_user_agent($user_agent)
+ {
+ $browser = Browser::getInstance();
+ $browser->setUserAgent($user_agent);
+ //reset twg instance
+ $this->resetTwig();
+ }
+
+ /**
+ * Insert one basket entry ans set current authenticated user as owner
+ *
+ * @return \Entities\Basket
+ */
+ protected function insertOneBasket()
+ {
+ try {
+ $basketFixture = new PhraseaFixture\Basket\LoadOneBasket();
+
+ $basketFixture->setUser(self::$user);
+
+ $loader = new Loader();
+ $loader->addFixture($basketFixture);
+
+ $this->insertFixtureInDatabase($loader);
+
+ return $basketFixture->basket;
+ } catch (\Exception $e) {
+ $this->fail('Fail load one Basket : ' . $e->getMessage());
+ }
+ }
+
+ protected function insertOneUsrList(\User_Adapter $user)
+ {
+ try {
+ $loader = new Loader();
+
+ $UsrOwner = new PhraseaFixture\UsrLists\UsrListOwner();
+ $UsrOwner->setUser($user);
+
+ $loader->addFixture($UsrOwner);
+
+ $UsrList = new PhraseaFixture\UsrLists\UsrList();
+
+ $loader->addFixture($UsrList);
+
+
+ $this->insertFixtureInDatabase($loader);
+
+ return $UsrList->list;
+ } catch (\Exception $e) {
+ $this->fail('Fail load one UsrList : ' . $e->getMessage());
+ }
+ }
+
+ /**
+ *
+ * @param \Entities\UsrList $UsrList
+ * @return \Entities\UsrListEntry
+ */
+ protected function insertOneUsrListEntry(\User_adapter $owner, \User_adapter $user)
+ {
+ try {
+ $loader = new Loader();
+
+ $UsrOwner = new PhraseaFixture\UsrLists\UsrListOwner();
+ $UsrOwner->setUser($owner);
+
+ $loader->addFixture($UsrOwner);
+
+ $UsrList = new PhraseaFixture\UsrLists\UsrList();
+
+ $loader->addFixture($UsrList);
+
+ $UsrEntry = new PhraseaFixture\UsrLists\UsrListEntry();
+// $UsrEntry->setList($UsrList);
+ $UsrEntry->setUser($user);
+
+ $loader->addFixture($UsrEntry);
+
+
+ $this->insertFixtureInDatabase($loader);
+
+ return $UsrEntry->entry;
+ } catch (\Exception $e) {
+ $this->fail('Fail load one UsrListEntry : ' . $e->getMessage());
+ }
+ }
+
+ /**
+ * Insert five baskets and set current authenticated user as owner
+ *
+ * @return \Entities\Basket
+ */
+ protected function insertFiveBasket()
+ {
+ try {
+ $basketFixture = new PhraseaFixture\Basket\LoadFiveBaskets();
+
+ $basketFixture->setUser(self::$user);
+
+ $loader = new Loader();
+ $loader->addFixture($basketFixture);
+
+ $this->insertFixtureInDatabase($loader);
+
+ return $basketFixture->baskets;
+ } catch (\Exception $e) {
+ $this->fail('Fail load five Basket : ' . $e->getMessage());
+ }
+ }
+
+ /**
+ *
+ * @return \Entities\BasketElement
+ */
+ protected function insertOneBasketElement()
+ {
+ $basket = $this->insertOneBasket();
+
+ $basketElement = new \Entities\BasketElement();
+ $basketElement->setRecord(self::$record_1);
+ $basketElement->setBasket($basket);
+
+ $basket->addBasketElement($basketElement);
+
+ $em = self::$core->getEntityManager();
+
+ $em->persist($basketElement);
+
+ $em->merge($basket);
+
+ $em->flush();
+
+ return $basketElement;
+ }
+
+ /**
+ *
+ * @return \Entities\Basket
+ */
+ protected function insertOneValidationBasket()
+ {
+ $em = self::$core->getEntityManager();
+
+ $basketElement = $this->insertOneBasketElement();
+ $basket = $basketElement->getBasket();
+
+ $Validation = new Entities\ValidationSession();
+ $Validation->setBasket($basket);
+ $Validation->setInitiator(self::$user);
+
+ $basket->setValidation($Validation);
+
+ $em->persist($Validation);
+ $em->merge($basket);
+
+ $Participant = new Entities\ValidationParticipant();
+ $Participant->setUser(self::$user);
+ $Participant->setCanAgree(true);
+ $Participant->setCanSeeOthers(true);
+
+ $Validation->addValidationParticipant($Participant);
+ $Participant->setSession($Validation);
+
+ $em->persist($Participant);
+ $em->merge($Validation);
+
+ $Data = new Entities\ValidationData();
+ $Data->setBasketElement($basketElement);
+ $Data->setParticipant($Participant);
+ $basketElement->addValidationData($Data);
+
+ $em->persist($Data);
+ $em->merge($basketElement);
+
+ $em->flush();
+
+ return $basket;
+ }
+
+ /**
+ * Create a new basket with current auhtenticated user as owner
+ * Create a new sessionValidation with the newly created basket
+ * Set current authenticated user as sessionValidation initiator
+ * Add 2 records as elments of the newly created basket
+ * Add 2 participants to the newly created sessionValidation
+ *
+ * @return \Entities\Basket
+ */
+ protected function insertOneBasketEnv()
+ {
+ try {
+ $em = self::$core->getEntityManager();
+ /* @var $em \Doctrine\ORM\EntityManager */
+
+ $basketFixture = new PhraseaFixture\Basket\LoadOneBasketEnv();
+
+ $basketFixture->setUser(self::$user);
+
+ $basketFixture->addParticipant(self::$user_alt1);
+ $basketFixture->addParticipant(self::$user_alt2);
+
+ $basketFixture->addBasketElement(self::$record_1);
+ $basketFixture->addBasketElement(self::$record_2);
+
+ $loader = new Loader();
+ $loader->addFixture($basketFixture);
+
+ $this->insertFixtureInDatabase($loader);
+
+ return $basketFixture->basket;
+ } catch (\Exception $e) {
+ $this->fail('Fail load one Basket context : ' . $e->getMessage());
+ }
+ }
+
+ /**
+ * Load One WZ with
+ * One basket
+ * One story
+ * One ValidationSession & one participant
+ * @return
+ */
+ protected function insertOneWZ()
+ {
+ try {
+ $currentUser = self::$user;
+ $altUser = self::$user_alt1;
+ //add one basket
+ $basket = new PhraseaFixture\Basket\LoadOneBasket();
+ $basket->setUser($currentUser);
+ //add one story
+ $story = new PhraseaFixture\Story\LoadOneStory();
+ $story->setUser($currentUser);
+ $story->setRecord(self::$record_1);
+ //add a validation session initiated by alt user
+ $validationSession = new PhraseaFixture\ValidationSession\LoadOneValidationSession();
+ $validationSession->setUser($altUser);
+
+ $loader = new Loader();
+ $loader->addFixture($basket);
+ $loader->addFixture($story);
+ $loader->addFixture($validationSession);
+
+ $this->insertFixtureInDatabase($loader);
+
+ //add current user as participant
+ $validationParticipant = new PhraseaFixture\ValidationParticipant\LoadParticipantWithSession();
+ $validationParticipant->setSession($validationSession->validationSession);
+ $validationParticipant->setUser($currentUser);
+
+ $loader = new Loader();
+ $loader->addFixture($validationParticipant);
+ $this->insertFixtureInDatabase($loader);
+ } catch (\Exception $e) {
+ $this->fail('Fail load one WorkingZone : ' . $e->getMessage());
+ }
+
+ return;
+ }
+
+ /**
+ * Create a new instance of Twig service
+ * @return void
+ */
+ protected function resetTwig()
+ {
+ $configuration = self::$core->getConfiguration();
+
+ $serviceName = $configuration->getTemplating();
+ $confService = $configuration->getService($serviceName);
+
+ $templateService = \Alchemy\Phrasea\Core\Service\Builder::create(
+ self::$core
+ , $confService
);
- $user->ACL()->update_rights_to_base($collection->get_base_id(), $rights);
- }
- }
- }
-
- /**
- * Set self::$collection
- * @return void
- */
- private static function setCollection()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $coll = $collection_no_acces = null;
-
- foreach ($appbox->get_databoxes() as $databox)
- {
- foreach ($databox->get_collections() as $collection)
- {
- if($coll instanceof collection && !$collection_no_acces)
- $collection_no_acces = $collection;
- if(!$coll)
- $coll = $collection;
- if($coll instanceof collection && $collection_no_acces instanceof collection)
- break;
- }
-
- if ($coll instanceof collection && $collection_no_acces instanceof collection)
- {
- break;
- }
+ $this->app['Core']["Twig"] = $templateService->getDriver();
}
- if (!$coll instanceof collection)
+ /**
+ * Update the sql tables with the current schema
+ * @return void
+ */
+ private static function updateTablesSchema()
{
- self::fail('Unable to find a collection');
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+
+ if ( ! self::$updated) {
+
+ if (file_exists(Setup_Upgrade::get_lock_file())) {
+ unlink(Setup_Upgrade::get_lock_file());
+ }
+
+ if (null !== self::$core) {
+ /* @var $em \Doctrine\ORM\EntityManager */
+ $em = self::$core->getEntityManager();
+
+ //get sqlite filePath
+ $params = $em->getConnection()->getParams();
+
+ //remove if exists
+ if (is_file($params["path"])) {
+ unlink($params["path"]);
+ }
+
+ //create schema
+ $tool = new \Doctrine\ORM\Tools\SchemaTool($em);
+ $metas = $em->getMetadataFactory()->getAllMetadata();
+ $tool->createSchema($metas);
+ }
+
+ $upgrader = new Setup_Upgrade($appbox);
+ $appbox->forceUpgrade($upgrader);
+ unset($upgrader);
+
+ self::$updated = true;
+ }
+
+ set_time_limit(3600);
+
+ return;
}
- if (!$collection_no_acces instanceof collection)
+
+ /**
+ * Create a set of users for the test suite
+ * self::$user
+ * self::$user_alt1
+ * self::$user_alt2
+ *
+ * @return void;
+ */
+ private static function createSetOfUserTests()
{
- $collection_no_acces = collection::create($databox, $appbox, 'BIBOO', self::$user);
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+
+ $usr_id = User_Adapter::get_usr_id_from_login('test_phpunit');
+ $usr_alt1_id = User_Adapter::get_usr_id_from_login('test_phpunit_alt1');
+ $usr_alt2_id = User_Adapter::get_usr_id_from_login('test_phpunit_alt2');
+
+ if ( ! $usr_id) {
+ $user = User_Adapter::create($appbox, 'test_phpunit', random::generatePassword(), 'noone@example.com', false);
+ $usr_id = $user->get_id();
+ }
+ if ( ! $usr_alt1_id) {
+ $user = User_Adapter::create($appbox, 'test_phpunit_alt1', random::generatePassword(), 'noonealt1@example.com', false);
+ $usr_alt1_id = $user->get_id();
+ }
+ if ( ! $usr_alt2_id) {
+ $user = User_Adapter::create($appbox, 'test_phpunit_alt2', random::generatePassword(), 'noonealt2@example.com', false);
+ $usr_alt2_id = $user->get_id();
+ }
+
+ self::$user = User_Adapter::getInstance($usr_id, $appbox);
+ self::$user_alt1 = User_Adapter::getInstance($usr_alt2_id, $appbox);
+ self::$user_alt2 = User_Adapter::getInstance($usr_alt1_id, $appbox);
+
+ return;
+ }
+
+ /**
+ * Give Bases Rights to User
+ *
+ * @param \User_AAdapter $user
+ */
+ private static function giveRightsToUser(\User_Adapter $user)
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+
+ $user->ACL()->give_access_to_sbas(array_keys($appbox->get_databoxes()));
+
+ foreach ($appbox->get_databoxes() as $databox) {
+
+ $rights = array(
+ 'bas_manage' => '1'
+ , 'bas_modify_struct' => '1'
+ , 'bas_modif_th' => '1'
+ , 'bas_chupub' => '1'
+ );
+
+ $user->ACL()->update_rights_to_sbas($databox->get_sbas_id(), $rights);
+
+ foreach ($databox->get_collections() as $collection) {
+ $base_id = $collection->get_base_id();
+ $user->ACL()->give_access_to_base(array($base_id));
+
+ set_exportorder::set_order_admins(array($user->get_id()), $base_id);
+
+ $rights = array(
+ 'canputinalbum' => '1'
+ , 'candwnldhd' => '1'
+ , 'candwnldsubdef' => '1'
+ , 'nowatermark' => '1'
+ , 'candwnldpreview' => '1'
+ , 'cancmd' => '1'
+ , 'canadmin' => '1'
+ , 'canreport' => '1'
+ , 'canpush' => '1'
+ , 'creationdate' => '1'
+ , 'canaddrecord' => '1'
+ , 'canmodifrecord' => '1'
+ , 'candeleterecord' => '1'
+ , 'chgstatus' => '1'
+ , 'imgtools' => '1'
+ , 'manage' => '1'
+ , 'modify_struct' => '1'
+ , 'manage' => '1'
+ , 'bas_modify_struct' => '1'
+ );
+
+ $user->ACL()->update_rights_to_base($collection->get_base_id(), $rights);
+ }
+ }
+ }
+
+ /**
+ * Set self::$collection
+ * @return void
+ */
+ private static function setCollection()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $coll = $collection_no_acces = null;
+
+ foreach ($appbox->get_databoxes() as $databox) {
+ foreach ($databox->get_collections() as $collection) {
+ if ($coll instanceof collection && ! $collection_no_acces)
+ $collection_no_acces = $collection;
+ if ( ! $coll)
+ $coll = $collection;
+ if ($coll instanceof collection && $collection_no_acces instanceof collection)
+ break;
+ }
+
+ if ($coll instanceof collection && $collection_no_acces instanceof collection) {
+ break;
+ }
+ }
+
+ if ( ! $coll instanceof collection) {
+ self::fail('Unable to find a collection');
+ }
+ if ( ! $collection_no_acces instanceof collection) {
+ $collection_no_acces = collection::create($databox, $appbox, 'BIBOO', self::$user);
// self::fail('Unable to find a second collection');
+ }
+
+ self::$collection = $coll;
+
+ self::$collection_no_access = $collection_no_acces;
+
+ return;
}
- self::$collection = $coll;
-
- self::$collection_no_access = $collection_no_acces;
-
- return;
- }
-
- /**
- * Generate a set of stories for the current test suites
- *
- * @return void
- */
- private static function generateStories()
- {
- if (static::$need_story && !self::$story_1 instanceof record_adapter)
+ /**
+ * Generate a set of stories for the current test suites
+ *
+ * @return void
+ */
+ private static function generateStories()
{
- self::$story_1 = \record_adapter::create(
- self::$collection
- , new system_file(__DIR__ . '/testfiles/test001.CR2')
- , false
- , true
- );
+ if (static::$need_story && ! self::$story_1 instanceof record_adapter) {
+ self::$story_1 = \record_adapter::create(
+ self::$collection
+ , new system_file(__DIR__ . '/testfiles/test001.CR2')
+ , false
+ , true
+ );
+ }
+
+ if (static::$need_story && ! self::$story_2 instanceof record_adapter) {
+ self::$story_2 = \record_adapter::create(
+ self::$collection
+ , new system_file(__DIR__ . '/testfiles/test001.CR2')
+ , false
+ , true
+ );
+ }
+
+ return;
}
- if (static::$need_story && !self::$story_2 instanceof record_adapter)
+ /**
+ * Generate a set subdef according to the records previously created
+ *
+ * @return void
+ */
+ private static function generateSubdefs()
{
- self::$story_2 = \record_adapter::create(
- self::$collection
- , new system_file(__DIR__ . '/testfiles/test001.CR2')
- , false
- , true
- );
+ if (static::$need_records && static::$need_subdefs) {
+ if (self::$record_1 instanceof record_adapter && ! isset(self::$generated_subdefs['a1'])) {
+ self::$record_1->generate_subdefs(self::$collection->get_databox());
+ self::$generated_subdefs['a1'] = true;
+ }
+ if (self::$record_2 instanceof record_adapter && ! isset(self::$generated_subdefs['a2'])) {
+ self::$record_2->generate_subdefs(self::$collection->get_databox());
+ self::$generated_subdefs['a2'] = true;
+ }
+ if (self::$record_3 instanceof record_adapter && ! isset(self::$generated_subdefs['a3'])) {
+ self::$record_3->generate_subdefs(self::$collection->get_databox());
+ self::$generated_subdefs['a3'] = true;
+ }
+ if (self::$record_4 instanceof record_adapter && ! isset(self::$generated_subdefs['a4'])) {
+ self::$record_4->generate_subdefs(self::$collection->get_databox());
+ self::$generated_subdefs['a4'] = true;
+ }
+ if (self::$record_5 instanceof record_adapter && ! isset(self::$generated_subdefs['a5'])) {
+ self::$record_5->generate_subdefs(self::$collection->get_databox());
+ self::$generated_subdefs['a5'] = true;
+ }
+ if (self::$record_6 instanceof record_adapter && ! isset(self::$generated_subdefs['a6'])) {
+ self::$record_6->generate_subdefs(self::$collection->get_databox());
+ self::$generated_subdefs['a6'] = true;
+ }
+ if (self::$record_7 instanceof record_adapter && ! isset(self::$generated_subdefs['a7'])) {
+ self::$record_7->generate_subdefs(self::$collection->get_databox());
+ self::$generated_subdefs['a7'] = true;
+ }
+ if (self::$record_8 instanceof record_adapter && ! isset(self::$generated_subdefs['a8'])) {
+ self::$record_8->generate_subdefs(self::$collection->get_databox());
+ self::$generated_subdefs['a8'] = true;
+ }
+ if (self::$record_9 instanceof record_adapter && ! isset(self::$generated_subdefs['a9'])) {
+ self::$record_9->generate_subdefs(self::$collection->get_databox());
+ self::$generated_subdefs['a9'] = true;
+ }
+ if (self::$record_10 instanceof record_adapter && ! isset(self::$generated_subdefs['a10'])) {
+ self::$record_10->generate_subdefs(self::$collection->get_databox());
+ self::$generated_subdefs['a10'] = true;
+ }
+ if (self::$record_11 instanceof record_adapter && ! isset(self::$generated_subdefs['a11'])) {
+ self::$record_11->generate_subdefs(self::$collection->get_databox());
+ self::$generated_subdefs['a11'] = true;
+ }
+ if (self::$record_12 instanceof record_adapter && ! isset(self::$generated_subdefs['a12'])) {
+ self::$record_12->generate_subdefs(self::$collection->get_databox());
+ self::$generated_subdefs['a12'] = true;
+ }
+ if (self::$record_13 instanceof record_adapter && ! isset(self::$generated_subdefs['a13'])) {
+ self::$record_13->generate_subdefs(self::$collection->get_databox());
+ self::$generated_subdefs['a13'] = true;
+ }
+ if (self::$record_14 instanceof record_adapter && ! isset(self::$generated_subdefs['a14'])) {
+ self::$record_14->generate_subdefs(self::$collection->get_databox());
+ self::$generated_subdefs['a14'] = true;
+ }
+ if (self::$record_15 instanceof record_adapter && ! isset(self::$generated_subdefs['a15'])) {
+ self::$record_15->generate_subdefs(self::$collection->get_databox());
+ self::$generated_subdefs['a15'] = true;
+ }
+ if (self::$record_16 instanceof record_adapter && ! isset(self::$generated_subdefs['a16'])) {
+ self::$record_16->generate_subdefs(self::$collection->get_databox());
+ self::$generated_subdefs['a16'] = true;
+ }
+ if (self::$record_17 instanceof record_adapter && ! isset(self::$generated_subdefs['a17'])) {
+ self::$record_17->generate_subdefs(self::$collection->get_databox());
+ self::$generated_subdefs['a17'] = true;
+ }
+ if (self::$record_18 instanceof record_adapter && ! isset(self::$generated_subdefs['a18'])) {
+ self::$record_18->generate_subdefs(self::$collection->get_databox());
+ self::$generated_subdefs['a18'] = true;
+ }
+ if (self::$record_19 instanceof record_adapter && ! isset(self::$generated_subdefs['a19'])) {
+ self::$record_19->generate_subdefs(self::$collection->get_databox());
+ self::$generated_subdefs['a19'] = true;
+ }
+ if (self::$record_20 instanceof record_adapter && ! isset(self::$generated_subdefs['a20'])) {
+ self::$record_20->generate_subdefs(self::$collection->get_databox());
+ self::$generated_subdefs['a20'] = true;
+ }
+ if (self::$record_21 instanceof record_adapter && ! isset(self::$generated_subdefs['a21'])) {
+ self::$record_21->generate_subdefs(self::$collection->get_databox());
+ self::$generated_subdefs['a21'] = true;
+ }
+ if (self::$record_22 instanceof record_adapter && ! isset(self::$generated_subdefs['a22'])) {
+ self::$record_22->generate_subdefs(self::$collection->get_databox());
+ self::$generated_subdefs['a22'] = true;
+ }
+ if (self::$record_23 instanceof record_adapter && ! isset(self::$generated_subdefs['a23'])) {
+ self::$record_23->generate_subdefs(self::$collection->get_databox());
+ self::$generated_subdefs['a23'] = true;
+ }
+ }
+
+ return;
}
- return;
- }
-
- /**
- * Generate a set subdef according to the records previously created
- *
- * @return void
- */
- private static function generateSubdefs()
- {
- if (static::$need_records && static::$need_subdefs)
+ /**
+ * Generate a set of records for the current tests suites
+ * @return void
+ */
+ private static function generateRecords()
{
- if (self::$record_1 instanceof record_adapter && !isset(self::$generated_subdefs['a1']))
- {
- self::$record_1->generate_subdefs(self::$collection->get_databox());
- self::$generated_subdefs['a1'] = true;
- }
- if (self::$record_2 instanceof record_adapter && !isset(self::$generated_subdefs['a2']))
- {
- self::$record_2->generate_subdefs(self::$collection->get_databox());
- self::$generated_subdefs['a2'] = true;
- }
- if (self::$record_3 instanceof record_adapter && !isset(self::$generated_subdefs['a3']))
- {
- self::$record_3->generate_subdefs(self::$collection->get_databox());
- self::$generated_subdefs['a3'] = true;
- }
- if (self::$record_4 instanceof record_adapter && !isset(self::$generated_subdefs['a4']))
- {
- self::$record_4->generate_subdefs(self::$collection->get_databox());
- self::$generated_subdefs['a4'] = true;
- }
- if (self::$record_5 instanceof record_adapter && !isset(self::$generated_subdefs['a5']))
- {
- self::$record_5->generate_subdefs(self::$collection->get_databox());
- self::$generated_subdefs['a5'] = true;
- }
- if (self::$record_6 instanceof record_adapter && !isset(self::$generated_subdefs['a6']))
- {
- self::$record_6->generate_subdefs(self::$collection->get_databox());
- self::$generated_subdefs['a6'] = true;
- }
- if (self::$record_7 instanceof record_adapter && !isset(self::$generated_subdefs['a7']))
- {
- self::$record_7->generate_subdefs(self::$collection->get_databox());
- self::$generated_subdefs['a7'] = true;
- }
- if (self::$record_8 instanceof record_adapter && !isset(self::$generated_subdefs['a8']))
- {
- self::$record_8->generate_subdefs(self::$collection->get_databox());
- self::$generated_subdefs['a8'] = true;
- }
- if (self::$record_9 instanceof record_adapter && !isset(self::$generated_subdefs['a9']))
- {
- self::$record_9->generate_subdefs(self::$collection->get_databox());
- self::$generated_subdefs['a9'] = true;
- }
- if (self::$record_10 instanceof record_adapter && !isset(self::$generated_subdefs['a10']))
- {
- self::$record_10->generate_subdefs(self::$collection->get_databox());
- self::$generated_subdefs['a10'] = true;
- }
- if (self::$record_11 instanceof record_adapter && !isset(self::$generated_subdefs['a11']))
- {
- self::$record_11->generate_subdefs(self::$collection->get_databox());
- self::$generated_subdefs['a11'] = true;
- }
- if (self::$record_12 instanceof record_adapter && !isset(self::$generated_subdefs['a12']))
- {
- self::$record_12->generate_subdefs(self::$collection->get_databox());
- self::$generated_subdefs['a12'] = true;
- }
- if (self::$record_13 instanceof record_adapter && !isset(self::$generated_subdefs['a13']))
- {
- self::$record_13->generate_subdefs(self::$collection->get_databox());
- self::$generated_subdefs['a13'] = true;
- }
- if (self::$record_14 instanceof record_adapter && !isset(self::$generated_subdefs['a14']))
- {
- self::$record_14->generate_subdefs(self::$collection->get_databox());
- self::$generated_subdefs['a14'] = true;
- }
- if (self::$record_15 instanceof record_adapter && !isset(self::$generated_subdefs['a15']))
- {
- self::$record_15->generate_subdefs(self::$collection->get_databox());
- self::$generated_subdefs['a15'] = true;
- }
- if (self::$record_16 instanceof record_adapter && !isset(self::$generated_subdefs['a16']))
- {
- self::$record_16->generate_subdefs(self::$collection->get_databox());
- self::$generated_subdefs['a16'] = true;
- }
- if (self::$record_17 instanceof record_adapter && !isset(self::$generated_subdefs['a17']))
- {
- self::$record_17->generate_subdefs(self::$collection->get_databox());
- self::$generated_subdefs['a17'] = true;
- }
- if (self::$record_18 instanceof record_adapter && !isset(self::$generated_subdefs['a18']))
- {
- self::$record_18->generate_subdefs(self::$collection->get_databox());
- self::$generated_subdefs['a18'] = true;
- }
- if (self::$record_19 instanceof record_adapter && !isset(self::$generated_subdefs['a19']))
- {
- self::$record_19->generate_subdefs(self::$collection->get_databox());
- self::$generated_subdefs['a19'] = true;
- }
- if (self::$record_20 instanceof record_adapter && !isset(self::$generated_subdefs['a20']))
- {
- self::$record_20->generate_subdefs(self::$collection->get_databox());
- self::$generated_subdefs['a20'] = true;
- }
- if (self::$record_21 instanceof record_adapter && !isset(self::$generated_subdefs['a21']))
- {
- self::$record_21->generate_subdefs(self::$collection->get_databox());
- self::$generated_subdefs['a21'] = true;
- }
- if (self::$record_22 instanceof record_adapter && !isset(self::$generated_subdefs['a22']))
- {
- self::$record_22->generate_subdefs(self::$collection->get_databox());
- self::$generated_subdefs['a22'] = true;
- }
- if (self::$record_23 instanceof record_adapter && !isset(self::$generated_subdefs['a23']))
- {
- self::$record_23->generate_subdefs(self::$collection->get_databox());
- self::$generated_subdefs['a23'] = true;
- }
+ if (static::$need_records) {
+ if ((static::$need_records === true || static::$need_records >= 1) && ! self::$record_1 instanceof record_adapter) {
+ self::$record_sf_1 = new system_file(__DIR__ . '/testfiles/test001.CR2');
+ self::$record_1 = record_adapter::create(self::$collection, self::$record_sf_1);
+ }
+ if ((static::$need_records === true || static::$need_records >= 1) && ! self::$record_no_access instanceof record_adapter) {
+ $file = new system_file(__DIR__ . '/testfiles/test001.CR2');
+ self::$record_no_access = record_adapter::create(self::$collection_no_access, $file);
+ }
+ if ((static::$need_records === true || static::$need_records >= 2) && ! self::$record_2 instanceof record_adapter) {
+ self::$record_sf_2 = new system_file(__DIR__ . '/testfiles/test002.CR2');
+ self::$record_2 = record_adapter::create(self::$collection, self::$record_sf_2);
+ }
+ if ((static::$need_records === true || static::$need_records >= 3) && ! self::$record_3 instanceof record_adapter) {
+ self::$record_sf_3 = new system_file(__DIR__ . '/testfiles/test003.CR2');
+ self::$record_3 = record_adapter::create(self::$collection, self::$record_sf_3);
+ }
+ if ((static::$need_records === true || static::$need_records >= 4) && ! self::$record_4 instanceof record_adapter) {
+ self::$record_sf_4 = new system_file(__DIR__ . '/testfiles/test004.CR2');
+ self::$record_4 = record_adapter::create(self::$collection, self::$record_sf_4);
+ }
+ if ((static::$need_records === true || static::$need_records >= 5) && ! self::$record_5 instanceof record_adapter) {
+ self::$record_sf_5 = new system_file(__DIR__ . '/testfiles/test005.CR2');
+ self::$record_5 = record_adapter::create(self::$collection, self::$record_sf_5);
+ }
+ if ((static::$need_records === true || static::$need_records >= 6) && ! self::$record_6 instanceof record_adapter) {
+ self::$record_sf_6 = new system_file(__DIR__ . '/testfiles/test006.wav');
+ self::$record_6 = record_adapter::create(self::$collection, self::$record_sf_6);
+ }
+ if ((static::$need_records === true || static::$need_records >= 7) && ! self::$record_7 instanceof record_adapter) {
+ self::$record_sf_7 = new system_file(__DIR__ . '/testfiles/test007.ppt');
+ self::$record_7 = record_adapter::create(self::$collection, self::$record_sf_7);
+ }
+ if ((static::$need_records === true || static::$need_records >= 8) && ! self::$record_8 instanceof record_adapter) {
+ self::$record_sf_8 = new system_file(__DIR__ . '/testfiles/test008.ai');
+ self::$record_8 = record_adapter::create(self::$collection, self::$record_sf_8);
+ }
+ if ((static::$need_records === true || static::$need_records >= 9) && ! self::$record_9 instanceof record_adapter) {
+ self::$record_sf_9 = new system_file(__DIR__ . '/testfiles/test009.TIFF');
+ self::$record_9 = record_adapter::create(self::$collection, self::$record_sf_9);
+ }
+ if ((static::$need_records === true || static::$need_records >= 10) && ! self::$record_10 instanceof record_adapter) {
+ self::$record_sf_10 = new system_file(__DIR__ . '/testfiles/test010.fla');
+ self::$record_10 = record_adapter::create(self::$collection, self::$record_sf_10);
+ }
+ if ((static::$need_records === true || static::$need_records >= 11) && ! self::$record_11 instanceof record_adapter) {
+ self::$record_sf_11 = new system_file(__DIR__ . '/testfiles/test011.swf');
+ self::$record_11 = record_adapter::create(self::$collection, self::$record_sf_11);
+ }
+ if ((static::$need_records === true || static::$need_records >= 12) && ! self::$record_12 instanceof record_adapter) {
+ self::$record_sf_12 = new system_file(__DIR__ . '/testfiles/test012.wav');
+ self::$record_12 = record_adapter::create(self::$collection, self::$record_sf_12);
+ }
+ if ((static::$need_records === true || static::$need_records >= 13) && ! self::$record_13 instanceof record_adapter) {
+ self::$record_sf_13 = new system_file(__DIR__ . '/testfiles/test013.ai');
+ self::$record_13 = record_adapter::create(self::$collection, self::$record_sf_13);
+ }
+ if ((static::$need_records === true || static::$need_records >= 14) && ! self::$record_14 instanceof record_adapter) {
+ self::$record_sf_14 = new system_file(__DIR__ . '/testfiles/test014.swf');
+ self::$record_14 = record_adapter::create(self::$collection, self::$record_sf_14);
+ }
+ if ((static::$need_records === true || static::$need_records >= 15) && ! self::$record_15 instanceof record_adapter) {
+ self::$record_sf_15 = new system_file(__DIR__ . '/testfiles/test015.eps');
+ self::$record_15 = record_adapter::create(self::$collection, self::$record_sf_15);
+ }
+ if ((static::$need_records === true || static::$need_records >= 16) && ! self::$record_16 instanceof record_adapter) {
+ self::$record_sf_16 = new system_file(__DIR__ . '/testfiles/test016.ai');
+ self::$record_16 = record_adapter::create(self::$collection, self::$record_sf_16);
+ }
+ if ((static::$need_records === true || static::$need_records >= 17) && ! self::$record_17 instanceof record_adapter) {
+ self::$record_sf_17 = new system_file(__DIR__ . '/testfiles/test017.wav');
+ self::$record_17 = record_adapter::create(self::$collection, self::$record_sf_17);
+ }
+ if ((static::$need_records === true || static::$need_records >= 18) && ! self::$record_18 instanceof record_adapter) {
+ self::$record_sf_18 = new system_file(__DIR__ . '/testfiles/test018.TIFF');
+ self::$record_18 = record_adapter::create(self::$collection, self::$record_sf_18);
+ }
+ if ((static::$need_records === true || static::$need_records >= 19) && ! self::$record_19 instanceof record_adapter) {
+ self::$record_sf_19 = new system_file(__DIR__ . '/testfiles/test019.mp3');
+ self::$record_19 = record_adapter::create(self::$collection, self::$record_sf_19);
+ }
+ if ((static::$need_records === true || static::$need_records >= 20) && ! self::$record_20 instanceof record_adapter) {
+ self::$record_sf_20 = new system_file(__DIR__ . '/testfiles/test020.mp3');
+ self::$record_20 = record_adapter::create(self::$collection, self::$record_sf_20);
+ }
+ if ((static::$need_records === true || static::$need_records >= 21) && ! self::$record_21 instanceof record_adapter) {
+ self::$record_sf_21 = new system_file(__DIR__ . '/testfiles/test021.fla');
+ self::$record_21 = record_adapter::create(self::$collection, self::$record_sf_21);
+ }
+ if ((static::$need_records === true || static::$need_records >= 22) && ! self::$record_22 instanceof record_adapter) {
+ self::$record_sf_22 = new system_file(__DIR__ . '/testfiles/test022.swf');
+ self::$record_22 = record_adapter::create(self::$collection, self::$record_sf_22);
+ }
+ if ((static::$need_records === true || static::$need_records >= 23) && ! self::$record_23 instanceof record_adapter) {
+ self::$record_sf_23 = new system_file(__DIR__ . '/testfiles/test023.mp4');
+ self::$record_23 = record_adapter::create(self::$collection, self::$record_sf_23);
+ }
+ }
+
+ return;
}
- return;
- }
+ /**
+ * Delete previously created Ressources
+ *
+ * @return void
+ */
+ private static function deleteRessources()
+ {
+ $skipped = \PhraseanetPHPUnitListener::getSkipped();
- /**
- * Generate a set of records for the current tests suites
- * @return void
- */
- private static function generateRecords()
- {
- if (static::$need_records)
- {
- if ((static::$need_records === true || static::$need_records >= 1) && !self::$record_1 instanceof record_adapter)
- {
- self::$record_sf_1 = new system_file(__DIR__ . '/testfiles/test001.CR2');
- self::$record_1 = record_adapter::create(self::$collection, self::$record_sf_1);
- }
- if ((static::$need_records === true || static::$need_records >= 1) && !self::$record_no_access instanceof record_adapter)
- {
- $file = new system_file(__DIR__ . '/testfiles/test001.CR2');
- self::$record_no_access = record_adapter::create(self::$collection_no_access, $file);
- }
- if ((static::$need_records === true || static::$need_records >= 2) && !self::$record_2 instanceof record_adapter)
- {
- self::$record_sf_2 = new system_file(__DIR__ . '/testfiles/test002.CR2');
- self::$record_2 = record_adapter::create(self::$collection, self::$record_sf_2);
- }
- if ((static::$need_records === true || static::$need_records >= 3) && !self::$record_3 instanceof record_adapter)
- {
- self::$record_sf_3 = new system_file(__DIR__ . '/testfiles/test003.CR2');
- self::$record_3 = record_adapter::create(self::$collection, self::$record_sf_3);
- }
- if ((static::$need_records === true || static::$need_records >= 4) && !self::$record_4 instanceof record_adapter)
- {
- self::$record_sf_4 = new system_file(__DIR__ . '/testfiles/test004.CR2');
- self::$record_4 = record_adapter::create(self::$collection, self::$record_sf_4);
- }
- if ((static::$need_records === true || static::$need_records >= 5) && !self::$record_5 instanceof record_adapter)
- {
- self::$record_sf_5 = new system_file(__DIR__ . '/testfiles/test005.CR2');
- self::$record_5 = record_adapter::create(self::$collection, self::$record_sf_5);
- }
- if ((static::$need_records === true || static::$need_records >= 6) && !self::$record_6 instanceof record_adapter)
- {
- self::$record_sf_6 = new system_file(__DIR__ . '/testfiles/test006.wav');
- self::$record_6 = record_adapter::create(self::$collection, self::$record_sf_6);
- }
- if ((static::$need_records === true || static::$need_records >= 7) && !self::$record_7 instanceof record_adapter)
- {
- self::$record_sf_7 = new system_file(__DIR__ . '/testfiles/test007.ppt');
- self::$record_7 = record_adapter::create(self::$collection, self::$record_sf_7);
- }
- if ((static::$need_records === true || static::$need_records >= 8) && !self::$record_8 instanceof record_adapter)
- {
- self::$record_sf_8 = new system_file(__DIR__ . '/testfiles/test008.ai');
- self::$record_8 = record_adapter::create(self::$collection, self::$record_sf_8);
- }
- if ((static::$need_records === true || static::$need_records >= 9) && !self::$record_9 instanceof record_adapter)
- {
- self::$record_sf_9 = new system_file(__DIR__ . '/testfiles/test009.TIFF');
- self::$record_9 = record_adapter::create(self::$collection, self::$record_sf_9);
- }
- if ((static::$need_records === true || static::$need_records >= 10) && !self::$record_10 instanceof record_adapter)
- {
- self::$record_sf_10 = new system_file(__DIR__ . '/testfiles/test010.fla');
- self::$record_10 = record_adapter::create(self::$collection, self::$record_sf_10);
- }
- if ((static::$need_records === true || static::$need_records >= 11) && !self::$record_11 instanceof record_adapter)
- {
- self::$record_sf_11 = new system_file(__DIR__ . '/testfiles/test011.swf');
- self::$record_11 = record_adapter::create(self::$collection, self::$record_sf_11);
- }
- if ((static::$need_records === true || static::$need_records >= 12) && !self::$record_12 instanceof record_adapter)
- {
- self::$record_sf_12 = new system_file(__DIR__ . '/testfiles/test012.wav');
- self::$record_12 = record_adapter::create(self::$collection, self::$record_sf_12);
- }
- if ((static::$need_records === true || static::$need_records >= 13) && !self::$record_13 instanceof record_adapter)
- {
- self::$record_sf_13 = new system_file(__DIR__ . '/testfiles/test013.ai');
- self::$record_13 = record_adapter::create(self::$collection, self::$record_sf_13);
- }
- if ((static::$need_records === true || static::$need_records >= 14) && !self::$record_14 instanceof record_adapter)
- {
- self::$record_sf_14 = new system_file(__DIR__ . '/testfiles/test014.swf');
- self::$record_14 = record_adapter::create(self::$collection, self::$record_sf_14);
- }
- if ((static::$need_records === true || static::$need_records >= 15) && !self::$record_15 instanceof record_adapter)
- {
- self::$record_sf_15 = new system_file(__DIR__ . '/testfiles/test015.eps');
- self::$record_15 = record_adapter::create(self::$collection, self::$record_sf_15);
- }
- if ((static::$need_records === true || static::$need_records >= 16) && !self::$record_16 instanceof record_adapter)
- {
- self::$record_sf_16 = new system_file(__DIR__ . '/testfiles/test016.ai');
- self::$record_16 = record_adapter::create(self::$collection, self::$record_sf_16);
- }
- if ((static::$need_records === true || static::$need_records >= 17) && !self::$record_17 instanceof record_adapter)
- {
- self::$record_sf_17 = new system_file(__DIR__ . '/testfiles/test017.wav');
- self::$record_17 = record_adapter::create(self::$collection, self::$record_sf_17);
- }
- if ((static::$need_records === true || static::$need_records >= 18) && !self::$record_18 instanceof record_adapter)
- {
- self::$record_sf_18 = new system_file(__DIR__ . '/testfiles/test018.TIFF');
- self::$record_18 = record_adapter::create(self::$collection, self::$record_sf_18);
- }
- if ((static::$need_records === true || static::$need_records >= 19) && !self::$record_19 instanceof record_adapter)
- {
- self::$record_sf_19 = new system_file(__DIR__ . '/testfiles/test019.mp3');
- self::$record_19 = record_adapter::create(self::$collection, self::$record_sf_19);
- }
- if ((static::$need_records === true || static::$need_records >= 20) && !self::$record_20 instanceof record_adapter)
- {
- self::$record_sf_20 = new system_file(__DIR__ . '/testfiles/test020.mp3');
- self::$record_20 = record_adapter::create(self::$collection, self::$record_sf_20);
- }
- if ((static::$need_records === true || static::$need_records >= 21) && !self::$record_21 instanceof record_adapter)
- {
- self::$record_sf_21 = new system_file(__DIR__ . '/testfiles/test021.fla');
- self::$record_21 = record_adapter::create(self::$collection, self::$record_sf_21);
- }
- if ((static::$need_records === true || static::$need_records >= 22) && !self::$record_22 instanceof record_adapter)
- {
- self::$record_sf_22 = new system_file(__DIR__ . '/testfiles/test022.swf');
- self::$record_22 = record_adapter::create(self::$collection, self::$record_sf_22);
- }
- if ((static::$need_records === true || static::$need_records >= 23) && !self::$record_23 instanceof record_adapter)
- {
- self::$record_sf_23 = new system_file(__DIR__ . '/testfiles/test023.mp4');
- self::$record_23 = record_adapter::create(self::$collection, self::$record_sf_23);
- }
- }
+ if ($skipped) {
+ echo "\nSkipped test : \n\n";
+ foreach ($skipped as $skipped_test) {
+ echo $skipped_test . "\n";
+ }
+ echo "\n";
+ }
- return;
- }
+ \PhraseanetPHPUnitListener::resetSkipped();
- /**
- * Delete previously created Ressources
- *
- * @return void
- */
- private static function deleteRessources()
- {
- $skipped = \PhraseanetPHPUnitListener::getSkipped();
+ if (self::$story_1 instanceof record_adapter) {
+ self::$story_1->delete();
+ self::$story_1 = null;
+ }
+ if (self::$story_2 instanceof record_adapter) {
+ self::$story_2->delete();
+ self::$story_2 = null;
+ }
+ if (self::$record_1 instanceof record_adapter) {
+ self::$record_1->delete();
+ self::$record_1 = null;
+ }
+ if (self::$record_2 instanceof record_adapter) {
+ self::$record_2->delete();
+ self::$record_2 = null;
+ }
+ if (self::$record_3 instanceof record_adapter) {
+ self::$record_3->delete();
+ self::$record_3 = null;
+ }
+ if (self::$record_4 instanceof record_adapter) {
+ self::$record_4->delete();
+ self::$record_4 = null;
+ }
+ if (self::$record_5 instanceof record_adapter) {
+ self::$record_5->delete();
+ self::$record_5 = null;
+ }
+ if (self::$record_6 instanceof record_adapter) {
+ self::$record_6->delete();
+ self::$record_6 = null;
+ }
+ if (self::$record_7 instanceof record_adapter) {
+ self::$record_7->delete();
+ self::$record_7 = null;
+ }
+ if (self::$record_8 instanceof record_adapter) {
+ self::$record_8->delete();
+ self::$record_8 = null;
+ }
+ if (self::$record_9 instanceof record_adapter) {
+ self::$record_9->delete();
+ self::$record_9 = null;
+ }
+ if (self::$record_10 instanceof record_adapter) {
+ self::$record_10->delete();
+ self::$record_10 = null;
+ }
+ if (self::$record_11 instanceof record_adapter) {
+ self::$record_11->delete();
+ self::$record_11 = null;
+ }
+ if (self::$record_12 instanceof record_adapter) {
+ self::$record_12->delete();
+ self::$record_12 = null;
+ }
+ if (self::$record_13 instanceof record_adapter) {
+ self::$record_13->delete();
+ self::$record_13 = null;
+ }
+ if (self::$record_14 instanceof record_adapter) {
+ self::$record_14->delete();
+ self::$record_14 = null;
+ }
+ if (self::$record_15 instanceof record_adapter) {
+ self::$record_15->delete();
+ self::$record_15 = null;
+ }
+ if (self::$record_16 instanceof record_adapter) {
+ self::$record_16->delete();
+ self::$record_16 = null;
+ }
+ if (self::$record_17 instanceof record_adapter) {
+ self::$record_17->delete();
+ self::$record_17 = null;
+ }
+ if (self::$record_18 instanceof record_adapter) {
+ self::$record_18->delete();
+ self::$record_18 = null;
+ }
+ if (self::$record_19 instanceof record_adapter) {
+ self::$record_19->delete();
+ self::$record_19 = null;
+ }
+ if (self::$record_20 instanceof record_adapter) {
+ self::$record_20->delete();
+ self::$record_20 = null;
+ }
+ if (self::$record_21 instanceof record_adapter) {
+ self::$record_21->delete();
+ self::$record_21 = null;
+ }
+ if (self::$record_22 instanceof record_adapter) {
+ self::$record_22->delete();
+ self::$record_22 = null;
+ }
+ if (self::$record_23 instanceof record_adapter) {
+ self::$record_23->delete();
+ self::$record_23 = null;
+ }
- if($skipped)
- {
- echo "\nSkipped test : \n\n";
- foreach($skipped as $skipped_test)
- {
- echo $skipped_test . "\n";
- }
- echo "\n";
+ return;
}
-
- \PhraseanetPHPUnitListener::resetSkipped();
-
- if (self::$story_1 instanceof record_adapter)
- {
- self::$story_1->delete();
- self::$story_1 = null;
- }
- if (self::$story_2 instanceof record_adapter)
- {
- self::$story_2->delete();
- self::$story_2 = null;
- }
- if (self::$record_1 instanceof record_adapter)
- {
- self::$record_1->delete();
- self::$record_1 = null;
- }
- if (self::$record_2 instanceof record_adapter)
- {
- self::$record_2->delete();
- self::$record_2 = null;
- }
- if (self::$record_3 instanceof record_adapter)
- {
- self::$record_3->delete();
- self::$record_3 = null;
- }
- if (self::$record_4 instanceof record_adapter)
- {
- self::$record_4->delete();
- self::$record_4 = null;
- }
- if (self::$record_5 instanceof record_adapter)
- {
- self::$record_5->delete();
- self::$record_5 = null;
- }
- if (self::$record_6 instanceof record_adapter)
- {
- self::$record_6->delete();
- self::$record_6 = null;
- }
- if (self::$record_7 instanceof record_adapter)
- {
- self::$record_7->delete();
- self::$record_7 = null;
- }
- if (self::$record_8 instanceof record_adapter)
- {
- self::$record_8->delete();
- self::$record_8 = null;
- }
- if (self::$record_9 instanceof record_adapter)
- {
- self::$record_9->delete();
- self::$record_9 = null;
- }
- if (self::$record_10 instanceof record_adapter)
- {
- self::$record_10->delete();
- self::$record_10 = null;
- }
- if (self::$record_11 instanceof record_adapter)
- {
- self::$record_11->delete();
- self::$record_11 = null;
- }
- if (self::$record_12 instanceof record_adapter)
- {
- self::$record_12->delete();
- self::$record_12 = null;
- }
- if (self::$record_13 instanceof record_adapter)
- {
- self::$record_13->delete();
- self::$record_13 = null;
- }
- if (self::$record_14 instanceof record_adapter)
- {
- self::$record_14->delete();
- self::$record_14 = null;
- }
- if (self::$record_15 instanceof record_adapter)
- {
- self::$record_15->delete();
- self::$record_15 = null;
- }
- if (self::$record_16 instanceof record_adapter)
- {
- self::$record_16->delete();
- self::$record_16 = null;
- }
- if (self::$record_17 instanceof record_adapter)
- {
- self::$record_17->delete();
- self::$record_17 = null;
- }
- if (self::$record_18 instanceof record_adapter)
- {
- self::$record_18->delete();
- self::$record_18 = null;
- }
- if (self::$record_19 instanceof record_adapter)
- {
- self::$record_19->delete();
- self::$record_19 = null;
- }
- if (self::$record_20 instanceof record_adapter)
- {
- self::$record_20->delete();
- self::$record_20 = null;
- }
- if (self::$record_21 instanceof record_adapter)
- {
- self::$record_21->delete();
- self::$record_21 = null;
- }
- if (self::$record_22 instanceof record_adapter)
- {
- self::$record_22->delete();
- self::$record_22 = null;
- }
- if (self::$record_23 instanceof record_adapter)
- {
- self::$record_23->delete();
- self::$record_23 = null;
- }
-
- return;
- }
-
}
diff --git a/tests/PhraseanetPHPUnitAuthenticatedAbstract.class.inc b/tests/PhraseanetPHPUnitAuthenticatedAbstract.class.inc
index 740afc2a77..8cf297cfcb 100644
--- a/tests/PhraseanetPHPUnitAuthenticatedAbstract.class.inc
+++ b/tests/PhraseanetPHPUnitAuthenticatedAbstract.class.inc
@@ -1,20 +1,5 @@
get_session();
- $auth = new Session_Authentication_None(self::$user);
- $session->authenticate($auth);
- }
-
- public function tearDown()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $session = $appbox->get_session();
- $session->logout();
- parent::tearDown();
- }
+ public function setUp()
+ {
+ parent::setUp();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $session = $appbox->get_session();
+ $auth = new Session_Authentication_None(self::$user);
+ $session->authenticate($auth);
+ }
+ public function tearDown()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $session = $appbox->get_session();
+ $session->logout();
+ parent::tearDown();
+ }
}
diff --git a/tests/PhraseanetPHPUnitListener.class.inc b/tests/PhraseanetPHPUnitListener.class.inc
index 4533141386..0a8f6804bd 100644
--- a/tests/PhraseanetPHPUnitListener.class.inc
+++ b/tests/PhraseanetPHPUnitListener.class.inc
@@ -2,61 +2,59 @@
class PhraseanetPHPUnitListener implements PHPUnit_Framework_TestListener
{
+ private static $skipped = array();
- private static $skipped = array();
+ public function addError(PHPUnit_Framework_Test $test, Exception $e, $time)
+ {
+ return;
+ }
- public function addError(PHPUnit_Framework_Test $test, Exception $e, $time)
- {
- return;
- }
+ public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time)
+ {
+ return;
+ }
- public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time)
- {
- return;
- }
+ public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time)
+ {
+ return;
+ }
- public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time)
- {
- return;
- }
+ public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time)
+ {
+ static::$skipped[] = get_class($test) . ':' . $test->getName() . ' - ' . $e->getMessage();
- public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time)
- {
- static::$skipped[] = get_class($test) . ':' . $test->getName() . ' - ' . $e->getMessage();
+ return;
+ }
- return;
- }
+ public function getSkipped()
+ {
+ return static::$skipped;
+ }
- public function getSkipped()
- {
- return static::$skipped;
- }
+ public function resetSkipped()
+ {
+ static::$skipped = array();
- public function resetSkipped()
- {
- static::$skipped = array();
+ return;
+ }
- return;
- }
+ public function startTest(PHPUnit_Framework_Test $test)
+ {
+ return;
+ }
- public function startTest(PHPUnit_Framework_Test $test)
- {
- return;
- }
+ public function endTest(PHPUnit_Framework_Test $test, $time)
+ {
+ return;
+ }
- public function endTest(PHPUnit_Framework_Test $test, $time)
- {
- return;
- }
-
- public function startTestSuite(PHPUnit_Framework_TestSuite $suite)
- {
- return;
- }
-
- public function endTestSuite(PHPUnit_Framework_TestSuite $suite)
- {
- return;
- }
+ public function startTestSuite(PHPUnit_Framework_TestSuite $suite)
+ {
+ return;
+ }
+ public function endTestSuite(PHPUnit_Framework_TestSuite $suite)
+ {
+ return;
+ }
}
diff --git a/tests/PhraseanetWebTestCaseAbstract.class.inc b/tests/PhraseanetWebTestCaseAbstract.class.inc
index 7e1c48964d..649c35485c 100644
--- a/tests/PhraseanetWebTestCaseAbstract.class.inc
+++ b/tests/PhraseanetWebTestCaseAbstract.class.inc
@@ -1,20 +1,5 @@
get_session();
- $auth = new Session_Authentication_None(self::$user);
- $session->authenticate($auth);
- }
-
- public static function tearDownAfterClass()
- {
- parent::tearDownAfterClass();
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $session = $appbox->get_session();
- $session->logout();
- }
+ public static function setUpBeforeClass()
+ {
+ parent::setUpBeforeClass();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $session = $appbox->get_session();
+ $auth = new Session_Authentication_None(self::$user);
+ $session->authenticate($auth);
+ }
+ public static function tearDownAfterClass()
+ {
+ parent::tearDownAfterClass();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $session = $appbox->get_session();
+ $session->logout();
+ }
}
diff --git a/tests/Session/Authentication/Session_Authentication_GuestTest.php b/tests/Session/Authentication/Session_Authentication_GuestTest.php
index 38ae196684..fcea55fd6f 100644
--- a/tests/Session/Authentication/Session_Authentication_GuestTest.php
+++ b/tests/Session/Authentication/Session_Authentication_GuestTest.php
@@ -4,35 +4,21 @@ require_once __DIR__ . '/../../PhraseanetPHPUnitAbstract.class.inc';
class Session_Authentication_GuestTest extends PhraseanetPHPUnitAbstract
{
+ /**
+ * @var Session_Authentication_Guest
+ */
+ protected $object;
- /**
- * @var Session_Authentication_Guest
- */
- protected $object;
-
- public function setUp()
- {
- $this->object = new Session_Authentication_Guest(appbox::get_instance(\bootstrap::getCore()));
- }
-
- /**
- * Tears down the fixture, for example, closes a network connection.
- * This method is called after a test is executed.
- */
- public function tearDown()
- {
-
- }
-
- /**
- * @todo Implement testSignOn().
- */
- public function testSignOn()
- {
- $user = $this->object->signOn();
- $this->assertInstanceOf('User_Adapter', $user);
- $this->assertTrue($user->is_guest());
- }
-
+ public function setUp()
+ {
+ parent::setUp();
+ $this->object = new Session_Authentication_Guest(appbox::get_instance(\bootstrap::getCore()));
+ }
+ public function testSignOn()
+ {
+ $user = $this->object->signOn();
+ $this->assertInstanceOf('User_Adapter', $user);
+ $this->assertTrue($user->is_guest());
+ }
}
diff --git a/tests/Session/Authentication/Session_Authentication_NativeTest.php b/tests/Session/Authentication/Session_Authentication_NativeTest.php
index 02ebcd32c1..a790d04907 100644
--- a/tests/Session/Authentication/Session_Authentication_NativeTest.php
+++ b/tests/Session/Authentication/Session_Authentication_NativeTest.php
@@ -4,45 +4,40 @@ require_once __DIR__ . '/../../PhraseanetPHPUnitAbstract.class.inc';
class Session_Authentication_NativeTest extends PhraseanetPHPUnitAbstract
{
+ /**
+ * @var Session_Authentication_Native
+ */
+ protected $object;
+ protected $local_user;
- /**
- * @var Session_Authentication_Native
- */
- protected $object;
- protected $local_user;
-
- public function setUp()
- {
- $login = 'testlogin';
- $password = 'testpassword';
- $usr_id = User_Adapter::get_usr_id_from_login($login);
- if ($usr_id)
+ public function setUp()
{
- $this->local_user = User_Adapter::getInstance($usr_id, appbox::get_instance(\bootstrap::getCore()));
+ parent::setUp();
+ $login = 'testlogin';
+ $password = 'testpassword';
+ $usr_id = User_Adapter::get_usr_id_from_login($login);
+ if ($usr_id) {
+ $this->local_user = User_Adapter::getInstance($usr_id, appbox::get_instance(\bootstrap::getCore()));
+ } else {
+ $this->local_user = User_Adapter::create(appbox::get_instance(\bootstrap::getCore()), $login, $password, null, false);
+ }
+ $this->object = new Session_Authentication_Native(appbox::get_instance(\bootstrap::getCore()), $login, $password);
}
- else
+
+ public function tearDown()
{
- $this->local_user = User_Adapter::create(appbox::get_instance(\bootstrap::getCore()), $login, $password, null, false);
+ $this->local_user->delete();
+ parent::tearDown();
}
- $this->object = new Session_Authentication_Native(appbox::get_instance(\bootstrap::getCore()), $login, $password);
- }
-
- public function tearDown()
- {
- $this->local_user->delete();
- }
-
- public function testSet_captcha_challenge()
- {
- $this->object->set_captcha_challenge(false);
- }
-
-
- public function testSignOn()
- {
- $user = $this->object->signOn();
- $this->assertInstanceOf('User_Adapter', $user);
- }
+ public function testSet_captcha_challenge()
+ {
+ $this->object->set_captcha_challenge(false);
+ }
+ public function testSignOn()
+ {
+ $user = $this->object->signOn();
+ $this->assertInstanceOf('User_Adapter', $user);
+ }
}
diff --git a/tests/Session/Authentication/Session_Authentication_PersistentCookieTest.php b/tests/Session/Authentication/Session_Authentication_PersistentCookieTest.php
deleted file mode 100644
index 6b9767a4ab..0000000000
--- a/tests/Session/Authentication/Session_Authentication_PersistentCookieTest.php
+++ /dev/null
@@ -1,60 +0,0 @@
-object = new Session_Authentication_PersistentCookie;
- }
-
- /**
- * Tears down the fixture, for example, closes a network connection.
- * This method is called after a test is executed.
- */
- public function tearDown()
- {
-
- }
-
- /**
- * @todo Implement testPrelog().
- */
- public function testPrelog()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testSignOn().
- */
- public function testSignOn()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testPostlog().
- */
- public function testPostlog()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
-}
diff --git a/tests/Session/Authentication/Session_Authentication_TokenTest.php b/tests/Session/Authentication/Session_Authentication_TokenTest.php
deleted file mode 100644
index c856889be7..0000000000
--- a/tests/Session/Authentication/Session_Authentication_TokenTest.php
+++ /dev/null
@@ -1,60 +0,0 @@
-object = new Session_Authentication_Token;
- }
-
- /**
- * Tears down the fixture, for example, closes a network connection.
- * This method is called after a test is executed.
- */
- public function tearDown()
- {
-
- }
-
- /**
- * @todo Implement testPrelog().
- */
- public function testPrelog()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testSignOn().
- */
- public function testSignOn()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testPostlog().
- */
- public function testPostlog()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
-}
diff --git a/tests/Session/Session_HandlerTest.php b/tests/Session/Session_HandlerTest.php
index ad4f70106a..c676dca1e1 100644
--- a/tests/Session/Session_HandlerTest.php
+++ b/tests/Session/Session_HandlerTest.php
@@ -4,437 +4,388 @@ require_once __DIR__ . '/../PhraseanetPHPUnitAbstract.class.inc';
class Session_HandlerTest extends PhraseanetPHPUnitAbstract
{
+ /**
+ * @var Session_Handler
+ */
+ protected $object;
- /**
- * @var Session_Handler
- */
- protected $object;
-
- public function setUp()
- {
- $this->object = Session_Handler::getInstance(appbox::get_instance(\bootstrap::getCore()));
- }
-
- /**
- * Tears down the fixture, for example, closes a network connection.
- * This method is called after a test is executed.
- */
- public function tearDown()
- {
- if ($this->object->is_authenticated())
- $this->object->logout();
- }
-
- public function testGetInstance()
- {
- $this->assertInstanceOf('Session_Handler', $this->object);
- }
-
- /**
- * @todo Implement testLogout().
- */
- public function testLogout()
- {
- $user = self::$user;
- $auth = new Session_Authentication_None($user);
- $databoxes = $user->ACL()->get_granted_sbas();
-
- $this->assertFalse($this->object->is_authenticated());
- $this->object->authenticate($auth);
- $this->assertTrue($this->object->is_authenticated());
- $this->assertTrue(is_int($this->object->get_ses_id()));
-
- $ses_id = $this->object->get_ses_id();
-
- $conn = connection::getPDOConnection();
- $sql = 'SELECT session_id FROM cache WHERE session_id = :ses_id';
- $params = array(':ses_id' => $ses_id);
- $stmt = $conn->prepare($sql);
- $stmt->execute($params);
- $this->assertEquals(1, $stmt->rowCount());
-
- $loggers = array();
-
- foreach ($databoxes as $databox)
+ public function setUp()
{
- $logger = $this->object->get_logger($databox);
- $this->assertInstanceOf('Session_Logger', $logger);
- $loggers[$databox->get_sbas_id()] = $logger;
+ parent::setUp();
+ $this->object = Session_Handler::getInstance(appbox::get_instance(\bootstrap::getCore()));
}
- $this->object->logout();
- $this->assertFalse($this->object->is_authenticated());
-
- $stmt->execute($params);
- $this->assertEquals(0, $stmt->rowCount());
- $stmt->closeCursor();
-
-
- foreach ($databoxes as $databox)
- {
-
- $logger = $this->object->get_logger($databox);
- $this->assertInstanceOf('Session_Logger', $logger);
- $this->assertNotEquals($loggers[$databox->get_sbas_id()]->get_id(), $logger->get_id());
- }
- }
-
- /**
- * @todo Implement testStorage().
- */
- public function testStorage()
- {
- $this->assertInstanceOf('Session_Storage_Interface', $this->object->storage());
- }
-
- /**
- * @todo Implement testClose_storage().
- */
- public function testClose_storage()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
-
- /**
- * @todo Implement testGet_locale().
- */
- public function testGet_locale()
- {
- $this->assertRegExp('/[a-z]{2}_[A-Z]{2}/', Session_Handler::get_locale());
- }
-
- /**
- * @todo Implement testSet_locale().
- */
- public function testSet_locale()
- {
- Session_Handler::set_locale('fr_FR');
- $this->assertEquals('fr_FR', Session_Handler::get_locale());
- Session_Handler::set_locale('en_GB');
- $this->assertEquals('en_GB', Session_Handler::get_locale());
- }
-
- /**
- * @todo Implement testGet_l10n().
- */
- public function testGet_l10n()
- {
- Session_Handler::set_locale('fr_FR');
- $this->assertEquals('FR', $this->object->get_l10n());
- Session_Handler::set_locale('en_GB');
- $this->assertEquals('GB', $this->object->get_l10n());
- }
-
- /**
- * @todo Implement testGet_I18n().
- */
- public function testGet_I18n()
- {
- Session_Handler::set_locale('fr_FR');
- $this->assertEquals('fr', $this->object->get_I18n());
- Session_Handler::set_locale('en_GB');
- $this->assertEquals('en', $this->object->get_I18n());
- }
-
- /**
- * @todo Implement testIs_authenticated().
- */
- public function testIs_authenticated()
- {
- $user = self::$user;
- $auth = new Session_Authentication_None($user);
- $this->assertFalse($this->object->is_authenticated());
- $this->object->authenticate($auth);
- $this->assertTrue($this->object->is_authenticated());
- $this->object->logout();
- $this->assertFalse($this->object->is_authenticated());
- }
-
- /**
- * @todo Implement testGet_usr_id().
- */
- public function testGet_usr_id()
- {
- $this->assertNull($this->object->get_usr_id());
-
- $user = self::$user;
- $auth = new Session_Authentication_None($user);
- $this->object->authenticate($auth);
-
- $this->assertTrue(is_int($this->object->get_usr_id()));
- $this->assertEquals($user->get_id(), $this->object->get_usr_id());
-
- $this->object->logout();
- $this->assertNull($this->object->get_usr_id());
- }
-
- /**
- * @todo Implement testGet_ses_id().
- */
- public function testGet_ses_id()
- {
- $this->assertNull($this->object->get_ses_id());
-
- $user = self::$user;
- $auth = new Session_Authentication_None($user);
- $this->object->authenticate($auth);
-
- $this->assertTrue(is_int($this->object->get_ses_id()));
-
- $this->object->logout();
- $this->assertNull($this->object->get_ses_id());
- }
-
- /**
- * @todo Implement testIsset_postlog().
- */
- public function testIsset_postlog()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testSet_postlog().
- */
- public function testSet_postlog()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_postlog().
- */
- public function testGet_postlog()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testDelete_postlog().
- */
- public function testDelete_postlog()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testSet_session_prefs().
- */
- public function testSet_session_prefs()
- {
- $datas = array('bla' => 1, 2 => 'boum');
- $this->object->set_session_prefs('test', $datas);
- $this->assertEquals($datas, $this->object->get_session_prefs('test'));
- }
-
- /**
- * @todo Implement testGet_session_prefs().
- */
- public function testGet_session_prefs()
- {
- $this->testSet_session_prefs();
- }
-
- /**
- * @todo Implement testGet_cookie().
- */
- public function testGet_cookie()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testSet_cookie().
- */
- public function testSet_cookie()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testIsset_cookie().
- */
- public function testIsset_cookie()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testOpen_phrasea_session().
- */
- public function testOpen_phrasea_session()
- {
- try
- {
- $this->object->open_phrasea_session();
- $this->fail();
- }
- catch (Exception_Session_Closed $e)
+ /**
+ * Tears down the fixture, for example, closes a network connection.
+ * This method is called after a test is executed.
+ */
+ public function tearDown()
{
+ if ($this->object->is_authenticated()) {
+ $this->object->logout();
+ }
+ parent::tearDown();
}
- $user = self::$user;
- $auth = new Session_Authentication_None($user);
- $this->object->authenticate($auth);
-
- $this->object->open_phrasea_session();
-
- $this->object->logout();
-
- try
+ public function testGetInstance()
{
- $this->object->open_phrasea_session();
- $this->fail();
- }
- catch (Exception_Session_Closed $e)
- {
-
- }
- }
-
- /**
- * @todo Implement testRestore().
- */
- public function testRestore()
- {
- $user = self::$user;
- $auth = new Session_Authentication_None($user);
- $this->object->authenticate($auth);
-
- $ses_id = $this->object->get_ses_id();
- $this->object->storage()->reset();
-
- $this->assertFalse($this->object->is_authenticated());
-
- $this->object->restore($user, $ses_id);
-
- $this->assertTrue($this->object->is_authenticated());
-
- $databoxes = $user->ACL()->get_granted_sbas();
- foreach ($databoxes as $databox)
- {
- $this->assertInstanceOf('Session_Logger', $this->object->get_logger($databox));
+ $this->assertInstanceOf('Session_Handler', $this->object);
}
- }
-
- /**
- * @todo Implement testAuthenticate().
- */
- public function testAuthenticate()
- {
- $user = self::$user;
- $auth = new Session_Authentication_None($user);
- $this->object->authenticate($auth);
-
- $registry = registry::get_instance();
-
-
- foreach($user->ACL()->get_granted_sbas() as $databox)
+ /**
+ * @todo Implement testLogout().
+ */
+ public function testLogout()
{
- $sql = 'SELECT usr_id FROM collusr WHERE site = :site AND usr_id = :usr_id AND coll_id = :coll_id';
- $stmt = $databox->get_connection()->prepare($sql);
+ $user = self::$user;
+ $auth = new Session_Authentication_None($user);
+ $databoxes = $user->ACL()->get_granted_sbas();
- foreach($user->ACL()->get_granted_base(array(), array($databox->get_sbas_id())) as $collection)
- {
- $stmt->execute(array(':site'=>$registry->get('GV_sit'),':usr_id'=>$user->get_id(), ':coll_id'=>$collection->get_coll_id()));
+ $this->assertFalse($this->object->is_authenticated());
+ $this->object->authenticate($auth);
+ $this->assertTrue($this->object->is_authenticated());
+ $this->assertTrue(is_int($this->object->get_ses_id()));
+
+ $ses_id = $this->object->get_ses_id();
+
+ $conn = connection::getPDOConnection();
+ $sql = 'SELECT session_id FROM cache WHERE session_id = :ses_id';
+ $params = array(':ses_id' => $ses_id);
+ $stmt = $conn->prepare($sql);
+ $stmt->execute($params);
$this->assertEquals(1, $stmt->rowCount());
- }
- $stmt->closeCursor();
+ $loggers = array();
+
+ foreach ($databoxes as $databox) {
+ $logger = $this->object->get_logger($databox);
+ $this->assertInstanceOf('Session_Logger', $logger);
+ $loggers[$databox->get_sbas_id()] = $logger;
+ }
+
+ $this->object->logout();
+ $this->assertFalse($this->object->is_authenticated());
+
+ $stmt->execute($params);
+ $this->assertEquals(0, $stmt->rowCount());
+ $stmt->closeCursor();
+
+
+ foreach ($databoxes as $databox) {
+
+ $logger = $this->object->get_logger($databox);
+ $this->assertInstanceOf('Session_Logger', $logger);
+ $this->assertNotEquals($loggers[$databox->get_sbas_id()]->get_id(), $logger->get_id());
+ }
}
- $this->object->logout();
-
- }
-
- /**
- * @todo Implement testAdd_persistent_cookie().
- */
- public function testAdd_persistent_cookie()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_logger().
- */
- public function testGet_logger()
- {
- $user = self::$user;
- $auth = new Session_Authentication_None($user);
- $databoxes = $user->ACL()->get_granted_sbas();
-
- $this->object->authenticate($auth);
- $this->assertTrue($this->object->is_authenticated());
-
- foreach ($databoxes as $databox)
+ /**
+ * @todo Implement testStorage().
+ */
+ public function testStorage()
{
- $this->assertInstanceOf('Session_Logger', $this->object->get_logger($databox));
+ $this->assertInstanceOf('Session_Storage_Interface', $this->object->storage());
}
- $this->assertTrue(is_int($this->object->get_logger($databox)->get_id()));
- }
- /**
- * @todo Implement testGet_my_sessions().
- */
- public function testGet_my_sessions()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
+ /**
+ * @todo Implement testClose_storage().
+ */
+ public function testClose_storage()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
'This test has not been implemented yet.'
- );
- }
+ );
+ }
- /**
- * @todo Implement testSet_event_module().
- */
- public function testSet_event_module()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
+ /**
+ * @todo Implement testGet_locale().
+ */
+ public function testGet_locale()
+ {
+ $this->assertRegExp('/[a-z]{2}_[A-Z]{2}/', Session_Handler::get_locale());
+ }
+
+ public function testSet_locale()
+ {
+ Session_Handler::set_locale('fr_FR');
+ $this->assertEquals('fr_FR', Session_Handler::get_locale());
+ Session_Handler::set_locale('en_GB');
+ $this->assertEquals('en_GB', Session_Handler::get_locale());
+ }
+
+ public function testGet_l10n()
+ {
+ Session_Handler::set_locale('fr_FR');
+ $this->assertEquals('FR', $this->object->get_l10n());
+ Session_Handler::set_locale('en_GB');
+ $this->assertEquals('GB', $this->object->get_l10n());
+ }
+
+ public function testGet_I18n()
+ {
+ Session_Handler::set_locale('fr_FR');
+ $this->assertEquals('fr', $this->object->get_I18n());
+ Session_Handler::set_locale('en_GB');
+ $this->assertEquals('en', $this->object->get_I18n());
+ }
+
+ public function testIs_authenticated()
+ {
+ $user = self::$user;
+ $auth = new Session_Authentication_None($user);
+ $this->assertFalse($this->object->is_authenticated());
+ $this->object->authenticate($auth);
+ $this->assertTrue($this->object->is_authenticated());
+ $this->object->logout();
+ $this->assertFalse($this->object->is_authenticated());
+ }
+
+ public function testGet_usr_id()
+ {
+ $this->assertNull($this->object->get_usr_id());
+
+ $user = self::$user;
+ $auth = new Session_Authentication_None($user);
+ $this->object->authenticate($auth);
+
+ $this->assertTrue(is_int($this->object->get_usr_id()));
+ $this->assertEquals($user->get_id(), $this->object->get_usr_id());
+
+ $this->object->logout();
+ $this->assertNull($this->object->get_usr_id());
+ }
+
+ public function testGet_ses_id()
+ {
+ $this->assertNull($this->object->get_ses_id());
+
+ $user = self::$user;
+ $auth = new Session_Authentication_None($user);
+ $this->object->authenticate($auth);
+
+ $this->assertTrue(is_int($this->object->get_ses_id()));
+
+ $this->object->logout();
+ $this->assertNull($this->object->get_ses_id());
+ }
+
+ /**
+ * @todo Implement testIsset_postlog().
+ */
+ public function testIsset_postlog()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
'This test has not been implemented yet.'
- );
- }
+ );
+ }
- /**
- * @todo Implement testGet_active_sessions().
- */
- public function testGet_active_sessions()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
+ /**
+ * @todo Implement testSet_postlog().
+ */
+ public function testSet_postlog()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
'This test has not been implemented yet.'
- );
- }
+ );
+ }
+ /**
+ * @todo Implement testGet_postlog().
+ */
+ public function testGet_postlog()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ /**
+ * @todo Implement testDelete_postlog().
+ */
+ public function testDelete_postlog()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ public function testSet_session_prefs()
+ {
+ $datas = array('bla' => 1, 2 => 'boum');
+ $this->object->set_session_prefs('test', $datas);
+ $this->assertEquals($datas, $this->object->get_session_prefs('test'));
+ }
+
+ public function testGet_session_prefs()
+ {
+ $this->testSet_session_prefs();
+ }
+
+ /**
+ * @todo Implement testGet_cookie().
+ */
+ public function testGet_cookie()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ /**
+ * @todo Implement testSet_cookie().
+ */
+ public function testSet_cookie()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ /**
+ * @todo Implement testIsset_cookie().
+ */
+ public function testIsset_cookie()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ public function testOpen_phrasea_session()
+ {
+ try {
+ $this->object->open_phrasea_session();
+ $this->fail();
+ } catch (Exception_Session_Closed $e) {
+
+ }
+
+ $user = self::$user;
+ $auth = new Session_Authentication_None($user);
+ $this->object->authenticate($auth);
+
+ $this->object->open_phrasea_session();
+
+ $this->object->logout();
+
+ try {
+ $this->object->open_phrasea_session();
+ $this->fail();
+ } catch (Exception_Session_Closed $e) {
+
+ }
+ }
+
+ public function testRestore()
+ {
+ $user = self::$user;
+ $auth = new Session_Authentication_None($user);
+ $this->object->authenticate($auth);
+
+ $ses_id = $this->object->get_ses_id();
+ $this->object->storage()->reset();
+
+ $this->assertFalse($this->object->is_authenticated());
+
+ $this->object->restore($user, $ses_id);
+
+ $this->assertTrue($this->object->is_authenticated());
+
+ $databoxes = $user->ACL()->get_granted_sbas();
+ foreach ($databoxes as $databox) {
+ $this->assertInstanceOf('Session_Logger', $this->object->get_logger($databox));
+ }
+ }
+
+ public function testAuthenticate()
+ {
+ $user = self::$user;
+ $auth = new Session_Authentication_None($user);
+ $this->object->authenticate($auth);
+
+ $registry = registry::get_instance();
+
+
+ foreach ($user->ACL()->get_granted_sbas() as $databox) {
+ $sql = 'SELECT usr_id FROM collusr WHERE site = :site AND usr_id = :usr_id AND coll_id = :coll_id';
+ $stmt = $databox->get_connection()->prepare($sql);
+
+ foreach ($user->ACL()->get_granted_base(array(), array($databox->get_sbas_id())) as $collection) {
+ $stmt->execute(array(':site' => $registry->get('GV_sit'), ':usr_id' => $user->get_id(), ':coll_id' => $collection->get_coll_id()));
+ $this->assertEquals(1, $stmt->rowCount());
+ }
+
+ $stmt->closeCursor();
+ }
+
+ $this->object->logout();
+ }
+
+ /**
+ * @todo Implement testAdd_persistent_cookie().
+ */
+ public function testAdd_persistent_cookie()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ public function testGet_logger()
+ {
+ $user = self::$user;
+ $auth = new Session_Authentication_None($user);
+ $databoxes = $user->ACL()->get_granted_sbas();
+
+ $this->object->authenticate($auth);
+ $this->assertTrue($this->object->is_authenticated());
+
+ foreach ($databoxes as $databox) {
+ $this->assertInstanceOf('Session_Logger', $this->object->get_logger($databox));
+ }
+ $this->assertTrue(is_int($this->object->get_logger($databox)->get_id()));
+ }
+
+ /**
+ * @todo Implement testGet_my_sessions().
+ */
+ public function testGet_my_sessions()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ /**
+ * @todo Implement testSet_event_module().
+ */
+ public function testSet_event_module()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ /**
+ * @todo Implement testGet_active_sessions().
+ */
+ public function testGet_active_sessions()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
}
diff --git a/tests/Session/Session_LoggerTest.php b/tests/Session/Session_LoggerTest.php
index 6cf70d034c..c4938b7d02 100644
--- a/tests/Session/Session_LoggerTest.php
+++ b/tests/Session/Session_LoggerTest.php
@@ -4,99 +4,82 @@ require_once __DIR__ . '/../PhraseanetPHPUnitAbstract.class.inc';
class Session_LoggerTest extends PhraseanetPHPUnitAbstract
{
+ /**
+ * @var Session_Logger
+ */
+ protected $object;
- /**
- * @var Session_Logger
- */
- protected $object;
- /**
- *
- * @var Session_Handler
- */
- protected $session;
- /**
- *
- * @var databox
- */
- protected $databox;
+ /**
+ *
+ * @var Session_Handler
+ */
+ protected $session;
- public function setUp()
- {
+ /**
+ *
+ * @var databox
+ */
+ protected $databox;
- }
-
- /**
- * Tears down the fixture, for example, closes a network connection.
- * This method is called after a test is executed.
- */
- public function tearDown()
- {
-
- }
-
- protected function feed_datas()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $this->session = $appbox->get_session();
- $user = self::$user;
- $auth = new Session_Authentication_None($user);
-
-
-
- $this->session->authenticate($auth);
-
- foreach ($user->ACL()->get_granted_sbas() as $databox)
+ protected function feed_datas()
{
- $this->object = $this->session->get_logger($databox);
- $this->databox = $databox;
- break;
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $this->session = $appbox->get_session();
+ $user = self::$user;
+ $auth = new Session_Authentication_None($user);
+
+
+
+ $this->session->authenticate($auth);
+
+ foreach ($user->ACL()->get_granted_sbas() as $databox) {
+ $this->object = $this->session->get_logger($databox);
+ $this->databox = $databox;
+ break;
+ }
+ if ( ! $this->object instanceof Session_Logger)
+ $this->fail('Not enough datas to test');
}
- if (!$this->object instanceof Session_Logger)
- $this->fail('Not enough datas to test');
- }
- public function testGet_id()
- {
- $this->feed_datas();
- $log_id = $this->object->get_id();
- $this->assertTrue(is_int($log_id));
+ public function testGet_id()
+ {
+ $this->feed_datas();
+ $log_id = $this->object->get_id();
+ $this->assertTrue(is_int($log_id));
- $registry = registry::get_instance();
+ $registry = registry::get_instance();
- $sql = 'SELECT id FROM log
+ $sql = 'SELECT id FROM log
WHERE sit_session = :ses_id AND usrid = :usr_id AND site = :site';
- $params = array(
- ':ses_id' => $this->session->get_ses_id()
- , ':usr_id' => $this->session->get_usr_id()
- , ':site' => $registry->get('GV_sit')
- );
+ $params = array(
+ ':ses_id' => $this->session->get_ses_id()
+ , ':usr_id' => $this->session->get_usr_id()
+ , ':site' => $registry->get('GV_sit')
+ );
- $stmt = $this->databox->get_connection()->prepare($sql);
- $stmt->execute($params);
- $this->assertEquals(1, $stmt->rowCount());
- $row = $stmt->fetch(PDO::FETCH_ASSOC);
- $this->assertEquals($this->object->get_id(), $row['id']);
- $log_id = $this->object->get_id();
- $ses_id = $this->session->get_ses_id();
- $usr_id = $this->session->get_usr_id();
+ $stmt = $this->databox->get_connection()->prepare($sql);
+ $stmt->execute($params);
+ $this->assertEquals(1, $stmt->rowCount());
+ $row = $stmt->fetch(PDO::FETCH_ASSOC);
+ $this->assertEquals($this->object->get_id(), $row['id']);
+ $log_id = $this->object->get_id();
+ $ses_id = $this->session->get_ses_id();
+ $usr_id = $this->session->get_usr_id();
- $this->session->logout();
+ $this->session->logout();
- $sql = 'SELECT id FROM log
+ $sql = 'SELECT id FROM log
WHERE sit_session = :ses_id AND usrid = :usr_id AND site = :site';
- $params = array(
- ':ses_id' => $ses_id
- , ':usr_id' => $usr_id
- , ':site' => $registry->get('GV_sit')
- );
-
- $stmt = $this->databox->get_connection()->prepare($sql);
- $stmt->execute($params);
- $this->assertEquals(1, $stmt->rowCount());
- $row = $stmt->fetch(PDO::FETCH_ASSOC);
- $this->assertEquals($log_id, $row['id']);
-
- }
+ $params = array(
+ ':ses_id' => $ses_id
+ , ':usr_id' => $usr_id
+ , ':site' => $registry->get('GV_sit')
+ );
+ $stmt = $this->databox->get_connection()->prepare($sql);
+ $stmt->execute($params);
+ $this->assertEquals(1, $stmt->rowCount());
+ $row = $stmt->fetch(PDO::FETCH_ASSOC);
+ $this->assertEquals($log_id, $row['id']);
+ }
}
-
diff --git a/tests/Session/Session_PhraseaTest.php b/tests/Session/Session_PhraseaTest.php
deleted file mode 100644
index 1543c7e994..0000000000
--- a/tests/Session/Session_PhraseaTest.php
+++ /dev/null
@@ -1,105 +0,0 @@
-object = new Session_Phrasea;
- }
-
- /**
- * Tears down the fixture, for example, closes a network connection.
- * This method is called after a test is executed.
- */
- public function tearDown()
- {
-
- }
-
- /**
- * @todo Implement testGet_id().
- */
- public function testGet_id()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testCreate().
- */
- public function testCreate()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
-
- /**
- * @todo Implement testOpen().
- */
- public function testOpen()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testRestore().
- */
- public function testRestore()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testClose().
- */
- public function testClose()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_actives_by_usr_id().
- */
- public function testGet_actives_by_usr_id()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_actives().
- */
- public function testGet_actives()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
-}
diff --git a/tests/Session/Storage/Session_Storage_CommandLineTest.php b/tests/Session/Storage/Session_Storage_CommandLineTest.php
deleted file mode 100644
index 184364a8e7..0000000000
--- a/tests/Session/Storage/Session_Storage_CommandLineTest.php
+++ /dev/null
@@ -1,115 +0,0 @@
-object = new Session_Storage_CommandLine;
- }
-
- /**
- * Tears down the fixture, for example, closes a network connection.
- * This method is called after a test is executed.
- */
- public function tearDown()
- {
-
- }
-
- /**
- * @todo Implement testGetInstance().
- */
- public function testGetInstance()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet().
- */
- public function testGet()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testHas().
- */
- public function testHas()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testSet().
- */
- public function testSet()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testRemove().
- */
- public function testRemove()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGetName().
- */
- public function testGetName()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGetId().
- */
- public function testGetId()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testDestroy().
- */
- public function testDestroy()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
-}
diff --git a/tests/Session/Storage/Session_Storage_PHPSessionTest.php b/tests/Session/Storage/Session_Storage_PHPSessionTest.php
deleted file mode 100644
index 846c4d4abb..0000000000
--- a/tests/Session/Storage/Session_Storage_PHPSessionTest.php
+++ /dev/null
@@ -1,126 +0,0 @@
-object = new Session_Storage_PHPSession;
- }
-
- /**
- * Tears down the fixture, for example, closes a network connection.
- * This method is called after a test is executed.
- */
- public function tearDown()
- {
-
- }
-
- /**
- * @todo Implement testGetInstance().
- */
- public function testGetInstance()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testClose().
- */
- public function testClose()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testHas().
- */
- public function testHas()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet().
- */
- public function testGet()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testSet().
- */
- public function testSet()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testRemove().
- */
- public function testRemove()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGetName().
- */
- public function testGetName()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGetId().
- */
- public function testGetId()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testDestroy().
- */
- public function testDestroy()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
-}
diff --git a/tests/Setup/Setup_ConstraintTest.php b/tests/Setup/Setup_ConstraintTest.php
index abee695fc9..5f9c9d1a22 100644
--- a/tests/Setup/Setup_ConstraintTest.php
+++ b/tests/Setup/Setup_ConstraintTest.php
@@ -4,41 +4,39 @@ require_once __DIR__ . '/../PhraseanetPHPUnitAbstract.class.inc';
class Setup_ConstraintTest extends PhraseanetPHPUnitAbstract
{
+ protected $object_non_blocker;
+ protected $object_blocker;
+ protected $message = "&é'(§è!çà dfljk sdq'";
+ protected $name = "Un joli nom";
- protected $object_non_blocker;
- protected $object_blocker;
- protected $message = "&é'(§è!çà dfljk sdq'";
- protected $name = "Un joli nom";
+ public function setUp()
+ {
+ parent::setUp();
+ $this->object_non_blocker = new Setup_Constraint($this->name, true, $this->message, false);
+ $this->object_blocker = new Setup_Constraint($this->name, false, $this->message, true);
+ }
- public function setUp()
- {
- $this->object_non_blocker = new Setup_Constraint($this->name, true, $this->message, false);
- $this->object_blocker = new Setup_Constraint($this->name, false, $this->message, true);
- }
+ public function testGet_name()
+ {
+ $this->assertEquals($this->name, $this->object_blocker->get_name());
+ $this->assertEquals($this->name, $this->object_non_blocker->get_name());
+ }
- public function testGet_name()
- {
- $this->assertEquals($this->name, $this->object_blocker->get_name());
- $this->assertEquals($this->name, $this->object_non_blocker->get_name());
- }
+ public function testIs_ok()
+ {
+ $this->assertFalse($this->object_blocker->is_ok());
+ $this->assertTrue($this->object_non_blocker->is_ok());
+ }
- public function testIs_ok()
- {
- $this->assertFalse($this->object_blocker->is_ok());
- $this->assertTrue($this->object_non_blocker->is_ok());
- }
-
- public function testIs_blocker()
- {
- $this->assertTrue($this->object_blocker->is_blocker());
- $this->assertFalse($this->object_non_blocker->is_blocker());
- }
-
- public function testGet_message()
- {
- $this->assertEquals($this->message, $this->object_blocker->get_message());
- $this->assertEquals($this->message, $this->object_non_blocker->get_message());
- }
+ public function testIs_blocker()
+ {
+ $this->assertTrue($this->object_blocker->is_blocker());
+ $this->assertFalse($this->object_non_blocker->is_blocker());
+ }
+ public function testGet_message()
+ {
+ $this->assertEquals($this->message, $this->object_blocker->get_message());
+ $this->assertEquals($this->message, $this->object_non_blocker->get_message());
+ }
}
-
diff --git a/tests/Setup/Setup_UpgradeTest.php b/tests/Setup/Setup_UpgradeTest.php
index eb1aaba5b4..362c320a2e 100644
--- a/tests/Setup/Setup_UpgradeTest.php
+++ b/tests/Setup/Setup_UpgradeTest.php
@@ -4,90 +4,90 @@ require_once __DIR__ . '/../PhraseanetPHPUnitAbstract.class.inc';
class Setup_UpgradeTest extends PhraseanetPHPUnitAbstract
{
+ /**
+ * @var Setup_Upgrade
+ */
+ protected $object;
- /**
- * @var Setup_Upgrade
- */
- protected $object;
+ public function setUp()
+ {
+ parent::setUp();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $this->object = new Setup_Upgrade($appbox);
+ }
- public function setUp()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $this->object = new Setup_Upgrade($appbox);
- }
+ public function tearDown()
+ {
+ unset($this->object);
+ parent::tearDown();
+ }
- public function tearDown()
- {
- unset($this->object);
- }
+ public function test__destruct()
+ {
+ $this->assertFileExists(Setup_Upgrade::get_lock_file());
+ unset($this->object);
+ $this->assertFileNotExists(Setup_Upgrade::get_lock_file());
+ }
- public function test__destruct()
- {
- $this->assertFileExists(Setup_Upgrade::get_lock_file());
- unset($this->object);
- $this->assertFileNotExists(Setup_Upgrade::get_lock_file());
- }
+ public function testAdd_steps()
+ {
+ $this->check_percentage(1, 0, 0);
+ $this->object->add_steps(1);
+ $this->check_percentage(0, 1, 0);
+ $this->object->add_steps('lsdf');
+ $this->check_percentage(0, 1, 0);
+ $this->object->add_steps(20);
+ $this->check_percentage(0, 21, 0);
+ $this->object->add_steps(-5);
+ $this->check_percentage(0, 16, 0);
+ }
- public function testAdd_steps()
- {
- $this->check_percentage(1, 0, 0);
- $this->object->add_steps(1);
- $this->check_percentage(0, 1, 0);
- $this->object->add_steps('lsdf');
- $this->check_percentage(0, 1, 0);
- $this->object->add_steps(20);
- $this->check_percentage(0, 21, 0);
- $this->object->add_steps(-5);
- $this->check_percentage(0, 16, 0);
- }
+ protected function check_percentage($percent, $total, $complete)
+ {
+ $datas = $this->object->get_status();
+ $this->assertArrayHasKey('completed_steps', $datas);
+ $this->assertArrayHasKey('total_steps', $datas);
+ $this->assertArrayHasKey('percentage', $datas);
+ $this->assertArrayHasKey('last_update', $datas);
+ $this->assertDateAtom($datas['last_update']);
+ $this->assertEquals($percent, $datas['percentage']);
+ $this->assertEquals($total, $datas['total_steps']);
+ $this->assertEquals($complete, $datas['completed_steps']);
+ }
- protected function check_percentage($percent, $total, $complete)
- {
- $datas = $this->object->get_status();
- $this->assertArrayHasKey('completed_steps', $datas);
- $this->assertArrayHasKey('total_steps', $datas);
- $this->assertArrayHasKey('percentage', $datas);
- $this->assertArrayHasKey('last_update', $datas);
- $this->assertDateAtom($datas['last_update']);
- $this->assertEquals($percent, $datas['percentage']);
- $this->assertEquals($total, $datas['total_steps']);
- $this->assertEquals($complete, $datas['completed_steps']);
- }
+ public function testAdd_steps_complete()
+ {
+ $this->check_percentage(1, 0, 0);
+ $this->object->add_steps(1)->add_steps_complete(1);
+ $this->check_percentage(1, 1, 1);
+ $this->object->add_steps(20)->add_steps_complete(20);
+ $this->check_percentage(1, 21, 21);
+ $this->object->add_steps(20);
+ $this->check_percentage(round(21 / 41, 2), 41, 21);
+ $this->object->add_steps_complete(40);
+ $this->check_percentage(1, 41, 61);
+ }
- public function testAdd_steps_complete()
- {
- $this->check_percentage(1, 0, 0);
- $this->object->add_steps(1)->add_steps_complete(1);
- $this->check_percentage(1, 1, 1);
- $this->object->add_steps(20)->add_steps_complete(20);
- $this->check_percentage(1, 21, 21);
- $this->object->add_steps(20);
- $this->check_percentage(round(21 / 41, 2), 41, 21);
- $this->object->add_steps_complete(40);
- $this->check_percentage(1, 41, 61);
- }
+ public function testSet_current_message()
+ {
+ $message = 'ZOubid èèè\\';
+ $this->object->set_current_message($message);
- public function testSet_current_message()
- {
- $message = 'ZOubid èèè\\';
- $this->object->set_current_message($message);
-
- $datas = $this->object->get_status();
- $this->assertArrayHasKey('message', $datas);
- $this->assertEquals($message, $datas['message']);
- }
-
- public function testGet_status()
- {
- $datas = $this->object->get_status();
- $this->assertTrue(is_array($datas));
- $this->assertArrayHasKey('active', $datas);
- $this->assertArrayHasKey('percentage', $datas);
- $this->assertArrayHasKey('total_steps', $datas);
- $this->assertArrayHasKey('completed_steps', $datas);
- $this->assertArrayHasKey('message', $datas);
- $this->assertArrayHasKey('last_update', $datas);
- $this->assertDateAtom($datas['last_update']);
- }
+ $datas = $this->object->get_status();
+ $this->assertArrayHasKey('message', $datas);
+ $this->assertEquals($message, $datas['message']);
+ }
+ public function testGet_status()
+ {
+ $datas = $this->object->get_status();
+ $this->assertTrue(is_array($datas));
+ $this->assertArrayHasKey('active', $datas);
+ $this->assertArrayHasKey('percentage', $datas);
+ $this->assertArrayHasKey('total_steps', $datas);
+ $this->assertArrayHasKey('completed_steps', $datas);
+ $this->assertArrayHasKey('message', $datas);
+ $this->assertArrayHasKey('last_update', $datas);
+ $this->assertDateAtom($datas['last_update']);
+ }
}
diff --git a/tests/api/oauthv2/API_OAuth2_AuthCodeTest.php b/tests/api/oauthv2/API_OAuth2_AuthCodeTest.php
index dde8e57327..d31a14c77b 100644
--- a/tests/api/oauthv2/API_OAuth2_AuthCodeTest.php
+++ b/tests/api/oauthv2/API_OAuth2_AuthCodeTest.php
@@ -4,77 +4,77 @@ require_once __DIR__ . '/../../PhraseanetPHPUnitAbstract.class.inc';
class API_OAuth2_AuthCodeTest extends PhraseanetPHPUnitAbstract
{
+ /**
+ * @var API_OAuth2_AuthCode
+ */
+ protected $object;
+ protected $code;
+ protected $application;
+ protected $account;
- /**
- * @var API_OAuth2_AuthCode
- */
- protected $object;
- protected $code;
- protected $application;
- protected $account;
+ public function setUp()
+ {
+ parent::setUp();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $this->application = API_OAuth2_Application::create($appbox, self::$user, 'test app');
+ $this->account = API_OAuth2_Account::load_with_user($appbox, $this->application, self::$user);
- public function setUp()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $this->application = API_OAuth2_Application::create($appbox, self::$user, 'test app');
- $this->account = API_OAuth2_Account::load_with_user($appbox, $this->application, self::$user);
+ $expires = time() + 100;
+ $this->code = random::generatePassword(8);
- $expires = time() + 100;
- $this->code = random::generatePassword(8);
+ $this->object = API_OAuth2_AuthCode::create($appbox, $this->account, $this->code, $expires);
+ }
- $this->object = API_OAuth2_AuthCode::create($appbox, $this->account, $this->code, $expires);
- }
+ public function tearDown()
+ {
+ $this->application->delete();
+ parent::tearDown();
+ }
- public function tearDown()
- {
- $this->application->delete();
- }
+ public function testGet_code()
+ {
+ $this->assertEquals($this->code, $this->object->get_code());
+ }
- public function testGet_code()
- {
- $this->assertEquals($this->code, $this->object->get_code());
- }
+ public function testGet_account()
+ {
+ $this->assertInstanceOf('API_OAuth2_Account', $this->object->get_account());
+ }
- public function testGet_account()
- {
- $this->assertInstanceOf('API_OAuth2_Account', $this->object->get_account());
- }
+ public function testGet_redirect_uri()
+ {
+ $this->assertEquals('', $this->object->get_redirect_uri());
+ }
- public function testGet_redirect_uri()
- {
- $this->assertEquals('', $this->object->get_redirect_uri());
- }
+ public function testSet_redirect_uri()
+ {
+ $redirect_uri = 'https://www.google.com';
+ $this->assertEquals('', $this->object->get_redirect_uri());
+ $this->object->set_redirect_uri($redirect_uri);
+ $this->assertEquals($redirect_uri, $this->object->get_redirect_uri());
+ }
- public function testSet_redirect_uri()
- {
- $redirect_uri = 'https://www.google.com';
- $this->assertEquals('', $this->object->get_redirect_uri());
- $this->object->set_redirect_uri($redirect_uri);
- $this->assertEquals($redirect_uri, $this->object->get_redirect_uri());
- }
+ public function testGet_expires()
+ {
+ $this->assertInternalType('string', $this->object->get_expires());
+ }
- public function testGet_expires()
- {
- $this->assertInternalType('string', $this->object->get_expires());
- }
+ public function testGet_scope()
+ {
+ $this->assertEquals('', $this->object->get_scope());
+ }
- public function testGet_scope()
- {
- $this->assertEquals('', $this->object->get_scope());
- }
-
- public function testSet_scope()
- {
- $scope = 'prout';
- $this->assertEquals('', $this->object->get_scope());
- $this->object->set_scope($scope);
- $this->assertEquals($scope, $this->object->get_scope());
- }
-
- public function testLoad_codes_by_account()
- {
- $this->assertTrue(is_array(API_OAuth2_AuthCode::load_codes_by_account(appbox::get_instance(\bootstrap::getCore()), $this->account)));
- $this->assertTrue(count(API_OAuth2_AuthCode::load_codes_by_account(appbox::get_instance(\bootstrap::getCore()), $this->account)) > 0);
- }
+ public function testSet_scope()
+ {
+ $scope = 'prout';
+ $this->assertEquals('', $this->object->get_scope());
+ $this->object->set_scope($scope);
+ $this->assertEquals($scope, $this->object->get_scope());
+ }
+ public function testLoad_codes_by_account()
+ {
+ $this->assertTrue(is_array(API_OAuth2_AuthCode::load_codes_by_account(appbox::get_instance(\bootstrap::getCore()), $this->account)));
+ $this->assertTrue(count(API_OAuth2_AuthCode::load_codes_by_account(appbox::get_instance(\bootstrap::getCore()), $this->account)) > 0);
+ }
}
diff --git a/tests/api/oauthv2/API_OAuth2_RefreshTokenTest.php b/tests/api/oauthv2/API_OAuth2_RefreshTokenTest.php
index b2354306ee..47499a38bd 100644
--- a/tests/api/oauthv2/API_OAuth2_RefreshTokenTest.php
+++ b/tests/api/oauthv2/API_OAuth2_RefreshTokenTest.php
@@ -4,103 +4,103 @@ require_once __DIR__ . '/../../PhraseanetPHPUnitAbstract.class.inc';
class API_OAuth2_RefreshTokenTest extends PhraseanetPHPUnitAbstract
{
+ /**
+ * @var API_OAuth2_RefreshToken
+ */
+ protected $object;
+ protected $token;
+ protected $scope;
+ protected $application;
+ protected $account;
- /**
- * @var API_OAuth2_RefreshToken
- */
- protected $object;
- protected $token;
- protected $scope;
- protected $application;
- protected $account;
+ public function setUp()
+ {
+ parent::setUp();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $this->application = API_OAuth2_Application::create($appbox, self::$user, 'test app');
+ $this->account = API_OAuth2_Account::load_with_user($appbox, $this->application, self::$user);
- public function setUp()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $this->application = API_OAuth2_Application::create($appbox, self::$user, 'test app');
- $this->account = API_OAuth2_Account::load_with_user($appbox, $this->application, self::$user);
+ $expires = time() + 100;
+ $this->token = random::generatePassword(8);
+ $this->scope = 'scopidou';
- $expires = time() + 100;
- $this->token = random::generatePassword(8);
- $this->scope = 'scopidou';
+ $this->object = API_OAuth2_RefreshToken::create($appbox, $this->account, $expires, $this->token, $this->scope);
+ }
- $this->object = API_OAuth2_RefreshToken::create($appbox, $this->account, $expires, $this->token, $this->scope);
- }
+ public function tearDown()
+ {
+ $this->application->delete();
+ parent::tearDown();
+ }
- public function tearDown()
- {
- $this->application->delete();
- }
+ public function testGet_value()
+ {
+ $this->assertEquals($this->token, $this->object->get_value());
+ }
- public function testGet_value()
- {
- $this->assertEquals($this->token, $this->object->get_value());
- }
-
- /**
- * @todo Implement testGet_account().
- */
- public function testGet_account()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
+ /**
+ * @todo Implement testGet_account().
+ */
+ public function testGet_account()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
'This test has not been implemented yet.'
- );
- }
+ );
+ }
- /**
- * @todo Implement testGet_expires().
- */
- public function testGet_expires()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
+ /**
+ * @todo Implement testGet_expires().
+ */
+ public function testGet_expires()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
'This test has not been implemented yet.'
- );
- }
+ );
+ }
- /**
- * @todo Implement testGet_scope().
- */
- public function testGet_scope()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
+ /**
+ * @todo Implement testGet_scope().
+ */
+ public function testGet_scope()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
'This test has not been implemented yet.'
- );
- }
+ );
+ }
- /**
- * @todo Implement testDelete().
- */
- public function testDelete()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
+ /**
+ * @todo Implement testDelete().
+ */
+ public function testDelete()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
'This test has not been implemented yet.'
- );
- }
+ );
+ }
- /**
- * @todo Implement testLoad_by_account().
- */
- public function testLoad_by_account()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
+ /**
+ * @todo Implement testLoad_by_account().
+ */
+ public function testLoad_by_account()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
'This test has not been implemented yet.'
- );
- }
+ );
+ }
- /**
- * @todo Implement testCreate().
- */
- public function testCreate()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
+ /**
+ * @todo Implement testCreate().
+ */
+ public function testCreate()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
'This test has not been implemented yet.'
- );
- }
-
+ );
+ }
}
diff --git a/tests/api/oauthv2/api_oauthv2_AccountTest.php b/tests/api/oauthv2/api_oauthv2_AccountTest.php
index 8d8f194a8a..3f4a0a4fd3 100644
--- a/tests/api/oauthv2/api_oauthv2_AccountTest.php
+++ b/tests/api/oauthv2/api_oauthv2_AccountTest.php
@@ -4,81 +4,80 @@ require_once __DIR__ . '/../../PhraseanetPHPUnitAbstract.class.inc';
class API_OAuth2_AccountTest extends PhraseanetPHPUnitAbstract
{
+ /**
+ * @var API_OAuth2_Application
+ */
+ protected $application;
- /**
- * @var API_OAuth2_Application
- */
- protected $application;
+ /**
+ * @var API_OAuth2_Account
+ */
+ protected $object;
- /**
- * @var API_OAuth2_Account
- */
- protected $object;
+ public function setUp()
+ {
+ parent::setUp();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $this->application = API_OAuth2_Application::create($appbox, self::$user, 'test app');
+ $this->object = API_OAuth2_Account::load_with_user($appbox, $this->application, self::$user);
+ }
- public function setUp()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $this->application = API_OAuth2_Application::create($appbox, self::$user, 'test app');
- $this->object = API_OAuth2_Account::load_with_user($appbox, $this->application, self::$user);
- }
+ public function tearDown()
+ {
+ $this->application->delete();
+ parent::tearDown();
+ }
- public function tearDown()
- {
- $this->application->delete();
- }
+ public function testGet_id()
+ {
+ $this->assertTrue(is_int($this->object->get_id()));
+ }
- public function testGet_id()
- {
- $this->assertTrue(is_int($this->object->get_id()));
- }
+ public function testGet_user()
+ {
+ $this->assertInstanceOf('User_Adapter', $this->object->get_user());
+ $this->assertEquals(self::$user, $this->object->get_user());
+ }
- public function testGet_user()
- {
- $this->assertInstanceOf('User_Adapter', $this->object->get_user());
- $this->assertEquals(self::$user, $this->object->get_user());
- }
+ public function testGet_api_version()
+ {
+ $this->assertEquals('1.0', $this->object->get_api_version());
+ }
- public function testGet_api_version()
- {
- $this->assertEquals('1.0', $this->object->get_api_version());
- }
+ public function testIs_revoked()
+ {
+ $this->assertTrue(is_bool($this->object->is_revoked()));
+ $this->assertFalse($this->object->is_revoked());
+ }
- public function testIs_revoked()
- {
- $this->assertTrue(is_bool($this->object->is_revoked()));
- $this->assertFalse($this->object->is_revoked());
- }
+ public function testSet_revoked()
+ {
+ $this->object->set_revoked(true);
+ $this->assertTrue($this->object->is_revoked());
+ $this->object->set_revoked(false);
+ $this->assertFalse($this->object->is_revoked());
+ }
- public function testSet_revoked()
- {
- $this->object->set_revoked(true);
- $this->assertTrue($this->object->is_revoked());
- $this->object->set_revoked(false);
- $this->assertFalse($this->object->is_revoked());
- }
+ public function testGet_created_on()
+ {
+ $this->assertInstanceOf('DateTime', $this->object->get_created_on());
+ }
- public function testGet_created_on()
- {
- $this->assertInstanceOf('DateTime', $this->object->get_created_on());
- }
+ public function testGet_token()
+ {
+ $this->assertInstanceOf('API_OAuth2_Token', $this->object->get_token());
+ }
- public function testGet_token()
- {
- $this->assertInstanceOf('API_OAuth2_Token', $this->object->get_token());
- }
-
- public function testGet_application()
- {
- $this->assertInstanceOf('API_OAuth2_Application', $this->object->get_application());
- $this->assertEquals($this->application, $this->object->get_application());
- }
-
- public function testLoad_with_user()
- {
- $loaded = API_OAuth2_Account::load_with_user(appbox::get_instance(\bootstrap::getCore()), $this->application, self::$user);
- $this->assertInstanceOf('API_OAuth2_Account', $loaded);
- $this->assertEquals($this->object, $loaded);
- }
+ public function testGet_application()
+ {
+ $this->assertInstanceOf('API_OAuth2_Application', $this->object->get_application());
+ $this->assertEquals($this->application, $this->object->get_application());
+ }
+ public function testLoad_with_user()
+ {
+ $loaded = API_OAuth2_Account::load_with_user(appbox::get_instance(\bootstrap::getCore()), $this->application, self::$user);
+ $this->assertInstanceOf('API_OAuth2_Account', $loaded);
+ $this->assertEquals($this->object, $loaded);
+ }
}
-
diff --git a/tests/api/oauthv2/api_oauthv2_ApplicationTest.php b/tests/api/oauthv2/api_oauthv2_ApplicationTest.php
index f90a522627..9cdaf75f32 100644
--- a/tests/api/oauthv2/api_oauthv2_ApplicationTest.php
+++ b/tests/api/oauthv2/api_oauthv2_ApplicationTest.php
@@ -4,199 +4,192 @@ require_once __DIR__ . '/../../PhraseanetPHPUnitAbstract.class.inc';
class API_OAuth2_ApplicationTest extends PhraseanetPHPUnitAbstract
{
+ /**
+ * @var API_OAuth2_Application
+ */
+ protected $object;
- /**
- * @var API_OAuth2_Application
- */
- protected $object;
-
- public function setUp()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $this->object = API_OAuth2_Application::create($appbox, self::$user, 'test app');
- }
-
- public function tearDown()
- {
- $this->object->delete();
- }
-
- public function testLoad_from_client_id()
- {
- $client_id = $this->object->get_client_id();
- $loaded = API_OAuth2_Application::load_from_client_id(appbox::get_instance(\bootstrap::getCore()), $client_id);
- $this->assertInstanceOf('API_OAuth2_Application', $loaded);
- $this->assertEquals($this->object, $loaded);
- }
-
- public function testLoad_dev_app_by_user()
- {
- $apps = API_OAuth2_Application::load_dev_app_by_user(appbox::get_instance(\bootstrap::getCore()), self::$user);
- $this->assertTrue(is_array($apps));
- $this->assertTrue(count($apps) > 0);
- $found = false;
- foreach ($apps as $app)
+ public function setUp()
{
- if ($app->get_id() === $this->object->get_id())
- $found = true;
- $this->assertInstanceOf('API_OAuth2_Application', $app);
+ parent::setUp();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $this->object = API_OAuth2_Application::create($appbox, self::$user, 'test app');
}
- if (!$found)
- $this->fail();
- }
-
- public function testLoad_app_by_user()
- {
- $apps = API_OAuth2_Application::load_app_by_user(appbox::get_instance(\bootstrap::getCore()), self::$user);
- $this->assertTrue(is_array($apps));
- $this->assertTrue(count($apps) > 0);
- $found = false;
-
- foreach ($apps as $app)
+ public function tearDown()
{
- if ($app->get_id() === $this->object->get_id())
- $found = true;
- $this->assertInstanceOf('API_OAuth2_Application', $app);
+ $this->object->delete();
+ parent::tearDown();
}
- if (!$found)
- $this->fail();
- }
-
- public function testGet_id()
- {
- $this->assertTrue(is_int($this->object->get_id()));
- }
-
- public function testGet_creator()
- {
- $this->assertInstanceOf('User_Adapter', $this->object->get_creator());
- }
-
- public function testGet_type()
- {
- $this->assertTrue(in_array($this->object->get_type(), array(API_OAuth2_Application::DESKTOP_TYPE, API_OAuth2_Application::WEB_TYPE)));
- }
-
- public function testGet_nonce()
- {
- $this->assertTrue(is_string($this->object->get_nonce()));
- $this->assertTrue(strlen($this->object->get_nonce()) === 6);
- }
-
- public function testSet_type()
- {
- try
+ public function testLoad_from_client_id()
{
- $this->object->set_type('prout');
- $this->fail();
- }
- catch (Exception_InvalidArgument $e)
- {
-
+ $client_id = $this->object->get_client_id();
+ $loaded = API_OAuth2_Application::load_from_client_id(appbox::get_instance(\bootstrap::getCore()), $client_id);
+ $this->assertInstanceOf('API_OAuth2_Application', $loaded);
+ $this->assertEquals($this->object, $loaded);
}
- $this->object->set_type(API_OAuth2_Application::WEB_TYPE);
- $this->assertEquals(API_OAuth2_Application::WEB_TYPE, $this->object->get_type());
- $this->object->set_type(API_OAuth2_Application::DESKTOP_TYPE);
- $this->assertEquals(API_OAuth2_Application::DESKTOP_TYPE, $this->object->get_type());
- $this->assertEquals(API_OAuth2_Application::NATIVE_APP_REDIRECT_URI, $this->object->get_redirect_uri());
- }
+ public function testLoad_dev_app_by_user()
+ {
+ $apps = API_OAuth2_Application::load_dev_app_by_user(appbox::get_instance(\bootstrap::getCore()), self::$user);
+ $this->assertTrue(is_array($apps));
+ $this->assertTrue(count($apps) > 0);
+ $found = false;
+ foreach ($apps as $app) {
+ if ($app->get_id() === $this->object->get_id())
+ $found = true;
+ $this->assertInstanceOf('API_OAuth2_Application', $app);
+ }
- public function testGet_name()
- {
- $this->assertEquals('test app', $this->object->get_name());
- }
+ if ( ! $found)
+ $this->fail();
+ }
- public function testSet_name()
- {
- $this->object->set_name('prout');
- $this->assertEquals('prout', $this->object->get_name());
- }
+ public function testLoad_app_by_user()
+ {
+ $apps = API_OAuth2_Application::load_app_by_user(appbox::get_instance(\bootstrap::getCore()), self::$user);
+ $this->assertTrue(is_array($apps));
+ $this->assertTrue(count($apps) > 0);
+ $found = false;
- public function testGet_description()
- {
- $this->assertEquals('', $this->object->get_description());
- }
+ foreach ($apps as $app) {
+ if ($app->get_id() === $this->object->get_id())
+ $found = true;
+ $this->assertInstanceOf('API_OAuth2_Application', $app);
+ }
- public function testSet_description()
- {
- $desc = 'prouti prouto prout prout';
- $this->object->set_description($desc);
- $this->assertEquals($desc, $this->object->get_description());
- }
+ if ( ! $found)
+ $this->fail();
+ }
- public function testGet_website()
- {
- $this->assertEquals('', $this->object->get_website());
- }
+ public function testGet_id()
+ {
+ $this->assertTrue(is_int($this->object->get_id()));
+ }
- public function testSet_website()
- {
- $site = 'http://www.example.com/';
- $this->object->set_website($site);
- $this->assertEquals($site, $this->object->get_website());
- }
+ public function testGet_creator()
+ {
+ $this->assertInstanceOf('User_Adapter', $this->object->get_creator());
+ }
- public function testGet_created_on()
- {
- $this->assertInstanceOf('DateTime', $this->object->get_created_on());
- }
+ public function testGet_type()
+ {
+ $this->assertTrue(in_array($this->object->get_type(), array(API_OAuth2_Application::DESKTOP_TYPE, API_OAuth2_Application::WEB_TYPE)));
+ }
- public function testGet_last_modified()
- {
- $this->assertInstanceOf('DateTime', $this->object->get_last_modified());
- }
+ public function testGet_nonce()
+ {
+ $this->assertTrue(is_string($this->object->get_nonce()));
+ $this->assertTrue(strlen($this->object->get_nonce()) === 6);
+ }
- protected function assertmd5($md5)
- {
- $this->assertTrue((count(preg_match('/[a-z0-9]{32}/', $md5)) === 1));
- }
+ public function testSet_type()
+ {
+ try {
+ $this->object->set_type('prout');
+ $this->fail();
+ } catch (Exception_InvalidArgument $e) {
- public function testGet_client_id()
- {
- $this->assertMd5($this->object->get_client_id());
- }
+ }
- public function testSet_client_id()
- {
- $client_id = md5('prouto');
- $this->object->set_client_id($client_id);
- $this->assertEquals($client_id, $this->object->get_client_id());
- $this->assertMd5($this->object->get_client_id());
- }
+ $this->object->set_type(API_OAuth2_Application::WEB_TYPE);
+ $this->assertEquals(API_OAuth2_Application::WEB_TYPE, $this->object->get_type());
+ $this->object->set_type(API_OAuth2_Application::DESKTOP_TYPE);
+ $this->assertEquals(API_OAuth2_Application::DESKTOP_TYPE, $this->object->get_type());
+ $this->assertEquals(API_OAuth2_Application::NATIVE_APP_REDIRECT_URI, $this->object->get_redirect_uri());
+ }
- public function testGet_client_secret()
- {
- $this->assertMd5($this->object->get_client_secret());
- }
+ public function testGet_name()
+ {
+ $this->assertEquals('test app', $this->object->get_name());
+ }
- public function testSet_client_secret()
- {
- $client_secret = md5('prouto');
- $this->object->set_client_secret($client_secret);
- $this->assertEquals($client_secret, $this->object->get_client_secret());
- $this->assertMd5($this->object->get_client_secret());
- }
+ public function testSet_name()
+ {
+ $this->object->set_name('prout');
+ $this->assertEquals('prout', $this->object->get_name());
+ }
- public function testGet_redirect_uri()
- {
- $this->assertEquals('', $this->object->get_redirect_uri());
- }
+ public function testGet_description()
+ {
+ $this->assertEquals('', $this->object->get_description());
+ }
- public function testSet_redirect_uri()
- {
- $uri = 'http://www.example.com/callback/';
- $this->object->set_redirect_uri($uri);
- $this->assertEquals($uri, $this->object->get_redirect_uri());
- }
+ public function testSet_description()
+ {
+ $desc = 'prouti prouto prout prout';
+ $this->object->set_description($desc);
+ $this->assertEquals($desc, $this->object->get_description());
+ }
- public function testGet_user_account()
- {
- $this->assertInstanceOf('API_OAuth2_Account', $this->object->get_user_account(self::$user));
- }
+ public function testGet_website()
+ {
+ $this->assertEquals('', $this->object->get_website());
+ }
+ public function testSet_website()
+ {
+ $site = 'http://www.example.com/';
+ $this->object->set_website($site);
+ $this->assertEquals($site, $this->object->get_website());
+ }
+ public function testGet_created_on()
+ {
+ $this->assertInstanceOf('DateTime', $this->object->get_created_on());
+ }
+
+ public function testGet_last_modified()
+ {
+ $this->assertInstanceOf('DateTime', $this->object->get_last_modified());
+ }
+
+ protected function assertmd5($md5)
+ {
+ $this->assertTrue((count(preg_match('/[a-z0-9]{32}/', $md5)) === 1));
+ }
+
+ public function testGet_client_id()
+ {
+ $this->assertMd5($this->object->get_client_id());
+ }
+
+ public function testSet_client_id()
+ {
+ $client_id = md5('prouto');
+ $this->object->set_client_id($client_id);
+ $this->assertEquals($client_id, $this->object->get_client_id());
+ $this->assertMd5($this->object->get_client_id());
+ }
+
+ public function testGet_client_secret()
+ {
+ $this->assertMd5($this->object->get_client_secret());
+ }
+
+ public function testSet_client_secret()
+ {
+ $client_secret = md5('prouto');
+ $this->object->set_client_secret($client_secret);
+ $this->assertEquals($client_secret, $this->object->get_client_secret());
+ $this->assertMd5($this->object->get_client_secret());
+ }
+
+ public function testGet_redirect_uri()
+ {
+ $this->assertEquals('', $this->object->get_redirect_uri());
+ }
+
+ public function testSet_redirect_uri()
+ {
+ $uri = 'http://www.example.com/callback/';
+ $this->object->set_redirect_uri($uri);
+ $this->assertEquals($uri, $this->object->get_redirect_uri());
+ }
+
+ public function testGet_user_account()
+ {
+ $this->assertInstanceOf('API_OAuth2_Account', $this->object->get_user_account(self::$user));
+ }
}
-
diff --git a/tests/api/oauthv2/api_oauthv2_TokenTest.php b/tests/api/oauthv2/api_oauthv2_TokenTest.php
index 16ba2cf134..9b02dd0711 100644
--- a/tests/api/oauthv2/api_oauthv2_TokenTest.php
+++ b/tests/api/oauthv2/api_oauthv2_TokenTest.php
@@ -16,6 +16,7 @@ class API_OAuth2_TokenTest extends PhraseanetPHPUnitAbstract
public function setUp()
{
+ parent::setUp();
$appbox = appbox::get_instance(\bootstrap::getCore());
$this->application = API_OAuth2_Application::create($appbox, self::$user, 'test app');
$account = API_OAuth2_Account::load_with_user($appbox, $this->application, self::$user);
@@ -33,6 +34,7 @@ class API_OAuth2_TokenTest extends PhraseanetPHPUnitAbstract
public function tearDown()
{
$this->application->delete();
+ parent::tearDown();
}
protected function assertmd5($md5)
@@ -66,7 +68,7 @@ class API_OAuth2_TokenTest extends PhraseanetPHPUnitAbstract
public function testGet_expires()
{
$diff = (int) $this->object->get_expires() - time();
- $this->assertInternalType('string', $this->object->get_expires(), "expiration timestamp is string : ".$this->object->get_expires());
+ $this->assertInternalType('string', $this->object->get_expires(), "expiration timestamp is string : " . $this->object->get_expires());
$this->assertTrue($diff > 3500, "expire value $diff should be more than 3500 seconds ");
$this->assertTrue($diff < 3700, "expire value $diff should be less than 3700 seconds ");
}
@@ -121,4 +123,3 @@ class API_OAuth2_TokenTest extends PhraseanetPHPUnitAbstract
}
}
}
-
diff --git a/tests/api/v1/api_v1_adapterTest.php b/tests/api/v1/api_v1_adapterTest.php
index 066ff2a6d4..1a2f285577 100644
--- a/tests/api/v1/api_v1_adapterTest.php
+++ b/tests/api/v1/api_v1_adapterTest.php
@@ -6,554 +6,530 @@ use Symfony\Component\HttpFoundation\Request;
class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
{
+ /**
+ * @var API_V1_adapter
+ */
+ protected $object;
+ protected static $need_records = 1;
+ protected static $need_subdefs = true;
- /**
- * @var API_V1_adapter
- */
- protected $object;
- protected static $need_records = 1;
- protected static $need_subdefs = true;
-
- public function setUp()
- {
- parent::setUp();
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $this->object = new API_V1_adapter(FALSE, $appbox, self::$core);
- }
-
- public function testGet_error_code()
- {
- $request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
- $result = $this->object->get_error_code($request, 400);
- $this->assertTrue(is_object(json_decode($result->format())));
- $this->assertEquals(400, $result->get_http_code());
- $this->assertEquals('application/json', $result->get_content_type());
-
- $result = $this->object->get_error_code($request, 403);
- $this->assertTrue(is_object(json_decode($result->format())));
- $this->assertEquals(403, $result->get_http_code());
- $this->assertEquals('application/json', $result->get_content_type());
-
- $result = $this->object->get_error_code($request, 500);
- $this->assertTrue(is_object(json_decode($result->format())));
- $this->assertEquals(500, $result->get_http_code());
- $this->assertEquals('application/json', $result->get_content_type());
-
- $result = $this->object->get_error_code($request, 405);
- $this->assertTrue(is_object(json_decode($result->format())));
- $this->assertEquals(405, $result->get_http_code());
- $this->assertEquals('application/json', $result->get_content_type());
-
- $result = $this->object->get_error_code($request, 404);
- $this->assertTrue(is_object(json_decode($result->format())));
- $this->assertEquals(404, $result->get_http_code());
- $this->assertEquals('application/json', $result->get_content_type());
-
- $result = $this->object->get_error_code($request, 401);
- $this->assertTrue(is_object(json_decode($result->format())));
- $this->assertEquals(401, $result->get_http_code());
- $this->assertEquals('application/json', $result->get_content_type());
- }
-
- public function testGet_error_message()
- {
- $request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
- $result = $this->object->get_error_message($request, API_V1_result::ERROR_BAD_REQUEST);
- $this->assertTrue(is_object(json_decode($result->format())));
- $this->assertEquals(400, $result->get_http_code());
- $this->assertEquals('application/json', $result->get_content_type());
-
- $result = $this->object->get_error_message($request, API_V1_result::ERROR_FORBIDDEN);
- $this->assertTrue(is_object(json_decode($result->format())));
- $this->assertEquals(403, $result->get_http_code());
- $this->assertEquals('application/json', $result->get_content_type());
-
- $result = $this->object->get_error_message($request, API_V1_result::ERROR_INTERNALSERVERERROR);
- $this->assertTrue(is_object(json_decode($result->format())));
- $this->assertEquals(500, $result->get_http_code());
- $this->assertEquals('application/json', $result->get_content_type());
-
- $result = $this->object->get_error_message($request, API_V1_result::ERROR_METHODNOTALLOWED);
- $this->assertTrue(is_object(json_decode($result->format())));
- $this->assertEquals(405, $result->get_http_code());
- $this->assertEquals('application/json', $result->get_content_type());
-
- $result = $this->object->get_error_message($request, API_V1_result::ERROR_NOTFOUND);
- $this->assertTrue(is_object(json_decode($result->format())));
- $this->assertEquals(404, $result->get_http_code());
- $this->assertEquals('application/json', $result->get_content_type());
-
- $result = $this->object->get_error_message($request, API_V1_result::ERROR_UNAUTHORIZED);
- $this->assertTrue(is_object(json_decode($result->format())));
- $this->assertEquals(401, $result->get_http_code());
- $this->assertEquals('application/json', $result->get_content_type());
- }
-
- public function testGet_version()
- {
- $this->assertEquals('1.2', $this->object->get_version());
- }
-
- public function testGet_databoxes()
- {
- $request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
- $result = $this->object->get_databoxes($request);
- $this->assertEquals(200, $result->get_http_code());
- $this->assertEquals('application/json', $result->get_content_type());
- $this->assertTrue(is_object(json_decode($result->format())));
- }
-
- public function testGet_databox_collections()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $request = new Request();
- foreach ($appbox->get_databoxes() as $databox)
+ public function setUp()
{
- $result = $this->object->get_databox_collections($request, $databox->get_sbas_id());
- $this->assertEquals(200, $result->get_http_code());
- $this->assertEquals('application/json', $result->get_content_type());
- $this->assertTrue(is_object(json_decode($result->format())));
+ parent::setUp();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $this->object = new API_V1_adapter(FALSE, $appbox, self::$core);
}
- }
- public function testGet_record()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
-
- $request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
- $result = $this->object->get_record($request, self::$record_1->get_sbas_id(), "-40");
- $this->assertEquals(400, $result->get_http_code());
-
- $request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
- $result = $this->object->get_record($request, self::$record_1->get_sbas_id(), self::$record_1->get_record_id());
- $this->assertEquals(200, $result->get_http_code());
- $this->assertEquals('application/json', $result->get_content_type());
- $this->assertTrue(is_object(json_decode($result->format())));
- }
-
- public function testGet_databox_status()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
- foreach ($appbox->get_databoxes() as $databox)
+ public function testGet_error_code()
{
- $result = $this->object->get_databox_status($request, $databox->get_sbas_id());
- $this->assertEquals(200, $result->get_http_code());
- $this->assertEquals('application/json', $result->get_content_type());
- $this->assertTrue(is_object(json_decode($result->format())));
- }
- }
+ $request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
+ $result = $this->object->get_error_code($request, 400);
+ $this->assertTrue(is_object(json_decode($result->format())));
+ $this->assertEquals(400, $result->get_http_code());
+ $this->assertEquals('application/json', $result->get_content_type());
- public function testGet_databox_metadatas()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
- foreach ($appbox->get_databoxes() as $databox)
+ $result = $this->object->get_error_code($request, 403);
+ $this->assertTrue(is_object(json_decode($result->format())));
+ $this->assertEquals(403, $result->get_http_code());
+ $this->assertEquals('application/json', $result->get_content_type());
+
+ $result = $this->object->get_error_code($request, 500);
+ $this->assertTrue(is_object(json_decode($result->format())));
+ $this->assertEquals(500, $result->get_http_code());
+ $this->assertEquals('application/json', $result->get_content_type());
+
+ $result = $this->object->get_error_code($request, 405);
+ $this->assertTrue(is_object(json_decode($result->format())));
+ $this->assertEquals(405, $result->get_http_code());
+ $this->assertEquals('application/json', $result->get_content_type());
+
+ $result = $this->object->get_error_code($request, 404);
+ $this->assertTrue(is_object(json_decode($result->format())));
+ $this->assertEquals(404, $result->get_http_code());
+ $this->assertEquals('application/json', $result->get_content_type());
+
+ $result = $this->object->get_error_code($request, 401);
+ $this->assertTrue(is_object(json_decode($result->format())));
+ $this->assertEquals(401, $result->get_http_code());
+ $this->assertEquals('application/json', $result->get_content_type());
+ }
+
+ public function testGet_error_message()
{
- $result = $this->object->get_databox_metadatas($request, $databox->get_sbas_id());
- $this->assertEquals(200, $result->get_http_code());
- $this->assertEquals('application/json', $result->get_content_type());
- $this->assertTrue(is_object(json_decode($result->format())));
- }
- }
+ $request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
+ $result = $this->object->get_error_message($request, API_V1_result::ERROR_BAD_REQUEST);
+ $this->assertTrue(is_object(json_decode($result->format())));
+ $this->assertEquals(400, $result->get_http_code());
+ $this->assertEquals('application/json', $result->get_content_type());
- public function testGet_databox_terms()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
- foreach ($appbox->get_databoxes() as $databox)
+ $result = $this->object->get_error_message($request, API_V1_result::ERROR_FORBIDDEN);
+ $this->assertTrue(is_object(json_decode($result->format())));
+ $this->assertEquals(403, $result->get_http_code());
+ $this->assertEquals('application/json', $result->get_content_type());
+
+ $result = $this->object->get_error_message($request, API_V1_result::ERROR_INTERNALSERVERERROR);
+ $this->assertTrue(is_object(json_decode($result->format())));
+ $this->assertEquals(500, $result->get_http_code());
+ $this->assertEquals('application/json', $result->get_content_type());
+
+ $result = $this->object->get_error_message($request, API_V1_result::ERROR_METHODNOTALLOWED);
+ $this->assertTrue(is_object(json_decode($result->format())));
+ $this->assertEquals(405, $result->get_http_code());
+ $this->assertEquals('application/json', $result->get_content_type());
+
+ $result = $this->object->get_error_message($request, API_V1_result::ERROR_NOTFOUND);
+ $this->assertTrue(is_object(json_decode($result->format())));
+ $this->assertEquals(404, $result->get_http_code());
+ $this->assertEquals('application/json', $result->get_content_type());
+
+ $result = $this->object->get_error_message($request, API_V1_result::ERROR_UNAUTHORIZED);
+ $this->assertTrue(is_object(json_decode($result->format())));
+ $this->assertEquals(401, $result->get_http_code());
+ $this->assertEquals('application/json', $result->get_content_type());
+ }
+
+ public function testGet_version()
{
- $result = $this->object->get_databox_terms($request, $databox->get_sbas_id());
- $this->assertEquals(200, $result->get_http_code());
- $this->assertEquals('application/json', $result->get_content_type());
- $this->assertTrue(is_object(json_decode($result->format())));
+ $this->assertEquals('1.2', $this->object->get_version());
}
- }
- public function testSearch_records()
- {
- $request = new Request(array('record_type' => "image"), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
- $result = $this->object->search_records($request);
- $this->assertEquals(200, $result->get_http_code());
- $this->assertEquals('application/json', $result->get_content_type());
- $this->assertTrue(is_object(json_decode($result->format())));
- }
-
- public function testGet_record_related()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
-
- $request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
- $result = $this->object->get_record_related($request, self::$record_1->get_sbas_id(), self::$record_1->get_record_id());
- $this->assertEquals(200, $result->get_http_code());
- $this->assertEquals('application/json', $result->get_content_type());
- $this->assertTrue(is_object(json_decode($result->format())));
- }
-
- public function testGet_record_metadatas()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
-
- $request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
- $result = $this->object->get_record_metadatas($request, self::$record_1->get_sbas_id(), self::$record_1->get_record_id());
- $this->assertEquals(200, $result->get_http_code());
- $this->assertEquals('application/json', $result->get_content_type());
- $this->assertTrue(is_object(json_decode($result->format())));
- }
-
- public function testGet_record_status()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
-
- $request = new Request();
- $request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
- $result = $this->object->get_record_status($request, self::$record_1->get_sbas_id(), self::$record_1->get_record_id());
- $this->assertEquals(200, $result->get_http_code());
- $this->assertEquals('application/json', $result->get_content_type());
- $this->assertTrue(is_object(json_decode($result->format())));
- }
-
- public function testGet_record_embed()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
-
- $request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
- $result = $this->object->get_record_embed($request, self::$record_1->get_sbas_id(), self::$record_1->get_record_id());
- $this->assertEquals(200, $result->get_http_code());
- $this->assertEquals('application/json', $result->get_content_type());
- $this->assertTrue(is_object(json_decode($result->format())));
- }
-
- public function testSet_record_metadatas()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $databox = self::$record_1->get_databox();
- $request = new Request(array("salut" => "salut c'est la fete"), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
- $result = $this->object->set_record_metadatas($request, self::$record_1->get_sbas_id(), self::$record_1->get_record_id());
- $this->assertEquals(400, $result->get_http_code());
-
- $request = new Request(array("metadatas" => "salut c'est la fete"), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
- $this->object->set_record_metadatas($request, self::$record_1->get_sbas_id(), self::$record_1->get_record_id());
- $this->assertEquals(400, $result->get_http_code());
-
- if (sizeof(self::$record_1->get_caption()->get_fields()) == 0)
+ public function testGet_databoxes()
{
- $caption_field_value = caption_Field_Value::create(databox_field::get_instance($databox, 1), self::$record_1, 'my value');
+ $request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
+ $result = $this->object->get_databoxes($request);
+ $this->assertEquals(200, $result->get_http_code());
+ $this->assertEquals('application/json', $result->get_content_type());
+ $this->assertTrue(is_object(json_decode($result->format())));
}
+ public function testGet_databox_collections()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $request = new Request();
+ foreach ($appbox->get_databoxes() as $databox) {
+ $result = $this->object->get_databox_collections($request, $databox->get_sbas_id());
+ $this->assertEquals(200, $result->get_http_code());
+ $this->assertEquals('application/json', $result->get_content_type());
+ $this->assertTrue(is_object(json_decode($result->format())));
+ }
+ }
+
+ public function testGet_record()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+
+ $request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
+ $result = $this->object->get_record($request, self::$record_1->get_sbas_id(), "-40");
+ $this->assertEquals(400, $result->get_http_code());
+
+ $request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
+ $result = $this->object->get_record($request, self::$record_1->get_sbas_id(), self::$record_1->get_record_id());
+ $this->assertEquals(200, $result->get_http_code());
+ $this->assertEquals('application/json', $result->get_content_type());
+ $this->assertTrue(is_object(json_decode($result->format())));
+ }
+
+ public function testGet_databox_status()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
+ foreach ($appbox->get_databoxes() as $databox) {
+ $result = $this->object->get_databox_status($request, $databox->get_sbas_id());
+ $this->assertEquals(200, $result->get_http_code());
+ $this->assertEquals('application/json', $result->get_content_type());
+ $this->assertTrue(is_object(json_decode($result->format())));
+ }
+ }
+
+ public function testGet_databox_metadatas()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
+ foreach ($appbox->get_databoxes() as $databox) {
+ $result = $this->object->get_databox_metadatas($request, $databox->get_sbas_id());
+ $this->assertEquals(200, $result->get_http_code());
+ $this->assertEquals('application/json', $result->get_content_type());
+ $this->assertTrue(is_object(json_decode($result->format())));
+ }
+ }
+
+ public function testGet_databox_terms()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
+ foreach ($appbox->get_databoxes() as $databox) {
+ $result = $this->object->get_databox_terms($request, $databox->get_sbas_id());
+ $this->assertEquals(200, $result->get_http_code());
+ $this->assertEquals('application/json', $result->get_content_type());
+ $this->assertTrue(is_object(json_decode($result->format())));
+ }
+ }
+
+ public function testSearch_records()
+ {
+ $request = new Request(array('record_type' => "image"), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
+ $result = $this->object->search_records($request);
+ $this->assertEquals(200, $result->get_http_code());
+ $this->assertEquals('application/json', $result->get_content_type());
+ $this->assertTrue(is_object(json_decode($result->format())));
+ }
+
+ public function testGet_record_related()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+
+ $request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
+ $result = $this->object->get_record_related($request, self::$record_1->get_sbas_id(), self::$record_1->get_record_id());
+ $this->assertEquals(200, $result->get_http_code());
+ $this->assertEquals('application/json', $result->get_content_type());
+ $this->assertTrue(is_object(json_decode($result->format())));
+ }
+
+ public function testGet_record_metadatas()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+
+ $request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
+ $result = $this->object->get_record_metadatas($request, self::$record_1->get_sbas_id(), self::$record_1->get_record_id());
+ $this->assertEquals(200, $result->get_http_code());
+ $this->assertEquals('application/json', $result->get_content_type());
+ $this->assertTrue(is_object(json_decode($result->format())));
+ }
+
+ public function testGet_record_status()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+
+ $request = new Request();
+ $request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
+ $result = $this->object->get_record_status($request, self::$record_1->get_sbas_id(), self::$record_1->get_record_id());
+ $this->assertEquals(200, $result->get_http_code());
+ $this->assertEquals('application/json', $result->get_content_type());
+ $this->assertTrue(is_object(json_decode($result->format())));
+ }
+
+ public function testGet_record_embed()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+
+ $request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
+ $result = $this->object->get_record_embed($request, self::$record_1->get_sbas_id(), self::$record_1->get_record_id());
+ $this->assertEquals(200, $result->get_http_code());
+ $this->assertEquals('application/json', $result->get_content_type());
+ $this->assertTrue(is_object(json_decode($result->format())));
+ }
+
+ public function testSet_record_metadatas()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $databox = self::$record_1->get_databox();
+ $request = new Request(array("salut" => "salut c'est la fete"), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
+ $result = $this->object->set_record_metadatas($request, self::$record_1->get_sbas_id(), self::$record_1->get_record_id());
+ $this->assertEquals(400, $result->get_http_code());
+
+ $request = new Request(array("metadatas" => "salut c'est la fete"), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
+ $this->object->set_record_metadatas($request, self::$record_1->get_sbas_id(), self::$record_1->get_record_id());
+ $this->assertEquals(400, $result->get_http_code());
+
+ if (sizeof(self::$record_1->get_caption()->get_fields()) == 0) {
+ $caption_field_value = caption_Field_Value::create(databox_field::get_instance($databox, 1), self::$record_1, 'my value');
+ }
+
//valide metas
- $metadatas = array();
+ $metadatas = array();
- foreach (self::$record_1->get_databox()->get_meta_structure()->get_elements() as $field)
- {
- try
- {
- $values = self::$record_1->get_caption()->get_field($field->get_name())->get_values();
- $value = array_pop($values);
- $meta_id = $value->getId();
- }
- catch (\Exception $e)
- {
- $meta_id = null;
- }
+ foreach (self::$record_1->get_databox()->get_meta_structure()->get_elements() as $field) {
+ try {
+ $values = self::$record_1->get_caption()->get_field($field->get_name())->get_values();
+ $value = array_pop($values);
+ $meta_id = $value->getId();
+ } catch (\Exception $e) {
+ $meta_id = null;
+ }
- $metadatas[] = array(
- 'meta_id' => $meta_id
- , 'meta_struct_id' => $field->get_id()
- , 'value' => 'poOM POOM TCHOK ' . $field->get_id()
- );
+ $metadatas[] = array(
+ 'meta_id' => $meta_id
+ , 'meta_struct_id' => $field->get_id()
+ , 'value' => 'poOM POOM TCHOK ' . $field->get_id()
+ );
+ }
+
+ $request = new Request(array("metadatas" => $metadatas), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
+
+ $result = $this->object->set_record_metadatas($request, self::$record_1->get_sbas_id(), self::$record_1->get_record_id());
+
+ $response = json_decode($result->format());
+
+ $this->assertEquals($response->meta->http_code, 200);
+
+ $this->checkResponseField($result, "metadatas", PHPUnit_Framework_Constraint_IsType::TYPE_OBJECT);
}
- $request = new Request(array("metadatas" => $metadatas), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
-
- $result = $this->object->set_record_metadatas($request, self::$record_1->get_sbas_id(), self::$record_1->get_record_id());
-
- $response = json_decode($result->format());
-
- $this->assertEquals($response->meta->http_code, 200);
-
- $this->checkResponseField($result, "metadatas", PHPUnit_Framework_Constraint_IsType::TYPE_OBJECT);
- }
-
- /**
- * @todo Implement testSet_record_status().
- */
- public function testSet_record_status()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $stub = $this->getMock("API_V1_adapter", array("list_record_status"), array(false, &$appbox, bootstrap::getCore()));
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $databox = self::$record_1->get_databox();
-
- $statusbit = null;
- foreach ($databox->get_statusbits() as $key => $value)
+ public function testSet_record_status()
{
- $statusbit = $key;
- break;
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $stub = $this->getMock("API_V1_adapter", array("list_record_status"), array(false, &$appbox, bootstrap::getCore()));
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $databox = self::$record_1->get_databox();
+
+ $statusbit = null;
+ foreach ($databox->get_statusbits() as $key => $value) {
+ $statusbit = $key;
+ break;
+ }
+
+ $request = new Request(array("salut" => "salut c'est la fete"), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
+ $result = $stub->set_record_status($request, self::$record_1->get_sbas_id(), self::$record_1->get_record_id());
+ $this->assertEquals(400, $result->get_http_code());
+
+ $request = new Request(array("status" => "salut c'est la fete"), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
+ $stub->set_record_status($request, self::$record_1->get_sbas_id(), self::$record_1->get_record_id());
+ $this->assertEquals(400, $result->get_http_code());
+
+ $status = array($statusbit => '1');
+
+ $request = new Request(array("status" => $status), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
+ //check method use record->get_caption
+ $stub->expects($this->once())
+ ->method("list_record_status")
+ ->will($this->returnValue(new stdClass()));
+ //check for metadas fiels in response
+ $result = $stub->set_record_status($request, self::$record_1->get_sbas_id(), self::$record_1->get_record_id());
+ $this->checkResponseField($result, "status", PHPUnit_Framework_Constraint_IsType::TYPE_OBJECT);
}
- $request = new Request(array("salut" => "salut c'est la fete"), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
- $result = $stub->set_record_status($request, self::$record_1->get_sbas_id(), self::$record_1->get_record_id());
- $this->assertEquals(400, $result->get_http_code());
-
- $request = new Request(array("status" => "salut c'est la fete"), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
- $stub->set_record_status($request, self::$record_1->get_sbas_id(), self::$record_1->get_record_id());
- $this->assertEquals(400, $result->get_http_code());
-
- $status = array($statusbit => '1');
-
- $request = new Request(array("status" => $status), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
- //check method use record->get_caption
- $stub->expects($this->once())
- ->method("list_record_status")
- ->will($this->returnValue(new stdClass()));
- //check for metadas fiels in response
- $result = $stub->set_record_status($request, self::$record_1->get_sbas_id(), self::$record_1->get_record_id());
- $this->checkResponseField($result, "status", PHPUnit_Framework_Constraint_IsType::TYPE_OBJECT);
- }
-
- /**
- * @todo Implement testSet_record_collection().
- */
- public function testSet_record_collection()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $stub = $this->getMock("API_V1_adapter", array("list_record"), array(false, &$appbox, bootstrap::getCore()));
- $databox = self::$record_1->get_databox();
-
- $request = new Request(array("salut" => "salut c'est la fete"), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
- $result = $stub->set_record_collection($request, self::$record_1->get_sbas_id(), self::$record_1->get_record_id());
- $this->assertEquals(400, $result->get_http_code());
-
- foreach ($appbox->get_databoxes() as $databox)
+ public function testSet_record_collection()
{
- $collections = $databox->get_collections();
- break;
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $stub = $this->getMock("API_V1_adapter", array("list_record"), array(false, &$appbox, bootstrap::getCore()));
+ $databox = self::$record_1->get_databox();
+
+ $request = new Request(array("salut" => "salut c'est la fete"), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
+ $result = $stub->set_record_collection($request, self::$record_1->get_sbas_id(), self::$record_1->get_record_id());
+ $this->assertEquals(400, $result->get_http_code());
+
+ foreach ($appbox->get_databoxes() as $databox) {
+ $collections = $databox->get_collections();
+ break;
+ }
+
+ $collection = array_shift($collections);
+
+ $request = new Request(array("base_id" => $collection->get_base_id()), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
+ //check method use record->get_caption
+ $stub->expects($this->once())
+ ->method("list_record")
+ ->will($this->returnValue(new stdClass()));
+ //check for metadas fiels in response
+ $result = $stub->set_record_collection($request, self::$record_1->get_sbas_id(), self::$record_1->get_record_id());
+ $this->checkResponseField($result, "record", PHPUnit_Framework_Constraint_IsType::TYPE_OBJECT);
}
- $collection = array_shift($collections);
-
- $request = new Request(array("base_id" => $collection->get_base_id()), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
- //check method use record->get_caption
- $stub->expects($this->once())
- ->method("list_record")
- ->will($this->returnValue(new stdClass()));
- //check for metadas fiels in response
- $result = $stub->set_record_collection($request, self::$record_1->get_sbas_id(), self::$record_1->get_record_id());
- $this->checkResponseField($result, "record", PHPUnit_Framework_Constraint_IsType::TYPE_OBJECT);
- }
-
- /**
- * @todo Implement testAdd_record_tobasket().
- */
- public function testAdd_record_tobasket()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- public function testSearch_baskets()
- {
- $request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
- $result = $this->object->search_baskets($request);
- $this->assertEquals(200, $result->get_http_code());
- $this->assertEquals('application/json', $result->get_content_type());
- $this->assertTrue(is_object(json_decode($result->format())));
- }
-
- public function testCreate_basket()
- {
- $request = new Request(array(), array(), array('name' => 'BIG BASKET'), array(), array(), array('HTTP_Accept' => 'application/json'));
- $result = $this->object->create_basket($request);
- $this->assertEquals(200, $result->get_http_code());
- $this->assertEquals('application/json', $result->get_content_type());
- $this->assertTrue(is_object(json_decode($result->format())));
-
- $n = 0;
- foreach (json_decode($result->format())->response->basket as $ssel_id => $basket)
+ /**
+ * @todo Implement testAdd_record_tobasket().
+ */
+ public function testAdd_record_tobasket()
{
- $n++;
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
}
- $this->assertEquals(1, $n);
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $session = $appbox->get_session();
- $usr_id = $session->get_usr_id();
-
- $em = self::$core->getEntityManager();
- $repo = $em->getRepository('\Entities\Basket');
-
- /* @var $repo \Repositories\BasketRepository */
- $basket = $repo->findUserBasket($ssel_id, self::$core->getAuthenticatedUser(), true);
-
- $this->assertTrue($basket instanceof \Entities\Basket);
- $em->remove($basket);
- $em->flush();
- }
-
- public function testDelete_basket()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $usr_id = $appbox->get_session()->get_usr_id();
- $user = User_Adapter::getInstance($usr_id, $appbox);
-
- $em = self::$core->getEntityManager();
-
- $Basket = new Entities\Basket();
- $Basket->setName('Delete test');
- $Basket->setOwner($user);
-
- $em->persist($Basket);
- $em->flush();
-
- $ssel_id = $Basket->getId();
-
- $request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
- $result = $this->object->delete_basket($request, $ssel_id);
- $this->assertEquals(200, $result->get_http_code());
- $this->assertEquals('application/json', $result->get_content_type());
- $this->assertTrue(is_object(json_decode($result->format())));
-
- $repo = $em->getRepository('\Entities\Basket');
-
- try
+ public function testSearch_baskets()
{
- $repo->findUserBasket($ssel_id, $user, true);
- $this->fail('An exception should have been raised');
+ $request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
+ $result = $this->object->search_baskets($request);
+ $this->assertEquals(200, $result->get_http_code());
+ $this->assertEquals('application/json', $result->get_content_type());
+ $this->assertTrue(is_object(json_decode($result->format())));
}
- catch (Exception_NotFound $e)
+
+ public function testCreate_basket()
{
+ $request = new Request(array(), array(), array('name' => 'BIG BASKET'), array(), array(), array('HTTP_Accept' => 'application/json'));
+ $result = $this->object->create_basket($request);
+ $this->assertEquals(200, $result->get_http_code());
+ $this->assertEquals('application/json', $result->get_content_type());
+ $this->assertTrue(is_object(json_decode($result->format())));
+ $n = 0;
+ foreach (json_decode($result->format())->response->basket as $ssel_id => $basket) {
+ $n ++;
+ }
+
+ $this->assertEquals(1, $n);
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $session = $appbox->get_session();
+ $usr_id = $session->get_usr_id();
+
+ $em = self::$core->getEntityManager();
+ $repo = $em->getRepository('\Entities\Basket');
+
+ /* @var $repo \Repositories\BasketRepository */
+ $basket = $repo->findUserBasket($ssel_id, self::$core->getAuthenticatedUser(), true);
+
+ $this->assertTrue($basket instanceof \Entities\Basket);
+ $em->remove($basket);
+ $em->flush();
}
- }
- public function testGet_basket()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $usr_id = $appbox->get_session()->get_usr_id();
-
- $basket = $this->insertOneBasket();
-
- $request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
- $result = $this->object->get_basket($request, $basket->getId());
- $this->assertEquals(200, $result->get_http_code());
- $this->assertEquals('application/json', $result->get_content_type());
- $this->assertTrue(is_object(json_decode($result->format())));
- }
-
- public function testSet_basket_title()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $usr_id = $appbox->get_session()->get_usr_id();
-
- $basket = $this->insertOneBasket();
-
- $request = new Request(array(), array(), array('name' => 'PROUTO'), array(), array(), array('HTTP_Accept' => 'application/json'));
- $result = $this->object->set_basket_title($request, $basket->getId());
- $this->assertEquals(200, $result->get_http_code());
- $this->assertEquals('application/json', $result->get_content_type());
- $this->assertTrue(is_object(json_decode($result->format())));
-
- $repository = self::$core->getEntityManager()->getRepository('\Entities\Basket');
-
- $ret_bask = $repository->find($basket->getId());
-
- $this->assertEquals('PROUTO', $ret_bask->getName());
- }
-
- public function testSet_basket_description()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $usr_id = $appbox->get_session()->get_usr_id();
-
- $basket = $this->insertOneBasket();
-
- $request = new Request(array(), array(), array('description' => 'une belle description'), array(), array(), array('HTTP_Accept' => 'application/json'));
- $result = $this->object->set_basket_description($request, $basket->getId());
- $this->assertEquals(200, $result->get_http_code());
- $this->assertEquals('application/json', $result->get_content_type());
- $this->assertTrue(is_object(json_decode($result->format())));
-
- $repository = self::$core->getEntityManager()->getRepository('\Entities\Basket');
-
- $ret_bask = $repository->find($basket->getId());
-
- $this->assertEquals('une belle description', $ret_bask->getDescription());
- }
-
- public function testSearch_publications()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $stub = $this->getMock("API_V1_adapter", array("list_publication"), array(false, &$appbox, bootstrap::getCore()));
- $request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
- $feed = Feed_Adapter::create($appbox, self::$user, "hello", "salut");
- $result = $this->object->search_publications($request, self::$user);
- $this->checkResponseField($result, "feeds", PHPUnit_Framework_Constraint_IsType::TYPE_OBJECT);
- $feed->delete();
- }
-
- public function testRemove_publications()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- public function testGet_publication()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
-
- $date = new DateTime();
- $request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
- $feed = Feed_Adapter::create($appbox, self::$user, "hello", "salut");
- $feed_publisher = Feed_Publisher_Adapter::getPublisher($appbox, $feed, self::$user);
- $feed_entry = Feed_Entry_Adapter::create($appbox, $feed, $feed_publisher, "coucou", "hello", "me", "my@email.com");
- $feed_entry_item = Feed_Entry_Item::create($appbox, $feed_entry, self::$record_1);
- $coll = Feed_Collection::load_all($appbox, self::$user);
- foreach ($coll->get_feeds() as $feed)
+ public function testDelete_basket()
{
- $result = $this->object->get_publication($request, $feed->get_id(), self::$user);
- $this->checkResponseField($result, "feed", PHPUnit_Framework_Constraint_IsType::TYPE_OBJECT);
- $this->checkResponseField($result, "entries", PHPUnit_Framework_Constraint_IsType::TYPE_OBJECT);
- $this->checkResponseField($result, "offset_start", PHPUnit_Framework_Constraint_IsType::TYPE_INT);
- $this->checkResponseField($result, "per_page", PHPUnit_Framework_Constraint_IsType::TYPE_INT);
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $usr_id = $appbox->get_session()->get_usr_id();
+ $user = User_Adapter::getInstance($usr_id, $appbox);
+
+ $em = self::$core->getEntityManager();
+
+ $Basket = new Entities\Basket();
+ $Basket->setName('Delete test');
+ $Basket->setOwner($user);
+
+ $em->persist($Basket);
+ $em->flush();
+
+ $ssel_id = $Basket->getId();
+
+ $request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
+ $result = $this->object->delete_basket($request, $ssel_id);
+ $this->assertEquals(200, $result->get_http_code());
+ $this->assertEquals('application/json', $result->get_content_type());
+ $this->assertTrue(is_object(json_decode($result->format())));
+
+ $repo = $em->getRepository('\Entities\Basket');
+
+ try {
+ $repo->findUserBasket($ssel_id, $user, true);
+ $this->fail('An exception should have been raised');
+ } catch (Exception_NotFound $e) {
+
+ }
}
- $feed->delete();
- }
- public function testSearch_users()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
+ public function testGet_basket()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $usr_id = $appbox->get_session()->get_usr_id();
- public function testGet_user_acces()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
+ $basket = $this->insertOneBasket();
- public function testAdd_user()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
+ $request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
+ $result = $this->object->get_basket($request, $basket->getId());
+ $this->assertEquals(200, $result->get_http_code());
+ $this->assertEquals('application/json', $result->get_content_type());
+ $this->assertTrue(is_object(json_decode($result->format())));
+ }
- protected function checkResponseField(API_V1_result $result, $field, $type)
- {
- $response = json_decode($result->format());
- $this->assertObjectHasAttribute($field, $response->response);
- $this->assertInternalType($type, $response->response->$field);
- }
+ public function testSet_basket_title()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $usr_id = $appbox->get_session()->get_usr_id();
+ $basket = $this->insertOneBasket();
+
+ $request = new Request(array(), array(), array('name' => 'PROUTO'), array(), array(), array('HTTP_Accept' => 'application/json'));
+ $result = $this->object->set_basket_title($request, $basket->getId());
+ $this->assertEquals(200, $result->get_http_code());
+ $this->assertEquals('application/json', $result->get_content_type());
+ $this->assertTrue(is_object(json_decode($result->format())));
+
+ $repository = self::$core->getEntityManager()->getRepository('\Entities\Basket');
+
+ $ret_bask = $repository->find($basket->getId());
+
+ $this->assertEquals('PROUTO', $ret_bask->getName());
+ }
+
+ public function testSet_basket_description()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $usr_id = $appbox->get_session()->get_usr_id();
+
+ $basket = $this->insertOneBasket();
+
+ $request = new Request(array(), array(), array('description' => 'une belle description'), array(), array(), array('HTTP_Accept' => 'application/json'));
+ $result = $this->object->set_basket_description($request, $basket->getId());
+ $this->assertEquals(200, $result->get_http_code());
+ $this->assertEquals('application/json', $result->get_content_type());
+ $this->assertTrue(is_object(json_decode($result->format())));
+
+ $repository = self::$core->getEntityManager()->getRepository('\Entities\Basket');
+
+ $ret_bask = $repository->find($basket->getId());
+
+ $this->assertEquals('une belle description', $ret_bask->getDescription());
+ }
+
+ public function testSearch_publications()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $stub = $this->getMock("API_V1_adapter", array("list_publication"), array(false, &$appbox, bootstrap::getCore()));
+ $request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
+ $feed = Feed_Adapter::create($appbox, self::$user, "hello", "salut");
+ $result = $this->object->search_publications($request, self::$user);
+ $this->checkResponseField($result, "feeds", PHPUnit_Framework_Constraint_IsType::TYPE_OBJECT);
+ $feed->delete();
+ }
+
+ public function testRemove_publications()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ public function testGet_publication()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+
+ $date = new DateTime();
+ $request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
+ $feed = Feed_Adapter::create($appbox, self::$user, "hello", "salut");
+ $feed_publisher = Feed_Publisher_Adapter::getPublisher($appbox, $feed, self::$user);
+ $feed_entry = Feed_Entry_Adapter::create($appbox, $feed, $feed_publisher, "coucou", "hello", "me", "my@email.com");
+ $feed_entry_item = Feed_Entry_Item::create($appbox, $feed_entry, self::$record_1);
+ $coll = Feed_Collection::load_all($appbox, self::$user);
+ foreach ($coll->get_feeds() as $feed) {
+ $result = $this->object->get_publication($request, $feed->get_id(), self::$user);
+ $this->checkResponseField($result, "feed", PHPUnit_Framework_Constraint_IsType::TYPE_OBJECT);
+ $this->checkResponseField($result, "entries", PHPUnit_Framework_Constraint_IsType::TYPE_OBJECT);
+ $this->checkResponseField($result, "offset_start", PHPUnit_Framework_Constraint_IsType::TYPE_INT);
+ $this->checkResponseField($result, "per_page", PHPUnit_Framework_Constraint_IsType::TYPE_INT);
+ }
+ $feed->delete();
+ }
+
+ public function testSearch_users()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ public function testGet_user_acces()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ public function testAdd_user()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ protected function checkResponseField(API_V1_result $result, $field, $type)
+ {
+ $response = json_decode($result->format());
+ $this->assertObjectHasAttribute($field, $response->response);
+ $this->assertInternalType($type, $response->response->$field);
+ }
}
diff --git a/tests/api/v1/api_v1_resultTest.php b/tests/api/v1/api_v1_resultTest.php
index 1bc1fc7d03..52216051d4 100644
--- a/tests/api/v1/api_v1_resultTest.php
+++ b/tests/api/v1/api_v1_resultTest.php
@@ -6,340 +6,333 @@ use Symfony\Component\HttpFoundation\Request;
class API_V1_resultTest extends PhraseanetPHPUnitAuthenticatedAbstract
{
+ /**
+ * @var API_V1_result
+ */
+ protected $api;
- /**
- * @var API_V1_result
- */
- protected $api;
+ public function setUp()
+ {
+ parent::setUp();
+ $this->api = $this->getMock("API_V1_adapter", array("get_version"), array(), "", false);
+ $this->api->expects($this->any())->method("get_version")->will($this->returnValue("my_super_version1.0"));
+ }
- public function setUp()
- {
- $this->api = $this->getMock("API_V1_adapter", array("get_version"), array(), "", false);
- $this->api->expects($this->any())->method("get_version")->will($this->returnValue("my_super_version1.0"));
- }
+ public function testFormat()
+ {
+ $server = array(
+ "HTTP_ACCEPT" => "application/json"
+ , 'REQUEST_METHOD' => 'GET'
+ , 'SCRIPT_FILENAME' => 'my/base/path/my/request/uri/filename'
+ , "REQUEST_URI" => "my/base/path/my/request/uri"
+ , 'PHP_SELF' => 'my/base/path'
+ );
+ $request = new Request(array("callback" => ""), array(), array(), array(), array(), $server);
- public function testFormat()
- {
- $server = array(
- "HTTP_ACCEPT" => "application/json"
- , 'REQUEST_METHOD' => 'GET'
- , 'SCRIPT_FILENAME' => 'my/base/path/my/request/uri/filename'
- , "REQUEST_URI" => "my/base/path/my/request/uri"
- , 'PHP_SELF' => 'my/base/path'
- );
- $request = new Request(array("callback" => ""), array(), array(), array(), array(), $server);
-
- $api_result = new API_V1_result($request, $this->api);
- $return = $api_result->format();
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $return);
- $response = json_decode($return);
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_OBJECT, $response);
- $this->assertObjectHasAttribute("meta", $response);
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_OBJECT, $response->meta);
- $this->assertObjectHasAttribute("response", $response);
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_OBJECT, $response->response);
- $this->assertEquals(0, sizeof(get_object_vars($response->response)));
- $this->assertEquals(0, sizeof(get_class_methods($response->response)));
- $this->checkResponseFieldMeta($response, "api_version", "my_super_version1.0", PHPUnit_Framework_Constraint_IsType::TYPE_STRING);
- $this->checkResponseFieldMeta($response, "request", "GET my/base/path/my/request/uri", PHPUnit_Framework_Constraint_IsType::TYPE_STRING);
+ $api_result = new API_V1_result($request, $this->api);
+ $return = $api_result->format();
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $return);
+ $response = json_decode($return);
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_OBJECT, $response);
+ $this->assertObjectHasAttribute("meta", $response);
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_OBJECT, $response->meta);
+ $this->assertObjectHasAttribute("response", $response);
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_OBJECT, $response->response);
+ $this->assertEquals(0, sizeof(get_object_vars($response->response)));
+ $this->assertEquals(0, sizeof(get_class_methods($response->response)));
+ $this->checkResponseFieldMeta($response, "api_version", "my_super_version1.0", PHPUnit_Framework_Constraint_IsType::TYPE_STRING);
+ $this->checkResponseFieldMeta($response, "request", "GET my/base/path/my/request/uri", PHPUnit_Framework_Constraint_IsType::TYPE_STRING);
// $this->checkResponseFieldMeta($response, "response_time", $date->format(DATE_ATOM), PHPUnit_Framework_Constraint_IsType::TYPE_STRING);
- $this->assertDateAtom($response->meta->response_time);
- $date = new DateTime();
- $now_U = $date->format('U');
- $date_resp = DateTime::createFromFormat(DATE_ATOM,$response->meta->response_time);
- $resp_U = $date_resp->format('U');
+ $this->assertDateAtom($response->meta->response_time);
+ $date = new DateTime();
+ $now_U = $date->format('U');
+ $date_resp = DateTime::createFromFormat(DATE_ATOM, $response->meta->response_time);
+ $resp_U = $date_resp->format('U');
- $this->assertLessThan(3, abs($resp_U - $now_U), 'No more than 3sec between now and the query');
+ $this->assertLessThan(3, abs($resp_U - $now_U), 'No more than 3sec between now and the query');
- $this->checkResponseFieldMeta($response, "http_code", 200, PHPUnit_Framework_Constraint_IsType::TYPE_INT);
- $this->checkResponseFieldMeta($response, "charset", "UTF-8", PHPUnit_Framework_Constraint_IsType::TYPE_STRING);
- $this->assertObjectHasAttribute("error_message", $response->meta);
- $this->assertNull($response->meta->error_message);
- $this->assertObjectHasAttribute("error_details", $response->meta);
- $this->assertNull($response->meta->error_details);
+ $this->checkResponseFieldMeta($response, "http_code", 200, PHPUnit_Framework_Constraint_IsType::TYPE_INT);
+ $this->checkResponseFieldMeta($response, "charset", "UTF-8", PHPUnit_Framework_Constraint_IsType::TYPE_STRING);
+ $this->assertObjectHasAttribute("error_message", $response->meta);
+ $this->assertNull($response->meta->error_message);
+ $this->assertObjectHasAttribute("error_details", $response->meta);
+ $this->assertNull($response->meta->error_details);
- $server = array(
- "HTTP_ACCEPT" => "application/yaml"
- , 'REQUEST_METHOD' => 'GET'
- , 'SCRIPT_FILENAME' => 'my/base/path/my/request/uri/filename'
- , "REQUEST_URI" => "my/base/path/my/request/uri"
- , 'PHP_SELF' => 'my/base/path'
- );
- $request = new Request(array("callback" => ""), array(), array(), array(), array(), $server);
+ $server = array(
+ "HTTP_ACCEPT" => "application/yaml"
+ , 'REQUEST_METHOD' => 'GET'
+ , 'SCRIPT_FILENAME' => 'my/base/path/my/request/uri/filename'
+ , "REQUEST_URI" => "my/base/path/my/request/uri"
+ , 'PHP_SELF' => 'my/base/path'
+ );
+ $request = new Request(array("callback" => ""), array(), array(), array(), array(), $server);
- $api_result = new API_V1_result($request, $this->api);
- $return = $api_result->format();
- $sfYaml = new Symfony\Component\Yaml\Parser();
- $response = $sfYaml->parse($return);
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $response);
- $this->assertArrayHasKey("meta", $response);
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $response["meta"]);
- $this->assertArrayHasKey("response", $response);
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $response["response"]);
- $this->assertEquals(0, count($response["response"]));
- $this->assertArrayHasKey("api_version", $response["meta"]);
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $response["meta"]["api_version"]);
- $this->assertEquals("my_super_version1.0", $response["meta"]["api_version"]);
- $this->assertArrayHasKey("request", $response["meta"]);
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $response["meta"]["request"]);
- $this->assertEquals("GET my/base/path/my/request/uri", $response["meta"]["request"]);
- $this->assertArrayHasKey("response_time", $response["meta"]);
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $response["meta"]["response_time"]);
+ $api_result = new API_V1_result($request, $this->api);
+ $return = $api_result->format();
+ $sfYaml = new Symfony\Component\Yaml\Parser();
+ $response = $sfYaml->parse($return);
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $response);
+ $this->assertArrayHasKey("meta", $response);
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $response["meta"]);
+ $this->assertArrayHasKey("response", $response);
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $response["response"]);
+ $this->assertEquals(0, count($response["response"]));
+ $this->assertArrayHasKey("api_version", $response["meta"]);
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $response["meta"]["api_version"]);
+ $this->assertEquals("my_super_version1.0", $response["meta"]["api_version"]);
+ $this->assertArrayHasKey("request", $response["meta"]);
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $response["meta"]["request"]);
+ $this->assertEquals("GET my/base/path/my/request/uri", $response["meta"]["request"]);
+ $this->assertArrayHasKey("response_time", $response["meta"]);
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $response["meta"]["response_time"]);
- $this->assertDateAtom($response["meta"]["response_time"]);
- $date_obj1 = DateTime::createFromFormat(DATE_ATOM, $response["meta"]["response_time"]);
- $date_obj2 = new DateTime();
- $this->assertLessThan(3, abs($date_obj1->format('U') - $date_obj2->format('U')), 'No more than 3sec between now and the query');
+ $this->assertDateAtom($response["meta"]["response_time"]);
+ $date_obj1 = DateTime::createFromFormat(DATE_ATOM, $response["meta"]["response_time"]);
+ $date_obj2 = new DateTime();
+ $this->assertLessThan(3, abs($date_obj1->format('U') - $date_obj2->format('U')), 'No more than 3sec between now and the query');
- $this->assertArrayHasKey("http_code", $response["meta"]);
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_INT, $response["meta"]["http_code"]);
- $this->assertEquals(200, $response["meta"]["http_code"]);
- $this->assertArrayHasKey("error_message", $response["meta"]);
- $this->assertNull($response["meta"]["error_message"]);
- $this->assertArrayHasKey("error_details", $response["meta"]);
- $this->assertNull($response["meta"]["error_details"]);
- $this->assertArrayHasKey("charset", $response["meta"]);
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $response["meta"]["charset"]);
- $this->assertEquals("UTF-8", $response["meta"]["charset"]);
+ $this->assertArrayHasKey("http_code", $response["meta"]);
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_INT, $response["meta"]["http_code"]);
+ $this->assertEquals(200, $response["meta"]["http_code"]);
+ $this->assertArrayHasKey("error_message", $response["meta"]);
+ $this->assertNull($response["meta"]["error_message"]);
+ $this->assertArrayHasKey("error_details", $response["meta"]);
+ $this->assertNull($response["meta"]["error_details"]);
+ $this->assertArrayHasKey("charset", $response["meta"]);
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $response["meta"]["charset"]);
+ $this->assertEquals("UTF-8", $response["meta"]["charset"]);
- $server = array(
- "HTTP_ACCEPT" => "application/yaml"
- , 'REQUEST_METHOD' => 'GET'
- , 'SCRIPT_FILENAME' => 'my/base/path/my/request/uri/filename'
- , "REQUEST_URI" => "my/base/path/my/request/uri"
- , 'PHP_SELF' => 'my/base/path'
- );
- $request = new Request(array("callback" => "my_callback_function"), array(), array(), array(), array(), $server);
+ $server = array(
+ "HTTP_ACCEPT" => "application/yaml"
+ , 'REQUEST_METHOD' => 'GET'
+ , 'SCRIPT_FILENAME' => 'my/base/path/my/request/uri/filename'
+ , "REQUEST_URI" => "my/base/path/my/request/uri"
+ , 'PHP_SELF' => 'my/base/path'
+ );
+ $request = new Request(array("callback" => "my_callback_function"), array(), array(), array(), array(), $server);
- $api_result = new API_V1_result($request, $this->api);
- $return = $api_result->format();
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $return);
- $this->assertRegexp("/my_callback_function\(\{.+\}\)/", $return);
- }
-
- /**
- * @depends testFormat
- */
- public function testSet_datas()
- {
- $server = array(
- "HTTP_ACCEPT" => "application/json"
- , 'REQUEST_METHOD' => 'GET'
- , 'SCRIPT_FILENAME' => 'my/base/path/my/request/uri/filename'
- , "REQUEST_URI" => "my/base/path/my/request/uri"
- , 'PHP_SELF' => 'my/base/path'
- );
- $request = new Request(array("callback" => ""), array(), array(), array(), array(), $server);
-
- $api_result = new API_V1_result($request, $this->api);
- $api_result->set_datas(array("pirouette" => "cacahuete", "black" => true, "bob" => array("bob")));
- $response = json_decode($api_result->format());
- $this->checkResponseFieldResponse($response, "pirouette", "cacahuete", PHPUnit_Framework_Constraint_IsType::TYPE_STRING);
- $this->checkResponseFieldResponse($response, "black", true, PHPUnit_Framework_Constraint_IsType::TYPE_BOOL);
- $this->checkResponseFieldResponse($response, "bob", array("bob"), PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY);
- }
-
- protected function checkResponseFieldMeta(stdClass $response, $field, $expected_value, $type)
- {
- $this->assertObjectHasAttribute($field, $response->meta);
- $this->assertInternalType($type, $response->meta->$field);
- $this->assertEquals($expected_value, $response->meta->$field);
- }
-
- protected function checkResponseFieldResponse(stdClass $response, $field, $expected_value, $type)
- {
- $this->assertObjectHasAttribute($field, $response->response);
- $this->assertInternalType($type, $response->response->$field);
- $this->assertEquals($expected_value, $response->response->$field);
- }
-
- public function testGet_content_type()
- {
- $server = array("HTTP_ACCEPT" => "application/json");
- $request = new Request(array("callback" => ""), array(), array(), array(), array(), $server);
- $api_result = new API_V1_result($request, $this->api);
- $this->assertEquals("application/json", $api_result->get_content_type());
-
- $server = array("HTTP_ACCEPT" => "application/yaml");
- $request = new Request(array("callback" => ""), array(), array(), array(), array(), $server);
- $api_result = new API_V1_result($request, $this->api);
- $this->assertEquals('application/yaml', $api_result->get_content_type());
-
- $server = array("HTTP_ACCEPT" => "text/yaml");
- $request = new Request(array("callback" => ""), array(), array(), array(), array(), $server);
- $api_result = new API_V1_result($request, $this->api);
- $this->assertEquals('application/yaml', $api_result->get_content_type());
-
- $server = array("HTTP_ACCEPT" => "");
- $request = new Request(array("callback" => "hello"), array(), array(), array(), array(), $server);
- $api_result = new API_V1_result($request, $this->api);
- $this->assertEquals('text/javascript', $api_result->get_content_type());
-
- $server = array("HTTP_ACCEPT" => "unknow");
- $request = new Request(array("callback" => ""), array(), array(), array(), array(), $server);
- $api_result = new API_V1_result($request, $this->api);
- $this->assertEquals("application/json", $api_result->get_content_type());
- }
-
- /**
- * @depends testFormat
- */
- public function testSet_error_message()
- {
- $api_result = new API_V1_result(new Request(), $this->api);
- $api_result->set_error_message(API_V1_result::ERROR_BAD_REQUEST);
- $this->assertErrorMessage($api_result, 400, API_V1_result::ERROR_BAD_REQUEST, API_V1_exception_badrequest::get_details());
-
- $api_result = new API_V1_result(new Request(), $this->api);
- $api_result->set_error_message(API_V1_result::ERROR_UNAUTHORIZED);
- $this->assertErrorMessage($api_result, 401, API_V1_result::ERROR_UNAUTHORIZED, API_V1_exception_unauthorized::get_details());
-
- $api_result = new API_V1_result(new Request(), $this->api);
- $api_result->set_error_message(API_V1_result::ERROR_FORBIDDEN);
- $this->assertErrorMessage($api_result, 403, API_V1_result::ERROR_FORBIDDEN, API_V1_exception_forbidden::get_details());
-
- $api_result = new API_V1_result(new Request(), $this->api);
- $api_result->set_error_message(API_V1_result::ERROR_NOTFOUND);
- $this->assertErrorMessage($api_result, 404, API_V1_result::ERROR_NOTFOUND, API_V1_exception_notfound::get_details());
-
- $api_result = new API_V1_result(new Request(), $this->api);
- $api_result->set_error_message(API_V1_result::ERROR_METHODNOTALLOWED);
- $this->assertErrorMessage($api_result, 405, API_V1_result::ERROR_METHODNOTALLOWED, API_V1_exception_methodnotallowed::get_details());
-
- $api_result = new API_V1_result(new Request(), $this->api);
- $api_result->set_error_message(API_V1_result::ERROR_INTERNALSERVERERROR);
- $this->assertErrorMessage($api_result, 500, API_V1_result::ERROR_INTERNALSERVERERROR, API_V1_exception_internalservererror::get_details());
-
- $api_result = new API_V1_result(new Request(), $this->api);
- $api_result->set_error_message(OAUTH2_ERROR_INVALID_REQUEST);
- $this->assertErrorMessage($api_result, 200, OAUTH2_ERROR_INVALID_REQUEST, NULL);
- }
-
- protected function assertErrorMessage(API_V1_result $api_result, $code, $message, $detail)
- {
- $response = json_decode($api_result->format());
- $this->checkResponseFieldMeta($response, 'http_code', $code, PHPUnit_Framework_Constraint_IsType::TYPE_INT);
-
- if (is_null($message))
- {
- $this->assertObjectHasAttribute('error_message', $response->meta);
- $this->assertNull($response->meta->error_message);
- }
- else
- {
- $this->checkResponseFieldMeta($response, 'error_message', $message, PHPUnit_Framework_Constraint_IsType::TYPE_STRING);
+ $api_result = new API_V1_result($request, $this->api);
+ $return = $api_result->format();
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $return);
+ $this->assertRegexp("/my_callback_function\(\{.+\}\)/", $return);
}
- if (is_null($detail))
+ /**
+ * @depends testFormat
+ */
+ public function testSet_datas()
{
- $this->assertObjectHasAttribute('error_details', $response->meta);
- $this->assertNull($response->meta->error_details);
+ $server = array(
+ "HTTP_ACCEPT" => "application/json"
+ , 'REQUEST_METHOD' => 'GET'
+ , 'SCRIPT_FILENAME' => 'my/base/path/my/request/uri/filename'
+ , "REQUEST_URI" => "my/base/path/my/request/uri"
+ , 'PHP_SELF' => 'my/base/path'
+ );
+ $request = new Request(array("callback" => ""), array(), array(), array(), array(), $server);
+
+ $api_result = new API_V1_result($request, $this->api);
+ $api_result->set_datas(array("pirouette" => "cacahuete", "black" => true, "bob" => array("bob")));
+ $response = json_decode($api_result->format());
+ $this->checkResponseFieldResponse($response, "pirouette", "cacahuete", PHPUnit_Framework_Constraint_IsType::TYPE_STRING);
+ $this->checkResponseFieldResponse($response, "black", true, PHPUnit_Framework_Constraint_IsType::TYPE_BOOL);
+ $this->checkResponseFieldResponse($response, "bob", array("bob"), PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY);
}
- else
+
+ protected function checkResponseFieldMeta(stdClass $response, $field, $expected_value, $type)
{
- $this->checkResponseFieldMeta($response, 'error_details', $detail, PHPUnit_Framework_Constraint_IsType::TYPE_STRING);
+ $this->assertObjectHasAttribute($field, $response->meta);
+ $this->assertInternalType($type, $response->meta->$field);
+ $this->assertEquals($expected_value, $response->meta->$field);
}
- }
- /**
- * @depends testFormat
- */
- public function testSet_error_code()
- {
- $api_result = new API_V1_result(new Request(), $this->api);
- $api_result->set_error_code(400);
- $this->assertErrorMessage($api_result, 400, API_V1_result::ERROR_BAD_REQUEST, API_V1_exception_badrequest::get_details());
+ protected function checkResponseFieldResponse(stdClass $response, $field, $expected_value, $type)
+ {
+ $this->assertObjectHasAttribute($field, $response->response);
+ $this->assertInternalType($type, $response->response->$field);
+ $this->assertEquals($expected_value, $response->response->$field);
+ }
- $api_result = new API_V1_result(new Request(), $this->api);
- $api_result->set_error_code(401);
- $this->assertErrorMessage($api_result, 401, API_V1_result::ERROR_UNAUTHORIZED, API_V1_exception_unauthorized::get_details());
+ public function testGet_content_type()
+ {
+ $server = array("HTTP_ACCEPT" => "application/json");
+ $request = new Request(array("callback" => ""), array(), array(), array(), array(), $server);
+ $api_result = new API_V1_result($request, $this->api);
+ $this->assertEquals("application/json", $api_result->get_content_type());
- $api_result = new API_V1_result(new Request(), $this->api);
- $api_result->set_error_code(403);
- $this->assertErrorMessage($api_result, 403, API_V1_result::ERROR_FORBIDDEN, API_V1_exception_forbidden::get_details());
+ $server = array("HTTP_ACCEPT" => "application/yaml");
+ $request = new Request(array("callback" => ""), array(), array(), array(), array(), $server);
+ $api_result = new API_V1_result($request, $this->api);
+ $this->assertEquals('application/yaml', $api_result->get_content_type());
- $api_result = new API_V1_result(new Request(), $this->api);
- $api_result->set_error_code(404);
- $this->assertErrorMessage($api_result, 404, API_V1_result::ERROR_NOTFOUND, API_V1_exception_notfound::get_details());
+ $server = array("HTTP_ACCEPT" => "text/yaml");
+ $request = new Request(array("callback" => ""), array(), array(), array(), array(), $server);
+ $api_result = new API_V1_result($request, $this->api);
+ $this->assertEquals('application/yaml', $api_result->get_content_type());
- $api_result = new API_V1_result(new Request(), $this->api);
- $api_result->set_error_code(405);
- $this->assertErrorMessage($api_result, 405, API_V1_result::ERROR_METHODNOTALLOWED, API_V1_exception_methodnotallowed::get_details());
+ $server = array("HTTP_ACCEPT" => "");
+ $request = new Request(array("callback" => "hello"), array(), array(), array(), array(), $server);
+ $api_result = new API_V1_result($request, $this->api);
+ $this->assertEquals('text/javascript', $api_result->get_content_type());
- $api_result = new API_V1_result(new Request(), $this->api);
- $api_result->set_error_code(500);
- $this->assertErrorMessage($api_result, 500, API_V1_result::ERROR_INTERNALSERVERERROR, API_V1_exception_internalservererror::get_details());
- }
+ $server = array("HTTP_ACCEPT" => "unknow");
+ $request = new Request(array("callback" => ""), array(), array(), array(), array(), $server);
+ $api_result = new API_V1_result($request, $this->api);
+ $this->assertEquals("application/json", $api_result->get_content_type());
+ }
- public function testGet_http_code()
- {
- $api_result = new API_V1_result(new Request(), $this->api);
- $api_result->set_error_code(400);
- $this->assertEquals(400, $api_result->get_http_code());
+ /**
+ * @depends testFormat
+ */
+ public function testSet_error_message()
+ {
+ $api_result = new API_V1_result(new Request(), $this->api);
+ $api_result->set_error_message(API_V1_result::ERROR_BAD_REQUEST);
+ $this->assertErrorMessage($api_result, 400, API_V1_result::ERROR_BAD_REQUEST, API_V1_exception_badrequest::get_details());
- $api_result = new API_V1_result(new Request(), $this->api);
- $api_result->set_error_code(401);
- $this->assertEquals(401, $api_result->get_http_code());
+ $api_result = new API_V1_result(new Request(), $this->api);
+ $api_result->set_error_message(API_V1_result::ERROR_UNAUTHORIZED);
+ $this->assertErrorMessage($api_result, 401, API_V1_result::ERROR_UNAUTHORIZED, API_V1_exception_unauthorized::get_details());
- $api_result = new API_V1_result(new Request(), $this->api);
- $api_result->set_error_code(403);
- $this->assertEquals(403, $api_result->get_http_code());
+ $api_result = new API_V1_result(new Request(), $this->api);
+ $api_result->set_error_message(API_V1_result::ERROR_FORBIDDEN);
+ $this->assertErrorMessage($api_result, 403, API_V1_result::ERROR_FORBIDDEN, API_V1_exception_forbidden::get_details());
- $api_result = new API_V1_result(new Request(), $this->api);
- $api_result->set_error_code(404);
- $this->assertEquals(404, $api_result->get_http_code());
+ $api_result = new API_V1_result(new Request(), $this->api);
+ $api_result->set_error_message(API_V1_result::ERROR_NOTFOUND);
+ $this->assertErrorMessage($api_result, 404, API_V1_result::ERROR_NOTFOUND, API_V1_exception_notfound::get_details());
- $api_result = new API_V1_result(new Request(), $this->api);
- $api_result->set_error_code(405);
- $this->assertEquals(405, $api_result->get_http_code());
+ $api_result = new API_V1_result(new Request(), $this->api);
+ $api_result->set_error_message(API_V1_result::ERROR_METHODNOTALLOWED);
+ $this->assertErrorMessage($api_result, 405, API_V1_result::ERROR_METHODNOTALLOWED, API_V1_exception_methodnotallowed::get_details());
- $api_result = new API_V1_result(new Request(), $this->api);
- $api_result->set_error_code(500);
- $this->assertEquals(500, $api_result->get_http_code());
+ $api_result = new API_V1_result(new Request(), $this->api);
+ $api_result->set_error_message(API_V1_result::ERROR_INTERNALSERVERERROR);
+ $this->assertErrorMessage($api_result, 500, API_V1_result::ERROR_INTERNALSERVERERROR, API_V1_exception_internalservererror::get_details());
- $api_result = new API_V1_result(new Request(array("callback" => "my_callback")), $this->api);
- $api_result->set_error_code(400);
- $this->assertEquals(200, $api_result->get_http_code());
+ $api_result = new API_V1_result(new Request(), $this->api);
+ $api_result->set_error_message(OAUTH2_ERROR_INVALID_REQUEST);
+ $this->assertErrorMessage($api_result, 200, OAUTH2_ERROR_INVALID_REQUEST, NULL);
+ }
- $api_result = new API_V1_result(new Request(array("callback" => "my_callback")), $this->api);
- $api_result->set_error_code(500);
- $this->assertEquals(500, $api_result->get_http_code());
- }
+ protected function assertErrorMessage(API_V1_result $api_result, $code, $message, $detail)
+ {
+ $response = json_decode($api_result->format());
+ $this->checkResponseFieldMeta($response, 'http_code', $code, PHPUnit_Framework_Constraint_IsType::TYPE_INT);
- public function testSet_http_code()
- {
- $api_result = new API_V1_result(new Request(), $this->api);
- $api_result->set_http_code(500);
- $this->assertEquals(500, $api_result->get_http_code());
+ if (is_null($message)) {
+ $this->assertObjectHasAttribute('error_message', $response->meta);
+ $this->assertNull($response->meta->error_message);
+ } else {
+ $this->checkResponseFieldMeta($response, 'error_message', $message, PHPUnit_Framework_Constraint_IsType::TYPE_STRING);
+ }
- $api_result->set_http_code(400);
- $this->assertEquals(400, $api_result->get_http_code());
- $api_result->set_http_code(401);
- $this->assertEquals(401, $api_result->get_http_code());
- $api_result->set_http_code(403);
- $this->assertEquals(403, $api_result->get_http_code());
+ if (is_null($detail)) {
+ $this->assertObjectHasAttribute('error_details', $response->meta);
+ $this->assertNull($response->meta->error_details);
+ } else {
+ $this->checkResponseFieldMeta($response, 'error_details', $detail, PHPUnit_Framework_Constraint_IsType::TYPE_STRING);
+ }
+ }
- $api_result = new API_V1_result(new Request(array("callback" => "my_callback")), $this->api);
- $api_result->set_http_code(500);
- $this->assertEquals(500, $api_result->get_http_code());
+ /**
+ * @depends testFormat
+ */
+ public function testSet_error_code()
+ {
+ $api_result = new API_V1_result(new Request(), $this->api);
+ $api_result->set_error_code(400);
+ $this->assertErrorMessage($api_result, 400, API_V1_result::ERROR_BAD_REQUEST, API_V1_exception_badrequest::get_details());
- $api_result->set_http_code(400);
- $this->assertEquals(200, $api_result->get_http_code());
+ $api_result = new API_V1_result(new Request(), $this->api);
+ $api_result->set_error_code(401);
+ $this->assertErrorMessage($api_result, 401, API_V1_result::ERROR_UNAUTHORIZED, API_V1_exception_unauthorized::get_details());
- $api_result->set_http_code(401);
- $this->assertEquals(200, $api_result->get_http_code());
+ $api_result = new API_V1_result(new Request(), $this->api);
+ $api_result->set_error_code(403);
+ $this->assertErrorMessage($api_result, 403, API_V1_result::ERROR_FORBIDDEN, API_V1_exception_forbidden::get_details());
- $api_result->set_http_code(403);
- $this->assertEquals(200, $api_result->get_http_code());
+ $api_result = new API_V1_result(new Request(), $this->api);
+ $api_result->set_error_code(404);
+ $this->assertErrorMessage($api_result, 404, API_V1_result::ERROR_NOTFOUND, API_V1_exception_notfound::get_details());
- $api_result->set_http_code(404);
- $this->assertEquals(200, $api_result->get_http_code());
+ $api_result = new API_V1_result(new Request(), $this->api);
+ $api_result->set_error_code(405);
+ $this->assertErrorMessage($api_result, 405, API_V1_result::ERROR_METHODNOTALLOWED, API_V1_exception_methodnotallowed::get_details());
- $api_result->set_http_code(405);
- $this->assertEquals(200, $api_result->get_http_code());
- }
+ $api_result = new API_V1_result(new Request(), $this->api);
+ $api_result->set_error_code(500);
+ $this->assertErrorMessage($api_result, 500, API_V1_result::ERROR_INTERNALSERVERERROR, API_V1_exception_internalservererror::get_details());
+ }
+ public function testGet_http_code()
+ {
+ $api_result = new API_V1_result(new Request(), $this->api);
+ $api_result->set_error_code(400);
+ $this->assertEquals(400, $api_result->get_http_code());
+
+ $api_result = new API_V1_result(new Request(), $this->api);
+ $api_result->set_error_code(401);
+ $this->assertEquals(401, $api_result->get_http_code());
+
+ $api_result = new API_V1_result(new Request(), $this->api);
+ $api_result->set_error_code(403);
+ $this->assertEquals(403, $api_result->get_http_code());
+
+ $api_result = new API_V1_result(new Request(), $this->api);
+ $api_result->set_error_code(404);
+ $this->assertEquals(404, $api_result->get_http_code());
+
+ $api_result = new API_V1_result(new Request(), $this->api);
+ $api_result->set_error_code(405);
+ $this->assertEquals(405, $api_result->get_http_code());
+
+ $api_result = new API_V1_result(new Request(), $this->api);
+ $api_result->set_error_code(500);
+ $this->assertEquals(500, $api_result->get_http_code());
+
+ $api_result = new API_V1_result(new Request(array("callback" => "my_callback")), $this->api);
+ $api_result->set_error_code(400);
+ $this->assertEquals(200, $api_result->get_http_code());
+
+ $api_result = new API_V1_result(new Request(array("callback" => "my_callback")), $this->api);
+ $api_result->set_error_code(500);
+ $this->assertEquals(500, $api_result->get_http_code());
+ }
+
+ public function testSet_http_code()
+ {
+ $api_result = new API_V1_result(new Request(), $this->api);
+ $api_result->set_http_code(500);
+ $this->assertEquals(500, $api_result->get_http_code());
+
+ $api_result->set_http_code(400);
+ $this->assertEquals(400, $api_result->get_http_code());
+ $api_result->set_http_code(401);
+ $this->assertEquals(401, $api_result->get_http_code());
+ $api_result->set_http_code(403);
+ $this->assertEquals(403, $api_result->get_http_code());
+
+ $api_result = new API_V1_result(new Request(array("callback" => "my_callback")), $this->api);
+ $api_result->set_http_code(500);
+ $this->assertEquals(500, $api_result->get_http_code());
+
+ $api_result->set_http_code(400);
+ $this->assertEquals(200, $api_result->get_http_code());
+
+ $api_result->set_http_code(401);
+ $this->assertEquals(200, $api_result->get_http_code());
+
+ $api_result->set_http_code(403);
+ $this->assertEquals(200, $api_result->get_http_code());
+
+ $api_result->set_http_code(404);
+ $this->assertEquals(200, $api_result->get_http_code());
+
+ $api_result->set_http_code(405);
+ $this->assertEquals(200, $api_result->get_http_code());
+ }
}
diff --git a/tests/bootstrap.inc b/tests/bootstrap.inc
index 277b8a8742..deff8c2f40 100644
--- a/tests/bootstrap.inc
+++ b/tests/bootstrap.inc
@@ -1,20 +1,5 @@
object = new caption_record(self::$record_1, self::$record_1->get_databox());
- }
-
- /**
- * @covers \caption_record::serializeXML
- */
- public function testSerializeXML()
- {
-
- foreach (self::$record_1->get_databox()->get_meta_structure() as $databox_field)
+ public function setUp()
{
- $n = $databox_field->is_multi() ? 3 : 1;
-
- for ($i = 0; $i < $n; $i++)
- {
- \caption_Field_Value::create($databox_field, self::$record_1, \random::generatePassword());
- }
+ parent::setUp();
+ $this->object = new caption_record(self::$record_1, self::$record_1->get_databox());
}
- $xml = $this->object->serialize(\caption_record::SERIALIZE_XML);
-
- $sxe = simplexml_load_string($xml);
- $this->assertInstanceOf('SimpleXMLElement', $sxe);
-
- foreach (self::$record_1->get_caption()->get_fields() as $field)
+ /**
+ * @covers \caption_record::serializeXML
+ */
+ public function testSerializeXML()
{
- if($field->get_databox_field()->is_multi())
- {
- $tagname = $field->get_name();
- $retrieved = array();
- foreach($sxe->description->$tagname as $value)
- {
- $retrieved[] = (string) $value;
+
+ foreach (self::$record_1->get_databox()->get_meta_structure() as $databox_field) {
+ $n = $databox_field->is_multi() ? 3 : 1;
+
+ for ($i = 0; $i < $n; $i ++ ) {
+ \caption_Field_Value::create($databox_field, self::$record_1, \random::generatePassword());
+ }
}
- $values = $field->get_values();
- $this->assertEquals(count($values), count($retrieved));
- foreach($values as $val)
- {
- $this->assertTrue(in_array($val->getValue(), $retrieved));
+ $xml = $this->object->serialize(\caption_record::SERIALIZE_XML);
+
+ $sxe = simplexml_load_string($xml);
+ $this->assertInstanceOf('SimpleXMLElement', $sxe);
+
+ foreach (self::$record_1->get_caption()->get_fields() as $field) {
+ if ($field->get_databox_field()->is_multi()) {
+ $tagname = $field->get_name();
+ $retrieved = array();
+ foreach ($sxe->description->$tagname as $value) {
+ $retrieved[] = (string) $value;
+ }
+
+ $values = $field->get_values();
+ $this->assertEquals(count($values), count($retrieved));
+ foreach ($values as $val) {
+ $this->assertTrue(in_array($val->getValue(), $retrieved));
+ }
+ } else {
+ $tagname = $field->get_name();
+ $value = array_pop($field->get_values());
+ $this->assertEquals($value->getValue(), (string) $sxe->description->$tagname);
+ }
}
- }
- else
- {
- $tagname = $field->get_name();
- $value = array_pop($field->get_values());
- $this->assertEquals($value->getValue(), (string) $sxe->description->$tagname);
- }
}
- }
- /**
- * @covers \caption_record::serializeYAML
- */
- public function testSerializeYAML()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
+ /**
+ * @covers \caption_record::serializeYAML
+ */
+ public function testSerializeYAML()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
- /**
- * @covers \caption_record::get_fields
- * @todo Implement testGet_fields().
- */
- public function testGet_fields()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
+ /**
+ * @covers \caption_record::get_fields
+ * @todo Implement testGet_fields().
+ */
+ public function testGet_fields()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
- /**
- * @covers \caption_record::get_field
- * @todo Implement testGet_field().
- */
- public function testGet_field()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
+ /**
+ * @covers \caption_record::get_field
+ * @todo Implement testGet_field().
+ */
+ public function testGet_field()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
- /**
- * @covers \caption_record::get_dc_field
- * @todo Implement testGet_dc_field().
- */
- public function testGet_dc_field()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
+ /**
+ * @covers \caption_record::get_dc_field
+ * @todo Implement testGet_dc_field().
+ */
+ public function testGet_dc_field()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
- /**
- * @covers \caption_record::get_highlight_fields
- * @todo Implement testGet_highlight_fields().
- */
- public function testGet_highlight_fields()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
+ /**
+ * @covers \caption_record::get_highlight_fields
+ * @todo Implement testGet_highlight_fields().
+ */
+ public function testGet_highlight_fields()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
- /**
- * @covers \caption_record::get_cache_key
- * @todo Implement testGet_cache_key().
- */
- public function testGet_cache_key()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
+ /**
+ * @covers \caption_record::get_cache_key
+ * @todo Implement testGet_cache_key().
+ */
+ public function testGet_cache_key()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
- /**
- * @covers \caption_record::get_data_from_cache
- * @todo Implement testGet_data_from_cache().
- */
- public function testGet_data_from_cache()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
+ /**
+ * @covers \caption_record::get_data_from_cache
+ * @todo Implement testGet_data_from_cache().
+ */
+ public function testGet_data_from_cache()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
- /**
- * @covers \caption_record::set_data_to_cache
- * @todo Implement testSet_data_to_cache().
- */
- public function testSet_data_to_cache()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @covers \caption_record::delete_data_from_cache
- * @todo Implement testDelete_data_from_cache().
- */
- public function testDelete_data_from_cache()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
+ /**
+ * @covers \caption_record::set_data_to_cache
+ * @todo Implement testSet_data_to_cache().
+ */
+ public function testSet_data_to_cache()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+ /**
+ * @covers \caption_record::delete_data_from_cache
+ * @todo Implement testDelete_data_from_cache().
+ */
+ public function testDelete_data_from_cache()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
}
diff --git a/tests/collectionTest.php b/tests/collectionTest.php
index ba4d83906b..3652dc1540 100644
--- a/tests/collectionTest.php
+++ b/tests/collectionTest.php
@@ -4,357 +4,348 @@ require_once __DIR__ . '/PhraseanetPHPUnitAuthenticatedAbstract.class.inc';
class collectionTest extends PhraseanetPHPUnitAuthenticatedAbstract
{
+ /**
+ * @var collection
+ */
+ protected static $object;
- /**
- * @var collection
- */
- protected static $object;
-
- public static function setUpBeforeClass()
- {
- parent::setUpBeforeClass();
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $auth = new Session_Authentication_None(self::$user);
- $appbox->get_session()->authenticate($auth);
-
- $found = false;
- foreach ($appbox->get_databoxes() as $databox)
+ public static function setUpBeforeClass()
{
- $found = true;
- break;
+ parent::setUpBeforeClass();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $auth = new Session_Authentication_None(self::$user);
+ $appbox->get_session()->authenticate($auth);
+
+ $found = false;
+ foreach ($appbox->get_databoxes() as $databox) {
+ $found = true;
+ break;
+ }
+
+ if ( ! $found)
+ self::fail('No databox found for collection test');
+
+ self::$object = collection::create($databox, $appbox, 'test_collection', self::$user);
+
+ if ( ! self::$object instanceof collection)
+ self::fail('Unable to create collection');
}
- if (!$found)
- self::fail('No databox found for collection test');
-
- self::$object = collection::create($databox, $appbox, 'test_collection', self::$user);
-
- if (!self::$object instanceof collection)
- self::fail('Unable to create collection');
- }
-
- public static function tearDownAfterClass()
- {
-
- self::$object->delete();
- parent::tearDownAfterClass();
- }
-
- public function testEnable()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $base_id = self::$object->get_base_id();
- $coll_id = self::$object->get_coll_id();
- self::$object->disable($appbox);
- $this->assertTrue(is_int(self::$object->get_base_id()));
- $this->assertTrue(is_int(self::$object->get_coll_id()));
- $this->assertFalse(self::$object->is_active());
-
- $sbas_id = self::$object->get_databox()->get_sbas_id();
- $databox = databox::get_instance($sbas_id);
-
- foreach ($databox->get_collections() as $collection)
+ public static function tearDownAfterClass()
{
- $this->assertTrue($collection->get_base_id() !== $base_id);
- $this->assertTrue($collection->get_coll_id() !== $coll_id);
+
+ self::$object->delete();
+ parent::tearDownAfterClass();
}
- self::$object->enable($appbox);
- $this->assertTrue(is_int(self::$object->get_base_id()));
- $this->assertTrue(is_int(self::$object->get_coll_id()));
- $this->assertTrue(self::$object->is_active());
-
- $databox = databox::get_instance($sbas_id);
-
- $n = $m = 0;
- foreach ($databox->get_collections() as $collection)
+ public function testEnable()
{
- if ($collection->get_base_id() === $base_id)
- $n++;
- if ($collection->get_coll_id() === $coll_id)
- $m++;
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $base_id = self::$object->get_base_id();
+ $coll_id = self::$object->get_coll_id();
+ self::$object->disable($appbox);
+ $this->assertTrue(is_int(self::$object->get_base_id()));
+ $this->assertTrue(is_int(self::$object->get_coll_id()));
+ $this->assertFalse(self::$object->is_active());
+
+ $sbas_id = self::$object->get_databox()->get_sbas_id();
+ $databox = databox::get_instance($sbas_id);
+
+ foreach ($databox->get_collections() as $collection) {
+ $this->assertTrue($collection->get_base_id() !== $base_id);
+ $this->assertTrue($collection->get_coll_id() !== $coll_id);
+ }
+
+ self::$object->enable($appbox);
+ $this->assertTrue(is_int(self::$object->get_base_id()));
+ $this->assertTrue(is_int(self::$object->get_coll_id()));
+ $this->assertTrue(self::$object->is_active());
+
+ $databox = databox::get_instance($sbas_id);
+
+ $n = $m = 0;
+ foreach ($databox->get_collections() as $collection) {
+ if ($collection->get_base_id() === $base_id)
+ $n ++;
+ if ($collection->get_coll_id() === $coll_id)
+ $m ++;
+ }
+ $this->assertEquals($n, 1);
+ $this->assertEquals($m, 1);
}
- $this->assertEquals($n, 1);
- $this->assertEquals($m, 1);
- }
- public function testDisable()
- {
- $this->testEnable();
- }
-
- public function testEmpty_collection()
- {
- $record = record_adapter::create(self::$object, new system_file(__DIR__ . '/testfiles/cestlafete.jpg'));
- $this->assertTrue(self::$object->get_record_amount() > 0);
- self::$object->empty_collection();
- $this->assertTrue(self::$object->get_record_amount() === 0);
- }
-
- public function testIs_active()
- {
- $this->assertTrue(is_bool(self::$object->is_active()));
- }
-
- public function testGet_databox()
- {
- $this->assertInstanceOf('databox', self::$object->get_databox());
- }
-
- public function testGet_connection()
- {
- $this->assertInstanceOf('connection_pdo', self::$object->get_connection());
- }
-
- /**
- * @todo Implement testSet_public_presentation().
- */
- public function testSet_public_presentation()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- public function testSet_name()
- {
- self::$object->set_name('babababe bi bo bu');
- $this->assertEquals('babababe bi bo bu', self::$object->get_name());
- self::$object->set_name('babaé&\'" bi bo bu');
- $this->assertEquals('babaé&\'" bi bo bu', self::$object->get_name());
- self::$object->set_name('babababe bi bo bu');
- $this->assertEquals('babababe bi bo bu', self::$object->get_name());
- self::$object->set_name('babababe bi bo bu');
- $this->assertEquals('babababe bi bo bu', self::$object->get_name());
- }
-
- public function testGet_record_amount()
- {
- self::$object->empty_collection();
- $record = record_adapter::create(self::$object, new system_file(__DIR__ . '/testfiles/cestlafete.jpg'));
- $this->assertTrue(self::$object->get_record_amount() === 1);
- self::$object->empty_collection();
- $this->assertTrue(self::$object->get_record_amount() === 0);
- }
-
- public function testGet_record_details()
- {
- $record = record_adapter::create(self::$object, new system_file(__DIR__ . '/testfiles/cestlafete.jpg'));
- $details = self::$object->get_record_details();
-
- $this->assertTrue(is_array($details));
- foreach ($details as $detail)
+ public function testDisable()
{
- $this->assertTrue(is_array($detail));
- $this->assertArrayHasKey('coll_id', $detail);
- $this->asserttrue(is_int($detail['coll_id']));
- $this->assertArrayHasKey('name', $detail);
- $this->asserttrue(is_string($detail['name']));
- $this->assertArrayHasKey('amount', $detail);
- $this->asserttrue(is_int($detail['amount']));
- $this->assertArrayHasKey('size', $detail);
- $this->asserttrue(is_int($detail['size']));
+ $this->testEnable();
}
- }
- public function testUpdate_logo()
- {
- $pathfile = new system_file(__DIR__ . '/testfiles/logocoll.gif');
- self::$object->update_logo($pathfile);
- $this->assertEquals(file_get_contents($pathfile->getPathname()), self::$object->get_binary_minilogos());
- }
+ public function testEmpty_collection()
+ {
+ $record = record_adapter::create(self::$object, new system_file(__DIR__ . '/testfiles/cestlafete.jpg'));
+ $this->assertTrue(self::$object->get_record_amount() > 0);
+ self::$object->empty_collection();
+ $this->assertTrue(self::$object->get_record_amount() === 0);
+ }
- public function testReset_watermark()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
+ public function testIs_active()
+ {
+ $this->assertTrue(is_bool(self::$object->is_active()));
+ }
+
+ public function testGet_databox()
+ {
+ $this->assertInstanceOf('databox', self::$object->get_databox());
+ }
+
+ public function testGet_connection()
+ {
+ $this->assertInstanceOf('connection_pdo', self::$object->get_connection());
+ }
+
+ /**
+ * @todo Implement testSet_public_presentation().
+ */
+ public function testSet_public_presentation()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
'This test has not been implemented yet.'
- );
- }
+ );
+ }
- public function testDelete()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
+ public function testSet_name()
+ {
+ self::$object->set_name('babababe bi bo bu');
+ $this->assertEquals('babababe bi bo bu', self::$object->get_name());
+ self::$object->set_name('babaé&\'" bi bo bu');
+ $this->assertEquals('babaé&\'" bi bo bu', self::$object->get_name());
+ self::$object->set_name('babababe bi bo bu');
+ $this->assertEquals('babababe bi bo bu', self::$object->get_name());
+ self::$object->set_name('babababe bi bo bu');
+ $this->assertEquals('babababe bi bo bu', self::$object->get_name());
+ }
+
+ public function testGet_record_amount()
+ {
+ self::$object->empty_collection();
+ $record = record_adapter::create(self::$object, new system_file(__DIR__ . '/testfiles/cestlafete.jpg'));
+ $this->assertTrue(self::$object->get_record_amount() === 1);
+ self::$object->empty_collection();
+ $this->assertTrue(self::$object->get_record_amount() === 0);
+ }
+
+ public function testGet_record_details()
+ {
+ $record = record_adapter::create(self::$object, new system_file(__DIR__ . '/testfiles/cestlafete.jpg'));
+ $details = self::$object->get_record_details();
+
+ $this->assertTrue(is_array($details));
+ foreach ($details as $detail) {
+ $this->assertTrue(is_array($detail));
+ $this->assertArrayHasKey('coll_id', $detail);
+ $this->asserttrue(is_int($detail['coll_id']));
+ $this->assertArrayHasKey('name', $detail);
+ $this->asserttrue(is_string($detail['name']));
+ $this->assertArrayHasKey('amount', $detail);
+ $this->asserttrue(is_int($detail['amount']));
+ $this->assertArrayHasKey('size', $detail);
+ $this->asserttrue(is_int($detail['size']));
+ }
+ }
+
+ public function testUpdate_logo()
+ {
+ $pathfile = new system_file(__DIR__ . '/testfiles/logocoll.gif');
+ self::$object->update_logo($pathfile);
+ $this->assertEquals(file_get_contents($pathfile->getPathname()), self::$object->get_binary_minilogos());
+ }
+
+ public function testReset_watermark()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
'This test has not been implemented yet.'
- );
- }
+ );
+ }
- public function testGet_binary_minilogos()
- {
- $this->testUpdate_logo();
- }
-
- public function testGet_from_base_id()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
+ public function testDelete()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
'This test has not been implemented yet.'
- );
- }
+ );
+ }
- public function testGet_from_coll_id()
- {
- $temp_coll = collection::get_from_coll_id(self::$object->get_databox(), self::$object->get_coll_id());
- $this->assertEquals(self::$object->get_coll_id(), $temp_coll->get_coll_id());
- $this->assertEquals(self::$object->get_base_id(), $temp_coll->get_base_id());
- }
+ public function testGet_binary_minilogos()
+ {
+ $this->testUpdate_logo();
+ }
- public function testGet_base_id()
- {
- $this->assertTrue(is_int(self::$object->get_base_id()));
- $this->assertTrue(self::$object->get_base_id() > 0);
- }
-
- public function testGet_sbas_id()
- {
- $this->assertTrue(is_int(self::$object->get_sbas_id()));
- $this->assertEquals(self::$object->get_sbas_id(), self::$object->get_databox()->get_sbas_id());
- }
-
- public function testGet_coll_id()
- {
- $this->assertTrue(is_int(self::$object->get_coll_id()));
- $this->assertTrue(self::$object->get_coll_id() > 0);
- }
-
- /**
- * @todo Implement testGet_prefs().
- */
- public function testGet_prefs()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
+ public function testGet_from_base_id()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
'This test has not been implemented yet.'
- );
- }
+ );
+ }
- /**
- * @todo Implement testSet_prefs().
- */
- public function testSet_prefs()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
+ public function testGet_from_coll_id()
+ {
+ $temp_coll = collection::get_from_coll_id(self::$object->get_databox(), self::$object->get_coll_id());
+ $this->assertEquals(self::$object->get_coll_id(), $temp_coll->get_coll_id());
+ $this->assertEquals(self::$object->get_base_id(), $temp_coll->get_base_id());
+ }
+
+ public function testGet_base_id()
+ {
+ $this->assertTrue(is_int(self::$object->get_base_id()));
+ $this->assertTrue(self::$object->get_base_id() > 0);
+ }
+
+ public function testGet_sbas_id()
+ {
+ $this->assertTrue(is_int(self::$object->get_sbas_id()));
+ $this->assertEquals(self::$object->get_sbas_id(), self::$object->get_databox()->get_sbas_id());
+ }
+
+ public function testGet_coll_id()
+ {
+ $this->assertTrue(is_int(self::$object->get_coll_id()));
+ $this->assertTrue(self::$object->get_coll_id() > 0);
+ }
+
+ /**
+ * @todo Implement testGet_prefs().
+ */
+ public function testGet_prefs()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
'This test has not been implemented yet.'
- );
- }
+ );
+ }
- /**
- * @todo Implement testGet_name().
- */
- public function testGet_name()
- {
- $this->assertTrue(is_string(self::$object->get_name()));
- $this->assertTrue(trim(strip_tags(self::$object->get_name())) === self::$object->get_name());
- }
-
- /**
- * @todo Implement testGet_pub_wm().
- */
- public function testGet_pub_wm()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
+ /**
+ * @todo Implement testSet_prefs().
+ */
+ public function testSet_prefs()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
'This test has not been implemented yet.'
- );
- }
+ );
+ }
- /**
- * @todo Implement testIs_available().
- */
- public function testIs_available()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
+ public function testGet_name()
+ {
+ $this->assertTrue(is_string(self::$object->get_name()));
+ $this->assertTrue(trim(strip_tags(self::$object->get_name())) === self::$object->get_name());
+ }
+
+ /**
+ * @todo Implement testGet_pub_wm().
+ */
+ public function testGet_pub_wm()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
'This test has not been implemented yet.'
- );
- }
+ );
+ }
- /**
- * @todo Implement testUnmount_collection().
- */
- public function testUnmount_collection()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
+ /**
+ * @todo Implement testIs_available().
+ */
+ public function testIs_available()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
'This test has not been implemented yet.'
- );
- }
+ );
+ }
- /**
- * @todo Implement testCreate().
- */
- public function testCreate()
- {
-
- }
-
- /**
- * @todo Implement testSet_admin().
- */
- public function testSet_admin()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
+ /**
+ * @todo Implement testUnmount_collection().
+ */
+ public function testUnmount_collection()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
'This test has not been implemented yet.'
- );
- }
+ );
+ }
- /**
- * @todo Implement testMount_collection().
- */
- public function testMount_collection()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
+ /**
+ * @todo Implement testCreate().
+ */
+ public function testCreate()
+ {
+
+ }
+
+ /**
+ * @todo Implement testSet_admin().
+ */
+ public function testSet_admin()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
'This test has not been implemented yet.'
- );
- }
+ );
+ }
- /**
- * @todo Implement testGetLogo().
- */
- public function testGetLogo()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
+ /**
+ * @todo Implement testMount_collection().
+ */
+ public function testMount_collection()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
'This test has not been implemented yet.'
- );
- }
+ );
+ }
- /**
- * @todo Implement testGetWatermark().
- */
- public function testGetWatermark()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
+ /**
+ * @todo Implement testGetLogo().
+ */
+ public function testGetLogo()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
'This test has not been implemented yet.'
- );
- }
+ );
+ }
- /**
- * @todo Implement testGetPresentation().
- */
- public function testGetPresentation()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
+ /**
+ * @todo Implement testGetWatermark().
+ */
+ public function testGetWatermark()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
'This test has not been implemented yet.'
- );
- }
+ );
+ }
- /**
- * @todo Implement testGetStamp().
- */
- public function testGetStamp()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
+ /**
+ * @todo Implement testGetPresentation().
+ */
+ public function testGetPresentation()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
'This test has not been implemented yet.'
- );
- }
+ );
+ }
+ /**
+ * @todo Implement testGetStamp().
+ */
+ public function testGetStamp()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
}
diff --git a/tests/databox/Field/DCES/databox_Field_DCES_ContributorTest.php b/tests/databox/Field/DCES/databox_Field_DCES_ContributorTest.php
index 4ed2ed66bd..cbc100136a 100644
--- a/tests/databox/Field/DCES/databox_Field_DCES_ContributorTest.php
+++ b/tests/databox/Field/DCES/databox_Field_DCES_ContributorTest.php
@@ -4,33 +4,31 @@ require_once __DIR__ . '/../../../PhraseanetPHPUnitAbstract.class.inc';
class databox_Field_DCES_ContributorTest extends PhraseanetPHPUnitAbstract
{
+ /**
+ * @var databox_Field_DCES_Contributor
+ */
+ protected $object;
- /**
- * @var databox_Field_DCES_Contributor
- */
- protected $object;
+ public function setUp()
+ {
+ parent::setUp();
+ $this->object = new databox_Field_DCES_Contributor;
+ }
- public function setUp()
- {
- $this->object = new databox_Field_DCES_Contributor;
- }
+ public function testGet_label()
+ {
+ $name = str_replace('Test', '', array_pop(explode('_', __CLASS__)));
+ $this->assertEquals($name, $this->object->get_label());
+ }
- public function testGet_label()
- {
- $name = str_replace('Test', '', array_pop(explode('_', __CLASS__)));
- $this->assertEquals($name, $this->object->get_label());
- }
-
- public function testGet_definition()
- {
- $this->assertTrue(is_string($this->object->get_definition()));
- $this->assertTrue(strlen($this->object->get_definition()) > 20);
- }
-
- public function testGet_documentation_link()
- {
- $this->assertRegExp('/^http:\/\/dublincore\.org\/documents\/dces\/#[a-z]+$/', $this->object->get_documentation_link());
- }
+ public function testGet_definition()
+ {
+ $this->assertTrue(is_string($this->object->get_definition()));
+ $this->assertTrue(strlen($this->object->get_definition()) > 20);
+ }
+ public function testGet_documentation_link()
+ {
+ $this->assertRegExp('/^http:\/\/dublincore\.org\/documents\/dces\/#[a-z]+$/', $this->object->get_documentation_link());
+ }
}
-
diff --git a/tests/databox/Field/DCES/databox_Field_DCES_CoverageTest.php b/tests/databox/Field/DCES/databox_Field_DCES_CoverageTest.php
index 0e06864ada..ae21799f54 100644
--- a/tests/databox/Field/DCES/databox_Field_DCES_CoverageTest.php
+++ b/tests/databox/Field/DCES/databox_Field_DCES_CoverageTest.php
@@ -4,33 +4,31 @@ require_once __DIR__ . '/../../../PhraseanetPHPUnitAbstract.class.inc';
class databox_Field_DCES_CoverageTest extends PhraseanetPHPUnitAbstract
{
+ /**
+ * @var databox_Field_DCES_Coverage
+ */
+ protected $object;
- /**
- * @var databox_Field_DCES_Coverage
- */
- protected $object;
+ public function setUp()
+ {
+ parent::setUp();
+ $this->object = new databox_Field_DCES_Coverage;
+ }
- public function setUp()
- {
- $this->object = new databox_Field_DCES_Coverage;
- }
+ public function testGet_label()
+ {
+ $name = str_replace('Test', '', array_pop(explode('_', __CLASS__)));
+ $this->assertEquals($name, $this->object->get_label());
+ }
- public function testGet_label()
- {
- $name = str_replace('Test', '', array_pop(explode('_', __CLASS__)));
- $this->assertEquals($name, $this->object->get_label());
- }
-
- public function testGet_definition()
- {
- $this->assertTrue(is_string($this->object->get_definition()));
- $this->assertTrue(strlen($this->object->get_definition()) > 20);
- }
-
- public function testGet_documentation_link()
- {
- $this->assertRegExp('/^http:\/\/dublincore\.org\/documents\/dces\/#[a-z]+$/', $this->object->get_documentation_link());
- }
+ public function testGet_definition()
+ {
+ $this->assertTrue(is_string($this->object->get_definition()));
+ $this->assertTrue(strlen($this->object->get_definition()) > 20);
+ }
+ public function testGet_documentation_link()
+ {
+ $this->assertRegExp('/^http:\/\/dublincore\.org\/documents\/dces\/#[a-z]+$/', $this->object->get_documentation_link());
+ }
}
-
diff --git a/tests/databox/Field/DCES/databox_Field_DCES_CreatorTest.php b/tests/databox/Field/DCES/databox_Field_DCES_CreatorTest.php
index 5c9684d441..682e4be596 100644
--- a/tests/databox/Field/DCES/databox_Field_DCES_CreatorTest.php
+++ b/tests/databox/Field/DCES/databox_Field_DCES_CreatorTest.php
@@ -4,33 +4,31 @@ require_once __DIR__ . '/../../../PhraseanetPHPUnitAbstract.class.inc';
class databox_Field_DCES_CreatorTest extends PhraseanetPHPUnitAbstract
{
+ /**
+ * @var databox_Field_DCES_Creator
+ */
+ protected $object;
- /**
- * @var databox_Field_DCES_Creator
- */
- protected $object;
+ public function setUp()
+ {
+ parent::setUp();
+ $this->object = new databox_Field_DCES_Creator;
+ }
- public function setUp()
- {
- $this->object = new databox_Field_DCES_Creator;
- }
+ public function testGet_label()
+ {
+ $name = str_replace('Test', '', array_pop(explode('_', __CLASS__)));
+ $this->assertEquals($name, $this->object->get_label());
+ }
- public function testGet_label()
- {
- $name = str_replace('Test', '', array_pop(explode('_', __CLASS__)));
- $this->assertEquals($name, $this->object->get_label());
- }
-
- public function testGet_definition()
- {
- $this->assertTrue(is_string($this->object->get_definition()));
- $this->assertTrue(strlen($this->object->get_definition()) > 20);
- }
-
- public function testGet_documentation_link()
- {
- $this->assertRegExp('/^http:\/\/dublincore\.org\/documents\/dces\/#[a-z]+$/', $this->object->get_documentation_link());
- }
+ public function testGet_definition()
+ {
+ $this->assertTrue(is_string($this->object->get_definition()));
+ $this->assertTrue(strlen($this->object->get_definition()) > 20);
+ }
+ public function testGet_documentation_link()
+ {
+ $this->assertRegExp('/^http:\/\/dublincore\.org\/documents\/dces\/#[a-z]+$/', $this->object->get_documentation_link());
+ }
}
-
diff --git a/tests/databox/Field/DCES/databox_Field_DCES_DateTest.php b/tests/databox/Field/DCES/databox_Field_DCES_DateTest.php
index 91d71c3263..bf291c8ed4 100644
--- a/tests/databox/Field/DCES/databox_Field_DCES_DateTest.php
+++ b/tests/databox/Field/DCES/databox_Field_DCES_DateTest.php
@@ -4,33 +4,31 @@ require_once __DIR__ . '/../../../PhraseanetPHPUnitAbstract.class.inc';
class databox_Field_DCES_DateTest extends PhraseanetPHPUnitAbstract
{
+ /**
+ * @var databox_Field_DCES_Date
+ */
+ protected $object;
- /**
- * @var databox_Field_DCES_Date
- */
- protected $object;
+ public function setUp()
+ {
+ parent::setUp();
+ $this->object = new databox_Field_DCES_Date;
+ }
- public function setUp()
- {
- $this->object = new databox_Field_DCES_Date;
- }
+ public function testGet_label()
+ {
+ $name = str_replace('Test', '', array_pop(explode('_', __CLASS__)));
+ $this->assertEquals($name, $this->object->get_label());
+ }
- public function testGet_label()
- {
- $name = str_replace('Test', '', array_pop(explode('_', __CLASS__)));
- $this->assertEquals($name, $this->object->get_label());
- }
-
- public function testGet_definition()
- {
- $this->assertTrue(is_string($this->object->get_definition()));
- $this->assertTrue(strlen($this->object->get_definition()) > 20);
- }
-
- public function testGet_documentation_link()
- {
- $this->assertRegExp('/^http:\/\/dublincore\.org\/documents\/dces\/#[a-z]+$/', $this->object->get_documentation_link());
- }
+ public function testGet_definition()
+ {
+ $this->assertTrue(is_string($this->object->get_definition()));
+ $this->assertTrue(strlen($this->object->get_definition()) > 20);
+ }
+ public function testGet_documentation_link()
+ {
+ $this->assertRegExp('/^http:\/\/dublincore\.org\/documents\/dces\/#[a-z]+$/', $this->object->get_documentation_link());
+ }
}
-
diff --git a/tests/databox/Field/DCES/databox_Field_DCES_DescriptionTest.php b/tests/databox/Field/DCES/databox_Field_DCES_DescriptionTest.php
index 87a93cb05f..90b7d6e836 100644
--- a/tests/databox/Field/DCES/databox_Field_DCES_DescriptionTest.php
+++ b/tests/databox/Field/DCES/databox_Field_DCES_DescriptionTest.php
@@ -4,33 +4,31 @@ require_once __DIR__ . '/../../../PhraseanetPHPUnitAbstract.class.inc';
class databox_Field_DCES_DescriptionTest extends PhraseanetPHPUnitAbstract
{
+ /**
+ * @var databox_Field_DCES_Description
+ */
+ protected $object;
- /**
- * @var databox_Field_DCES_Description
- */
- protected $object;
+ public function setUp()
+ {
+ parent::setUp();
+ $this->object = new databox_Field_DCES_Description;
+ }
- public function setUp()
- {
- $this->object = new databox_Field_DCES_Description;
- }
+ public function testGet_label()
+ {
+ $name = str_replace('Test', '', array_pop(explode('_', __CLASS__)));
+ $this->assertEquals($name, $this->object->get_label());
+ }
- public function testGet_label()
- {
- $name = str_replace('Test', '', array_pop(explode('_', __CLASS__)));
- $this->assertEquals($name, $this->object->get_label());
- }
-
- public function testGet_definition()
- {
- $this->assertTrue(is_string($this->object->get_definition()));
- $this->assertTrue(strlen($this->object->get_definition()) > 20);
- }
-
- public function testGet_documentation_link()
- {
- $this->assertRegExp('/^http:\/\/dublincore\.org\/documents\/dces\/#[a-z]+$/', $this->object->get_documentation_link());
- }
+ public function testGet_definition()
+ {
+ $this->assertTrue(is_string($this->object->get_definition()));
+ $this->assertTrue(strlen($this->object->get_definition()) > 20);
+ }
+ public function testGet_documentation_link()
+ {
+ $this->assertRegExp('/^http:\/\/dublincore\.org\/documents\/dces\/#[a-z]+$/', $this->object->get_documentation_link());
+ }
}
-
diff --git a/tests/databox/Field/DCES/databox_Field_DCES_FormatTest.php b/tests/databox/Field/DCES/databox_Field_DCES_FormatTest.php
index 568dd15859..13ff9afa48 100644
--- a/tests/databox/Field/DCES/databox_Field_DCES_FormatTest.php
+++ b/tests/databox/Field/DCES/databox_Field_DCES_FormatTest.php
@@ -4,33 +4,31 @@ require_once __DIR__ . '/../../../PhraseanetPHPUnitAbstract.class.inc';
class databox_Field_DCES_FormatTest extends PhraseanetPHPUnitAbstract
{
+ /**
+ * @var databox_Field_DCES_Format
+ */
+ protected $object;
- /**
- * @var databox_Field_DCES_Format
- */
- protected $object;
+ public function setUp()
+ {
+ parent::setUp();
+ $this->object = new databox_Field_DCES_Format;
+ }
- public function setUp()
- {
- $this->object = new databox_Field_DCES_Format;
- }
+ public function testGet_label()
+ {
+ $name = str_replace('Test', '', array_pop(explode('_', __CLASS__)));
+ $this->assertEquals($name, $this->object->get_label());
+ }
- public function testGet_label()
- {
- $name = str_replace('Test', '', array_pop(explode('_', __CLASS__)));
- $this->assertEquals($name, $this->object->get_label());
- }
-
- public function testGet_definition()
- {
- $this->assertTrue(is_string($this->object->get_definition()));
- $this->assertTrue(strlen($this->object->get_definition()) > 20);
- }
-
- public function testGet_documentation_link()
- {
- $this->assertRegExp('/^http:\/\/dublincore\.org\/documents\/dces\/#[a-z]+$/', $this->object->get_documentation_link());
- }
+ public function testGet_definition()
+ {
+ $this->assertTrue(is_string($this->object->get_definition()));
+ $this->assertTrue(strlen($this->object->get_definition()) > 20);
+ }
+ public function testGet_documentation_link()
+ {
+ $this->assertRegExp('/^http:\/\/dublincore\.org\/documents\/dces\/#[a-z]+$/', $this->object->get_documentation_link());
+ }
}
-
diff --git a/tests/databox/Field/DCES/databox_Field_DCES_IdentifierTest.php b/tests/databox/Field/DCES/databox_Field_DCES_IdentifierTest.php
index 759190de44..9836fb5eb5 100644
--- a/tests/databox/Field/DCES/databox_Field_DCES_IdentifierTest.php
+++ b/tests/databox/Field/DCES/databox_Field_DCES_IdentifierTest.php
@@ -4,33 +4,31 @@ require_once __DIR__ . '/../../../PhraseanetPHPUnitAbstract.class.inc';
class databox_Field_DCES_IdentifierTest extends PhraseanetPHPUnitAbstract
{
+ /**
+ * @var databox_Field_DCES_Identifier
+ */
+ protected $object;
- /**
- * @var databox_Field_DCES_Identifier
- */
- protected $object;
+ public function setUp()
+ {
+ parent::setUp();
+ $this->object = new databox_Field_DCES_Identifier;
+ }
- public function setUp()
- {
- $this->object = new databox_Field_DCES_Identifier;
- }
+ public function testGet_label()
+ {
+ $name = str_replace('Test', '', array_pop(explode('_', __CLASS__)));
+ $this->assertEquals($name, $this->object->get_label());
+ }
- public function testGet_label()
- {
- $name = str_replace('Test', '', array_pop(explode('_', __CLASS__)));
- $this->assertEquals($name, $this->object->get_label());
- }
-
- public function testGet_definition()
- {
- $this->assertTrue(is_string($this->object->get_definition()));
- $this->assertTrue(strlen($this->object->get_definition()) > 20);
- }
-
- public function testGet_documentation_link()
- {
- $this->assertRegExp('/^http:\/\/dublincore\.org\/documents\/dces\/#[a-z]+$/', $this->object->get_documentation_link());
- }
+ public function testGet_definition()
+ {
+ $this->assertTrue(is_string($this->object->get_definition()));
+ $this->assertTrue(strlen($this->object->get_definition()) > 20);
+ }
+ public function testGet_documentation_link()
+ {
+ $this->assertRegExp('/^http:\/\/dublincore\.org\/documents\/dces\/#[a-z]+$/', $this->object->get_documentation_link());
+ }
}
-
diff --git a/tests/databox/Field/DCES/databox_Field_DCES_LanguageTest.php b/tests/databox/Field/DCES/databox_Field_DCES_LanguageTest.php
index 0ed9902a0b..51f5e1b122 100644
--- a/tests/databox/Field/DCES/databox_Field_DCES_LanguageTest.php
+++ b/tests/databox/Field/DCES/databox_Field_DCES_LanguageTest.php
@@ -4,33 +4,31 @@ require_once __DIR__ . '/../../../PhraseanetPHPUnitAbstract.class.inc';
class databox_Field_DCES_LanguageTest extends PhraseanetPHPUnitAbstract
{
+ /**
+ * @var databox_Field_DCES_Language
+ */
+ protected $object;
- /**
- * @var databox_Field_DCES_Language
- */
- protected $object;
+ public function setUp()
+ {
+ parent::setUp();
+ $this->object = new databox_Field_DCES_Language;
+ }
- public function setUp()
- {
- $this->object = new databox_Field_DCES_Language;
- }
+ public function testGet_label()
+ {
+ $name = str_replace('Test', '', array_pop(explode('_', __CLASS__)));
+ $this->assertEquals($name, $this->object->get_label());
+ }
- public function testGet_label()
- {
- $name = str_replace('Test', '', array_pop(explode('_', __CLASS__)));
- $this->assertEquals($name, $this->object->get_label());
- }
-
- public function testGet_definition()
- {
- $this->assertTrue(is_string($this->object->get_definition()));
- $this->assertTrue(strlen($this->object->get_definition()) > 20);
- }
-
- public function testGet_documentation_link()
- {
- $this->assertRegExp('/^http:\/\/dublincore\.org\/documents\/dces\/#[a-z]+$/', $this->object->get_documentation_link());
- }
+ public function testGet_definition()
+ {
+ $this->assertTrue(is_string($this->object->get_definition()));
+ $this->assertTrue(strlen($this->object->get_definition()) > 20);
+ }
+ public function testGet_documentation_link()
+ {
+ $this->assertRegExp('/^http:\/\/dublincore\.org\/documents\/dces\/#[a-z]+$/', $this->object->get_documentation_link());
+ }
}
-
diff --git a/tests/databox/Field/DCES/databox_Field_DCES_PublisherTest.php b/tests/databox/Field/DCES/databox_Field_DCES_PublisherTest.php
index 3cd2107669..165c8554b4 100644
--- a/tests/databox/Field/DCES/databox_Field_DCES_PublisherTest.php
+++ b/tests/databox/Field/DCES/databox_Field_DCES_PublisherTest.php
@@ -4,33 +4,31 @@ require_once __DIR__ . '/../../../PhraseanetPHPUnitAbstract.class.inc';
class databox_Field_DCES_PublisherTest extends PhraseanetPHPUnitAbstract
{
+ /**
+ * @var databox_Field_DCES_Publisher
+ */
+ protected $object;
- /**
- * @var databox_Field_DCES_Publisher
- */
- protected $object;
+ public function setUp()
+ {
+ parent::setUp();
+ $this->object = new databox_Field_DCES_Publisher;
+ }
- public function setUp()
- {
- $this->object = new databox_Field_DCES_Publisher;
- }
+ public function testGet_label()
+ {
+ $name = str_replace('Test', '', array_pop(explode('_', __CLASS__)));
+ $this->assertEquals($name, $this->object->get_label());
+ }
- public function testGet_label()
- {
- $name = str_replace('Test', '', array_pop(explode('_', __CLASS__)));
- $this->assertEquals($name, $this->object->get_label());
- }
-
- public function testGet_definition()
- {
- $this->assertTrue(is_string($this->object->get_definition()));
- $this->assertTrue(strlen($this->object->get_definition()) > 20);
- }
-
- public function testGet_documentation_link()
- {
- $this->assertRegExp('/^http:\/\/dublincore\.org\/documents\/dces\/#[a-z]+$/', $this->object->get_documentation_link());
- }
+ public function testGet_definition()
+ {
+ $this->assertTrue(is_string($this->object->get_definition()));
+ $this->assertTrue(strlen($this->object->get_definition()) > 20);
+ }
+ public function testGet_documentation_link()
+ {
+ $this->assertRegExp('/^http:\/\/dublincore\.org\/documents\/dces\/#[a-z]+$/', $this->object->get_documentation_link());
+ }
}
-
diff --git a/tests/databox/Field/DCES/databox_Field_DCES_RelationTest.php b/tests/databox/Field/DCES/databox_Field_DCES_RelationTest.php
index 7b011aa568..4a3d645f69 100644
--- a/tests/databox/Field/DCES/databox_Field_DCES_RelationTest.php
+++ b/tests/databox/Field/DCES/databox_Field_DCES_RelationTest.php
@@ -4,32 +4,31 @@ require_once __DIR__ . '/../../../PhraseanetPHPUnitAbstract.class.inc';
class databox_Field_DCES_RelationTest extends PhraseanetPHPUnitAbstract
{
+ /**
+ * @var databox_Field_DCES_Relation
+ */
+ protected $object;
- /**
- * @var databox_Field_DCES_Relation
- */
- protected $object;
+ public function setUp()
+ {
+ parent::setUp();
+ $this->object = new databox_Field_DCES_Relation;
+ }
- public function setUp()
- {
- $this->object = new databox_Field_DCES_Relation;
- }
+ public function testGet_label()
+ {
+ $name = str_replace('Test', '', array_pop(explode('_', __CLASS__)));
+ $this->assertEquals($name, $this->object->get_label());
+ }
- public function testGet_label()
- {
- $name = str_replace('Test', '', array_pop(explode('_', __CLASS__)));
- $this->assertEquals($name, $this->object->get_label());
- }
-
- public function testGet_definition()
- {
- $this->assertTrue(is_string($this->object->get_definition()));
- $this->assertTrue(strlen($this->object->get_definition()) > 18);
- }
-
- public function testGet_documentation_link()
- {
- $this->assertRegExp('/^http:\/\/dublincore\.org\/documents\/dces\/#[a-z]+$/', $this->object->get_documentation_link());
- }
+ public function testGet_definition()
+ {
+ $this->assertTrue(is_string($this->object->get_definition()));
+ $this->assertTrue(strlen($this->object->get_definition()) > 18);
+ }
+ public function testGet_documentation_link()
+ {
+ $this->assertRegExp('/^http:\/\/dublincore\.org\/documents\/dces\/#[a-z]+$/', $this->object->get_documentation_link());
+ }
}
diff --git a/tests/databox/Field/DCES/databox_Field_DCES_RightsTest.php b/tests/databox/Field/DCES/databox_Field_DCES_RightsTest.php
index de6ad2bb31..681dbec3cb 100644
--- a/tests/databox/Field/DCES/databox_Field_DCES_RightsTest.php
+++ b/tests/databox/Field/DCES/databox_Field_DCES_RightsTest.php
@@ -4,33 +4,31 @@ require_once __DIR__ . '/../../../PhraseanetPHPUnitAbstract.class.inc';
class databox_Field_DCES_RightsTest extends PhraseanetPHPUnitAbstract
{
+ /**
+ * @var databox_Field_DCES_Rights
+ */
+ protected $object;
- /**
- * @var databox_Field_DCES_Rights
- */
- protected $object;
+ public function setUp()
+ {
+ parent::setUp();
+ $this->object = new databox_Field_DCES_Rights;
+ }
- public function setUp()
- {
- $this->object = new databox_Field_DCES_Rights;
- }
+ public function testGet_label()
+ {
+ $name = str_replace('Test', '', array_pop(explode('_', __CLASS__)));
+ $this->assertEquals($name, $this->object->get_label());
+ }
- public function testGet_label()
- {
- $name = str_replace('Test', '', array_pop(explode('_', __CLASS__)));
- $this->assertEquals($name, $this->object->get_label());
- }
-
- public function testGet_definition()
- {
- $this->assertTrue(is_string($this->object->get_definition()));
- $this->assertTrue(strlen($this->object->get_definition()) > 20);
- }
-
- public function testGet_documentation_link()
- {
- $this->assertRegExp('/^http:\/\/dublincore\.org\/documents\/dces\/#[a-z]+$/', $this->object->get_documentation_link());
- }
+ public function testGet_definition()
+ {
+ $this->assertTrue(is_string($this->object->get_definition()));
+ $this->assertTrue(strlen($this->object->get_definition()) > 20);
+ }
+ public function testGet_documentation_link()
+ {
+ $this->assertRegExp('/^http:\/\/dublincore\.org\/documents\/dces\/#[a-z]+$/', $this->object->get_documentation_link());
+ }
}
-
diff --git a/tests/databox/Field/DCES/databox_Field_DCES_SourceTest.php b/tests/databox/Field/DCES/databox_Field_DCES_SourceTest.php
index 3492223257..b34e127337 100644
--- a/tests/databox/Field/DCES/databox_Field_DCES_SourceTest.php
+++ b/tests/databox/Field/DCES/databox_Field_DCES_SourceTest.php
@@ -4,32 +4,31 @@ require_once __DIR__ . '/../../../PhraseanetPHPUnitAbstract.class.inc';
class databox_Field_DCES_SourceTest extends PhraseanetPHPUnitAbstract
{
+ /**
+ * @var databox_Field_DCES_Source
+ */
+ protected $object;
- /**
- * @var databox_Field_DCES_Source
- */
- protected $object;
+ public function setUp()
+ {
+ parent::setUp();
+ $this->object = new databox_Field_DCES_Source;
+ }
- public function setUp()
- {
- $this->object = new databox_Field_DCES_Source;
- }
+ public function testGet_label()
+ {
+ $name = str_replace('Test', '', array_pop(explode('_', __CLASS__)));
+ $this->assertEquals($name, $this->object->get_label());
+ }
- public function testGet_label()
- {
- $name = str_replace('Test', '', array_pop(explode('_', __CLASS__)));
- $this->assertEquals($name, $this->object->get_label());
- }
-
- public function testGet_definition()
- {
- $this->assertTrue(is_string($this->object->get_definition()));
- $this->assertTrue(strlen($this->object->get_definition()) > 20);
- }
-
- public function testGet_documentation_link()
- {
- $this->assertRegExp('/^http:\/\/dublincore\.org\/documents\/dces\/#[a-z]+$/', $this->object->get_documentation_link());
- }
+ public function testGet_definition()
+ {
+ $this->assertTrue(is_string($this->object->get_definition()));
+ $this->assertTrue(strlen($this->object->get_definition()) > 20);
+ }
+ public function testGet_documentation_link()
+ {
+ $this->assertRegExp('/^http:\/\/dublincore\.org\/documents\/dces\/#[a-z]+$/', $this->object->get_documentation_link());
+ }
}
diff --git a/tests/databox/Field/DCES/databox_Field_DCES_SubjectTest.php b/tests/databox/Field/DCES/databox_Field_DCES_SubjectTest.php
index e22ea99604..03abb9c97d 100644
--- a/tests/databox/Field/DCES/databox_Field_DCES_SubjectTest.php
+++ b/tests/databox/Field/DCES/databox_Field_DCES_SubjectTest.php
@@ -4,33 +4,31 @@ require_once __DIR__ . '/../../../PhraseanetPHPUnitAbstract.class.inc';
class databox_Field_DCES_SubjectTest extends PhraseanetPHPUnitAbstract
{
+ /**
+ * @var databox_Field_DCES_Subject
+ */
+ protected $object;
- /**
- * @var databox_Field_DCES_Subject
- */
- protected $object;
+ public function setUp()
+ {
+ parent::setUp();
+ $this->object = new databox_Field_DCES_Subject;
+ }
- public function setUp()
- {
- $this->object = new databox_Field_DCES_Subject;
- }
+ public function testGet_label()
+ {
+ $name = str_replace('Test', '', array_pop(explode('_', __CLASS__)));
+ $this->assertEquals($name, $this->object->get_label());
+ }
- public function testGet_label()
- {
- $name = str_replace('Test', '', array_pop(explode('_', __CLASS__)));
- $this->assertEquals($name, $this->object->get_label());
- }
-
- public function testGet_definition()
- {
- $this->assertTrue(is_string($this->object->get_definition()));
- $this->assertTrue(strlen($this->object->get_definition()) > 20);
- }
-
- public function testGet_documentation_link()
- {
- $this->assertRegExp('/^http:\/\/dublincore\.org\/documents\/dces\/#[a-z]+$/', $this->object->get_documentation_link());
- }
+ public function testGet_definition()
+ {
+ $this->assertTrue(is_string($this->object->get_definition()));
+ $this->assertTrue(strlen($this->object->get_definition()) > 20);
+ }
+ public function testGet_documentation_link()
+ {
+ $this->assertRegExp('/^http:\/\/dublincore\.org\/documents\/dces\/#[a-z]+$/', $this->object->get_documentation_link());
+ }
}
-
diff --git a/tests/databox/Field/DCES/databox_Field_DCES_TitleTest.php b/tests/databox/Field/DCES/databox_Field_DCES_TitleTest.php
index b67cc8a35a..0f6b8d2c5d 100644
--- a/tests/databox/Field/DCES/databox_Field_DCES_TitleTest.php
+++ b/tests/databox/Field/DCES/databox_Field_DCES_TitleTest.php
@@ -4,33 +4,31 @@ require_once __DIR__ . '/../../../PhraseanetPHPUnitAbstract.class.inc';
class databox_Field_DCES_TitleTest extends PhraseanetPHPUnitAbstract
{
+ /**
+ * @var databox_Field_DCES_Title
+ */
+ protected $object;
- /**
- * @var databox_Field_DCES_Title
- */
- protected $object;
+ public function setUp()
+ {
+ parent::setUp();
+ $this->object = new databox_Field_DCES_Title;
+ }
- public function setUp()
- {
- $this->object = new databox_Field_DCES_Title;
- }
+ public function testGet_label()
+ {
+ $name = str_replace('Test', '', array_pop(explode('_', __CLASS__)));
+ $this->assertEquals($name, $this->object->get_label());
+ }
- public function testGet_label()
- {
- $name = str_replace('Test', '', array_pop(explode('_', __CLASS__)));
- $this->assertEquals($name, $this->object->get_label());
- }
-
- public function testGet_definition()
- {
- $this->assertTrue(is_string($this->object->get_definition()));
- $this->assertTrue(strlen($this->object->get_definition()) > 20);
- }
-
- public function testGet_documentation_link()
- {
- $this->assertRegExp('/^http:\/\/dublincore\.org\/documents\/dces\/#[a-z]+$/', $this->object->get_documentation_link());
- }
+ public function testGet_definition()
+ {
+ $this->assertTrue(is_string($this->object->get_definition()));
+ $this->assertTrue(strlen($this->object->get_definition()) > 20);
+ }
+ public function testGet_documentation_link()
+ {
+ $this->assertRegExp('/^http:\/\/dublincore\.org\/documents\/dces\/#[a-z]+$/', $this->object->get_documentation_link());
+ }
}
-
diff --git a/tests/databox/Field/DCES/databox_Field_DCES_TypeTest.php b/tests/databox/Field/DCES/databox_Field_DCES_TypeTest.php
index 7fca318084..9335ae5042 100644
--- a/tests/databox/Field/DCES/databox_Field_DCES_TypeTest.php
+++ b/tests/databox/Field/DCES/databox_Field_DCES_TypeTest.php
@@ -4,33 +4,31 @@ require_once __DIR__ . '/../../../PhraseanetPHPUnitAbstract.class.inc';
class databox_Field_DCES_TypeTest extends PhraseanetPHPUnitAbstract
{
+ /**
+ * @var databox_Field_DCES_Type
+ */
+ protected $object;
- /**
- * @var databox_Field_DCES_Type
- */
- protected $object;
+ public function setUp()
+ {
+ parent::setUp();
+ $this->object = new databox_Field_DCES_Type;
+ }
- public function setUp()
- {
- $this->object = new databox_Field_DCES_Type;
- }
+ public function testGet_label()
+ {
+ $name = str_replace('Test', '', array_pop(explode('_', __CLASS__)));
+ $this->assertEquals($name, $this->object->get_label());
+ }
- public function testGet_label()
- {
- $name = str_replace('Test', '', array_pop(explode('_', __CLASS__)));
- $this->assertEquals($name, $this->object->get_label());
- }
-
- public function testGet_definition()
- {
- $this->assertTrue(is_string($this->object->get_definition()));
- $this->assertTrue(strlen($this->object->get_definition()) > 20);
- }
-
- public function testGet_documentation_link()
- {
- $this->assertRegExp('/^http:\/\/dublincore\.org\/documents\/dces\/#[a-z]+$/', $this->object->get_documentation_link());
- }
+ public function testGet_definition()
+ {
+ $this->assertTrue(is_string($this->object->get_definition()));
+ $this->assertTrue(strlen($this->object->get_definition()) > 20);
+ }
+ public function testGet_documentation_link()
+ {
+ $this->assertRegExp('/^http:\/\/dublincore\.org\/documents\/dces\/#[a-z]+$/', $this->object->get_documentation_link());
+ }
}
-
diff --git a/tests/databox/Field/databox_Field_DCESAbstractTest.php b/tests/databox/Field/databox_Field_DCESAbstractTest.php
deleted file mode 100644
index ca94c22216..0000000000
--- a/tests/databox/Field/databox_Field_DCESAbstractTest.php
+++ /dev/null
@@ -1,60 +0,0 @@
-markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_definition().
- */
- public function testGet_definition()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_documentation_link().
- */
- public function testGet_documentation_link()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
-}
diff --git a/tests/databox/databox_cguTest.php b/tests/databox/databox_cguTest.php
deleted file mode 100644
index 5614c8a683..0000000000
--- a/tests/databox/databox_cguTest.php
+++ /dev/null
@@ -1,60 +0,0 @@
-markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testDenyCgus().
- */
- public function testDenyCgus()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGetHome().
- */
- public function testGetHome()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
-}
diff --git a/tests/databox/databox_descriptionStructureTest.php b/tests/databox/databox_descriptionStructureTest.php
deleted file mode 100644
index 53b71111cb..0000000000
--- a/tests/databox/databox_descriptionStructureTest.php
+++ /dev/null
@@ -1,104 +0,0 @@
-markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testAdd_element().
- */
- public function testAdd_element()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testRemove_element().
- */
- public function testRemove_element()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_elements().
- */
- public function testGet_elements()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_element().
- */
- public function testGet_element()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_element_by_name().
- */
- public function testGet_element_by_name()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testIsset_element().
- */
- public function testIsset_element()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
-}
diff --git a/tests/databox/databox_fieldTest.php b/tests/databox/databox_fieldTest.php
index 92437774d3..d06aa75467 100644
--- a/tests/databox/databox_fieldTest.php
+++ b/tests/databox/databox_fieldTest.php
@@ -4,516 +4,510 @@ require_once __DIR__ . '/../PhraseanetPHPUnitAbstract.class.inc';
class databox_fieldTest extends PhraseanetPHPUnitAbstract
{
+ /**
+ * @var databox_field
+ */
+ protected $object_mono;
+ protected $object_multi;
+ protected $databox;
+ protected $name_mono;
+ protected $name_multi;
+ protected static $need_records = 1;
- /**
- * @var databox_field
- */
- protected $object_mono;
- protected $object_multi;
- protected $databox;
- protected $name_mono;
- protected $name_multi;
- protected static $need_records = 1;
-
- public function setUp()
- {
- $this->databox = self::$record_1->get_databox();
- $this->name_mono = 'Field Test Mono';
- $this->name_multi = 'Field Test Multi';
-
- $this->object_mono = $this->databox->get_meta_structure()->get_element_by_name($this->name_mono);
-
- $this->object_multi = $this->databox->get_meta_structure()->get_element_by_name($this->name_multi);
-
- if(!$this->object_mono instanceof databox_field)
- $this->object_mono = databox_field::create($this->databox, $this->name_mono);
- if(!$this->object_multi instanceof databox_field)
+ public function setUp()
{
- $this->object_multi = databox_field::create($this->databox, $this->name_multi);
- $this->object_multi->set_multi(true)->save();
- }
- }
+ parent::setUp();
+ $this->databox = self::$record_1->get_databox();
+ $this->name_mono = 'Field Test Mono';
+ $this->name_multi = 'Field Test Multi';
- public function tearDown()
- {
- if($this->object_mono instanceof databox_field)
- $this->object_mono->delete();
- if($this->object_multi instanceof databox_field)
- $this->object_multi->delete();
+ $this->object_mono = $this->databox->get_meta_structure()->get_element_by_name($this->name_mono);
- $extra = $this->databox->get_meta_structure()->get_element_by_name('Bonoboyoyo');
- if($extra instanceof databox_field)
- $extra->delete();
- }
+ $this->object_multi = $this->databox->get_meta_structure()->get_element_by_name($this->name_multi);
- public function testGet_instance()
- {
- $instance = databox_field::get_instance($this->databox, $this->object_mono->get_id());
- $this->assertEquals($this->object_mono->get_id(), $instance->get_id());
-
- $instance = databox_field::get_instance($this->databox, $this->object_multi->get_id());
- $this->assertEquals($this->object_multi->get_id(), $instance->get_id());
- }
-
- /**
- * @todo Implement testSet_databox().
- */
- public function testSet_databox()
- {
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- public function testGet_connection()
- {
- $this->assertInstanceOf('\connection_pdo', $this->object_mono->get_connection());
- $this->assertInstanceOf('\connection_pdo', $this->object_multi->get_connection());
- }
-
- public function testGet_databox()
- {
- $this->assertInstanceOf('\databox', $this->object_mono->get_databox());
- $this->assertEquals(self::$record_1->get_databox()->get_sbas_id(), $this->object_mono->get_databox()->get_sbas_id());
- $this->assertInstanceOf('\databox', $this->object_multi->get_databox());
- $this->assertEquals(self::$record_1->get_databox()->get_sbas_id(), $this->object_multi->get_databox()->get_sbas_id());
- }
-
- /**
- * @todo Implement testDelete().
- */
- public function testDelete()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testSave().
- */
- public function testSave()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- public function testSet_name()
- {
- $name = 'Eléphant';
- $this->object_mono->set_name($name);
- $this->assertEquals('Elephant', $this->object_mono->get_name());
-
- $name = '0!èEléphant ';
- $this->object_mono->set_name($name);
- $this->assertEquals('eElephant', $this->object_mono->get_name());
-
- $name = 'Gaston';
- $this->object_mono->set_name($name);
- $this->assertEquals('Gaston', $this->object_mono->get_name());
-
- try
- {
- $this->object_mono->set_name('');
- $this->fail();
- }
- catch (Exception $e)
- {
- $this->assertTrue(true, 'test passed');
+ if ( ! $this->object_mono instanceof databox_field)
+ $this->object_mono = databox_field::create($this->databox, $this->name_mono);
+ if ( ! $this->object_multi instanceof databox_field) {
+ $this->object_multi = databox_field::create($this->databox, $this->name_multi);
+ $this->object_multi->set_multi(true)->save();
+ }
}
- try
+ public function tearDown()
{
- $this->object_mono->set_name('éà');
- $this->assertEquals('ea', $this->object_mono->get_name());
+ if ($this->object_mono instanceof databox_field) {
+ $this->object_mono->delete();
+ }
+ if ($this->object_multi instanceof databox_field) {
+ $this->object_multi->delete();
+ }
+
+ $extra = $this->databox->get_meta_structure()->get_element_by_name('Bonoboyoyo');
+ if ($extra instanceof databox_field) {
+ $extra->delete();
+ }
+
+ parent::tearDown();
}
- catch (Exception $e)
+
+ public function testGet_instance()
{
+ $instance = databox_field::get_instance($this->databox, $this->object_mono->get_id());
+ $this->assertEquals($this->object_mono->get_id(), $instance->get_id());
+ $instance = databox_field::get_instance($this->databox, $this->object_multi->get_id());
+ $this->assertEquals($this->object_multi->get_id(), $instance->get_id());
}
- }
- /**
- * @todo Implement testLoad_class_from_xpath().
- */
- public function testLoad_class_from_xpath()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
+ /**
+ * @todo Implement testSet_databox().
+ */
+ public function testSet_databox()
+ {
+ $this->markTestIncomplete(
'This test has not been implemented yet.'
- );
- }
+ );
+ }
- public function testSet_source()
- {
- $source = '/rdf:RDF/rdf:Description/PHRASEANET:tf-filename';
+ public function testGet_connection()
+ {
+ $this->assertInstanceOf('\connection_pdo', $this->object_mono->get_connection());
+ $this->assertInstanceOf('\connection_pdo', $this->object_multi->get_connection());
+ }
- $this->object_mono->set_source($source);
- $this->object_multi->set_source($source);
+ public function testGet_databox()
+ {
+ $this->assertInstanceOf('\databox', $this->object_mono->get_databox());
+ $this->assertEquals(self::$record_1->get_databox()->get_sbas_id(), $this->object_mono->get_databox()->get_sbas_id());
+ $this->assertInstanceOf('\databox', $this->object_multi->get_databox());
+ $this->assertEquals(self::$record_1->get_databox()->get_sbas_id(), $this->object_multi->get_databox()->get_sbas_id());
+ }
- $this->assertEquals($source, $this->object_mono->get_source()->get_source());
- $this->assertEquals($source, $this->object_multi->get_source()->get_source());
-
- $this->object_mono->set_source(null);
- $this->object_multi->set_source(null);
-
- $this->assertInstanceOf('\metadata_Interface', $this->object_mono->get_source());
- $this->assertInstanceOf('\metadata_Interface', $this->object_multi->get_source());
- $this->assertEquals('', $this->object_mono->get_source()->get_source());
- $this->assertEquals('', $this->object_multi->get_source()->get_source());
- }
-
- public function testGet_source()
- {
- $this->assertInstanceOf('\metadata_Interface', $this->object_mono->get_source());
- $this->assertInstanceOf('\metadata_Interface', $this->object_multi->get_source());
- }
-
- /**
- * @todo Implement testGet_dces_element().
- */
- public function testGet_dces_element()
- {
- $this->assertNull($this->object_mono->get_dces_element());
- $this->assertNull($this->object_multi->get_dces_element());
- }
-
- public function testSet_dces_element()
- {
- $this->object_mono->set_dces_element(new \databox_Field_DCES_Contributor());
- $this->object_multi->set_dces_element(new \databox_Field_DCES_Format());
-
- $this->assertInstanceOf('\databox_Field_DCESAbstract', $this->object_mono->get_dces_element());
- $this->assertInstanceOf('\databox_Field_DCESAbstract', $this->object_multi->get_dces_element());
-
- $this->object_multi->set_dces_element(null);
- $this->assertNull($this->object_multi->get_dces_element());
- }
-
- public function testSet_indexable()
- {
- $this->object_mono->set_indexable(false);
- $this->assertFalse($this->object_mono->is_indexable());
- $this->object_mono->set_indexable(true);
- $this->assertTrue($this->object_mono->is_indexable());
- }
-
- public function testSet_readonly()
- {
- $this->object_mono->set_readonly(false);
- $this->assertFalse($this->object_mono->is_readonly());
- $this->object_mono->set_readonly(true);
- $this->assertTrue($this->object_mono->is_readonly());
- }
-
- public function testSet_required()
- {
- $this->object_mono->set_required(false);
- $this->assertFalse($this->object_mono->is_required());
- $this->object_mono->set_required(true);
- $this->assertTrue($this->object_mono->is_required());
- }
-
- public function testSet_business()
- {
- $this->object_mono->set_business(false);
- $this->assertFalse($this->object_mono->isBusiness());
- $this->object_mono->set_business(true);
- $this->assertTrue($this->object_mono->isBusiness());
- }
-
- public function testSet_multi()
- {
- $this->object_mono->set_multi(false);
- $this->assertFalse($this->object_mono->is_multi());
- $this->object_mono->set_multi(true);
- $this->assertTrue($this->object_mono->is_multi());
- }
-
- public function testSet_report()
- {
- $this->object_mono->set_report(false);
- $this->assertFalse($this->object_mono->is_report());
- $this->object_mono->set_report(true);
- $this->assertTrue($this->object_mono->is_report());
- }
-
- public function testSet_type()
- {
- $this->object_mono->set_type('date');
- $this->assertEquals('date', $this->object_mono->get_type());
- $this->object_mono->set_type('text');
- $this->assertEquals('text', $this->object_mono->get_type());
- }
-
- public function testSet_tbranch()
- {
- $this->object_mono->set_tbranch('newBranche');
- $this->assertEquals('newBranche', $this->object_mono->get_tbranch());
- $this->object_mono->set_tbranch(null);
- $this->assertNull($this->object_mono->get_tbranch());
- }
-
- public function testSet_separator()
- {
- $this->assertEquals('', $this->object_mono->get_separator());
- $this->assertEquals(';', $this->object_multi->get_separator());
-
- $this->object_mono->set_separator(';.:');
- $this->object_multi->set_separator(';.:');
-
- $this->assertEquals('', $this->object_mono->get_separator());
- $this->assertEquals(';.:', $this->object_multi->get_separator());
-
- $this->object_multi->set_separator('.:-');
- $this->assertEquals('.:-;', $this->object_multi->get_separator());
- }
-
- public function testSet_thumbtitle()
- {
- $this->object_mono->set_thumbtitle(true);
- $this->assertTrue($this->object_mono->get_thumbtitle());
- $this->object_mono->set_thumbtitle('fr');
- $this->assertEquals('fr', $this->object_mono->get_thumbtitle());
- $this->object_mono->set_thumbtitle(false);
- $this->assertFalse($this->object_mono->get_thumbtitle());
- }
-
- public function testGet_thumbtitle()
- {
- $this->assertNull($this->object_mono->get_thumbtitle());
- $this->assertNull($this->object_multi->get_thumbtitle());
- }
-
- public function testGet_id()
- {
- $this->assertTrue(is_int($this->object_mono->get_id()));
- $this->assertTrue(is_int($this->object_multi->get_id()));
- }
-
- public function testGet_type()
- {
- $this->assertEquals('string', $this->object_mono->get_type());
- $this->assertEquals('string', $this->object_multi->get_type());
- }
-
- public function testGet_tbranch()
- {
- $this->assertEquals('', $this->object_mono->get_tbranch());
- $this->assertEquals('', $this->object_multi->get_tbranch());
- }
-
- public function testGet_separator()
- {
- $this->assertEquals('', $this->object_mono->get_separator());
- $this->assertEquals(';', $this->object_multi->get_separator());
- }
-
- public function testIs_indexable()
- {
- $this->assertTrue($this->object_mono->is_indexable());
- $this->assertTrue($this->object_multi->is_indexable());
- }
-
- public function testIs_readonly()
- {
- $this->assertFalse($this->object_mono->is_readonly());
- $this->assertFalse($this->object_multi->is_readonly());
- }
-
- public function testIs_required()
- {
- $this->assertFalse($this->object_mono->is_required());
- $this->assertFalse($this->object_multi->is_required());
- }
-
- public function testIs_multi()
- {
- $this->assertFalse($this->object_mono->is_multi());
- $this->assertTrue($this->object_multi->is_multi());
- }
-
- public function testIs_report()
- {
- $this->assertTrue($this->object_mono->is_report());
- $this->assertTrue($this->object_multi->is_report());
- }
-
- public function testGet_name()
- {
- $this->assertEquals(str_replace(' ', '', $this->name_mono), $this->object_mono->get_name());
- $this->assertEquals(str_replace(' ', '', $this->name_multi), $this->object_multi->get_name());
- }
-
- public function testGet_metadata_source()
- {
- $this->assertEquals('', $this->object_mono->get_metadata_source());
- $this->assertEquals('', $this->object_multi->get_metadata_source());
-
- $source = '/rdf:RDF/rdf:Description/PHRASEANET:tf-filename';
-
- $this->object_mono->set_source($source);
- $this->object_multi->set_source($source);
-
- $this->assertEquals($source, $this->object_mono->get_metadata_source());
- $this->assertEquals($source, $this->object_multi->get_metadata_source());
- }
-
- public function testGet_metadata_namespace()
- {
- $this->assertEquals('NoSource', $this->object_mono->get_metadata_namespace());
- $this->assertEquals('NoSource', $this->object_multi->get_metadata_namespace());
-
- $source = '/rdf:RDF/rdf:Description/PHRASEANET:tf-filename';
-
- $this->object_mono->set_source($source);
- $this->object_multi->set_source($source);
-
- $this->assertEquals('PHRASEANET', $this->object_mono->get_metadata_namespace());
- $this->assertEquals('PHRASEANET', $this->object_multi->get_metadata_namespace());
- }
-
- public function testGet_metadata_tagname()
- {
- $this->assertEquals('NoSource', $this->object_mono->get_metadata_tagname());
- $this->assertEquals('NoSource', $this->object_multi->get_metadata_tagname());
-
- $source = '/rdf:RDF/rdf:Description/PHRASEANET:tf-filename';
-
- $this->object_mono->set_source($source);
- $this->object_multi->set_source($source);
-
- $this->assertEquals('tf-filename', $this->object_mono->get_metadata_tagname());
- $this->assertEquals('tf-filename', $this->object_multi->get_metadata_tagname());
- }
-
- public function testIs_on_error()
- {
- $this->assertFalse($this->object_mono->is_on_error());
- $this->assertFalse($this->object_multi->is_on_error());
- }
-
- public function testRenameField()
- {
- $AddedValue = 'scalar value';
-
- self::$record_1->set_metadatas(array(
- array(
- 'meta_id' => null,
- 'meta_struct_id' => $this->object_mono->get_id(),
- 'value'=> $AddedValue
- )
- ));
-
- $this->object_mono->set_name('Bonobo yoyo')->save();
-
- $value = array_pop(self::$record_1->get_caption()->get_field('Bonoboyoyo')->get_values());
- $this->assertEquals($value->getValue(), $AddedValue);
- }
-
- public function testChangeMulti()
- {
- $AddedValue_1 = 'scalar value 1';
- $AddedValue_2 = 'scalar value 2';
-
- self::$record_1->set_metadatas(array(
- array(
- 'meta_id' => null,
- 'meta_struct_id' => $this->object_multi->get_id(),
- 'value'=> $AddedValue_1
- ),
- array(
- 'meta_id' => null,
- 'meta_struct_id' => $this->object_multi->get_id(),
- 'value'=> $AddedValue_2
- )
- ));
-
- $this->assertEquals(2, count(self::$record_1->get_caption()->get_field(str_replace(' ', '', $this->name_multi))->get_values()));
-
- $this->object_multi->set_multi(false)->save();
-
- $this->assertEquals(1, count(self::$record_1->get_caption()->get_field(str_replace(' ', '', $this->name_multi))->get_values()));
- }
-
- /**
- * @todo Implement testCreate().
- */
- public function testCreate()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
+ /**
+ * @todo Implement testDelete().
+ */
+ public function testDelete()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
'This test has not been implemented yet.'
- );
- }
+ );
+ }
- /**
- * @todo Implement test__sleep().
- */
- public function test__sleep()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
+ /**
+ * @todo Implement testSave().
+ */
+ public function testSave()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
'This test has not been implemented yet.'
- );
- }
+ );
+ }
- /**
- * @todo Implement test__wakeup().
- */
- public function test__wakeup()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
+ public function testSet_name()
+ {
+ $name = 'Eléphant';
+ $this->object_mono->set_name($name);
+ $this->assertEquals('Elephant', $this->object_mono->get_name());
+
+ $name = '0!èEléphant ';
+ $this->object_mono->set_name($name);
+ $this->assertEquals('eElephant', $this->object_mono->get_name());
+
+ $name = 'Gaston';
+ $this->object_mono->set_name($name);
+ $this->assertEquals('Gaston', $this->object_mono->get_name());
+
+ try {
+ $this->object_mono->set_name('');
+ $this->fail();
+ } catch (Exception $e) {
+ $this->assertTrue(true, 'test passed');
+ }
+
+ try {
+ $this->object_mono->set_name('éà');
+ $this->assertEquals('ea', $this->object_mono->get_name());
+ } catch (Exception $e) {
+
+ }
+ }
+
+ /**
+ * @todo Implement testLoad_class_from_xpath().
+ */
+ public function testLoad_class_from_xpath()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
'This test has not been implemented yet.'
- );
- }
+ );
+ }
- /**
- * @todo Implement testGet_cache_key().
- */
- public function testGet_cache_key()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
+ public function testSet_source()
+ {
+ $source = '/rdf:RDF/rdf:Description/PHRASEANET:tf-filename';
+
+ $this->object_mono->set_source($source);
+ $this->object_multi->set_source($source);
+
+ $this->assertEquals($source, $this->object_mono->get_source()->get_source());
+ $this->assertEquals($source, $this->object_multi->get_source()->get_source());
+
+ $this->object_mono->set_source(null);
+ $this->object_multi->set_source(null);
+
+ $this->assertInstanceOf('\metadata_Interface', $this->object_mono->get_source());
+ $this->assertInstanceOf('\metadata_Interface', $this->object_multi->get_source());
+ $this->assertEquals('', $this->object_mono->get_source()->get_source());
+ $this->assertEquals('', $this->object_multi->get_source()->get_source());
+ }
+
+ public function testGet_source()
+ {
+ $this->assertInstanceOf('\metadata_Interface', $this->object_mono->get_source());
+ $this->assertInstanceOf('\metadata_Interface', $this->object_multi->get_source());
+ }
+
+ public function testGet_dces_element()
+ {
+ $this->assertNull($this->object_mono->get_dces_element());
+ $this->assertNull($this->object_multi->get_dces_element());
+ }
+
+ public function testSet_dces_element()
+ {
+ $this->object_mono->set_dces_element(new \databox_Field_DCES_Contributor());
+ $this->object_multi->set_dces_element(new \databox_Field_DCES_Format());
+
+ $this->assertInstanceOf('\databox_Field_DCESAbstract', $this->object_mono->get_dces_element());
+ $this->assertInstanceOf('\databox_Field_DCESAbstract', $this->object_multi->get_dces_element());
+
+ $this->object_multi->set_dces_element(null);
+ $this->assertNull($this->object_multi->get_dces_element());
+ }
+
+ public function testSet_indexable()
+ {
+ $this->object_mono->set_indexable(false);
+ $this->assertFalse($this->object_mono->is_indexable());
+ $this->object_mono->set_indexable(true);
+ $this->assertTrue($this->object_mono->is_indexable());
+ }
+
+ public function testSet_readonly()
+ {
+ $this->object_mono->set_readonly(false);
+ $this->assertFalse($this->object_mono->is_readonly());
+ $this->object_mono->set_readonly(true);
+ $this->assertTrue($this->object_mono->is_readonly());
+ }
+
+ public function testSet_required()
+ {
+ $this->object_mono->set_required(false);
+ $this->assertFalse($this->object_mono->is_required());
+ $this->object_mono->set_required(true);
+ $this->assertTrue($this->object_mono->is_required());
+ }
+
+ public function testSet_business()
+ {
+ $this->object_mono->set_business(false);
+ $this->assertFalse($this->object_mono->isBusiness());
+ $this->object_mono->set_business(true);
+ $this->assertTrue($this->object_mono->isBusiness());
+ }
+
+ public function testSet_multi()
+ {
+ $this->object_mono->set_multi(false);
+ $this->assertFalse($this->object_mono->is_multi());
+ $this->object_mono->set_multi(true);
+ $this->assertTrue($this->object_mono->is_multi());
+ }
+
+ public function testSet_report()
+ {
+ $this->object_mono->set_report(false);
+ $this->assertFalse($this->object_mono->is_report());
+ $this->object_mono->set_report(true);
+ $this->assertTrue($this->object_mono->is_report());
+ }
+
+ public function testSet_type()
+ {
+ $this->object_mono->set_type('date');
+ $this->assertEquals('date', $this->object_mono->get_type());
+ $this->object_mono->set_type('text');
+ $this->assertEquals('text', $this->object_mono->get_type());
+ }
+
+ public function testSet_tbranch()
+ {
+ $this->object_mono->set_tbranch('newBranche');
+ $this->assertEquals('newBranche', $this->object_mono->get_tbranch());
+ $this->object_mono->set_tbranch(null);
+ $this->assertNull($this->object_mono->get_tbranch());
+ }
+
+ public function testSet_separator()
+ {
+ $this->assertEquals('', $this->object_mono->get_separator());
+ $this->assertEquals(';', $this->object_multi->get_separator());
+
+ $this->object_mono->set_separator(';.:');
+ $this->object_multi->set_separator(';.:');
+
+ $this->assertEquals('', $this->object_mono->get_separator());
+ $this->assertEquals(';.:', $this->object_multi->get_separator());
+
+ $this->object_multi->set_separator('.:-');
+ $this->assertEquals('.:-;', $this->object_multi->get_separator());
+ }
+
+ public function testSet_thumbtitle()
+ {
+ $this->object_mono->set_thumbtitle(true);
+ $this->assertTrue($this->object_mono->get_thumbtitle());
+ $this->object_mono->set_thumbtitle('fr');
+ $this->assertEquals('fr', $this->object_mono->get_thumbtitle());
+ $this->object_mono->set_thumbtitle(false);
+ $this->assertFalse($this->object_mono->get_thumbtitle());
+ }
+
+ public function testGet_thumbtitle()
+ {
+ $this->assertNull($this->object_mono->get_thumbtitle());
+ $this->assertNull($this->object_multi->get_thumbtitle());
+ }
+
+ public function testGet_id()
+ {
+ $this->assertTrue(is_int($this->object_mono->get_id()));
+ $this->assertTrue(is_int($this->object_multi->get_id()));
+ }
+
+ public function testGet_type()
+ {
+ $this->assertEquals('string', $this->object_mono->get_type());
+ $this->assertEquals('string', $this->object_multi->get_type());
+ }
+
+ public function testGet_tbranch()
+ {
+ $this->assertEquals('', $this->object_mono->get_tbranch());
+ $this->assertEquals('', $this->object_multi->get_tbranch());
+ }
+
+ public function testGet_separator()
+ {
+ $this->assertEquals('', $this->object_mono->get_separator());
+ $this->assertEquals(';', $this->object_multi->get_separator());
+ }
+
+ public function testIs_indexable()
+ {
+ $this->assertTrue($this->object_mono->is_indexable());
+ $this->assertTrue($this->object_multi->is_indexable());
+ }
+
+ public function testIs_readonly()
+ {
+ $this->assertFalse($this->object_mono->is_readonly());
+ $this->assertFalse($this->object_multi->is_readonly());
+ }
+
+ public function testIs_required()
+ {
+ $this->assertFalse($this->object_mono->is_required());
+ $this->assertFalse($this->object_multi->is_required());
+ }
+
+ public function testIs_multi()
+ {
+ $this->assertFalse($this->object_mono->is_multi());
+ $this->assertTrue($this->object_multi->is_multi());
+ }
+
+ public function testIs_report()
+ {
+ $this->assertTrue($this->object_mono->is_report());
+ $this->assertTrue($this->object_multi->is_report());
+ }
+
+ public function testGet_name()
+ {
+ $this->assertEquals(str_replace(' ', '', $this->name_mono), $this->object_mono->get_name());
+ $this->assertEquals(str_replace(' ', '', $this->name_multi), $this->object_multi->get_name());
+ }
+
+ public function testGet_metadata_source()
+ {
+ $this->assertEquals('', $this->object_mono->get_metadata_source());
+ $this->assertEquals('', $this->object_multi->get_metadata_source());
+
+ $source = '/rdf:RDF/rdf:Description/PHRASEANET:tf-filename';
+
+ $this->object_mono->set_source($source);
+ $this->object_multi->set_source($source);
+
+ $this->assertEquals($source, $this->object_mono->get_metadata_source());
+ $this->assertEquals($source, $this->object_multi->get_metadata_source());
+ }
+
+ public function testGet_metadata_namespace()
+ {
+ $this->assertEquals('NoSource', $this->object_mono->get_metadata_namespace());
+ $this->assertEquals('NoSource', $this->object_multi->get_metadata_namespace());
+
+ $source = '/rdf:RDF/rdf:Description/PHRASEANET:tf-filename';
+
+ $this->object_mono->set_source($source);
+ $this->object_multi->set_source($source);
+
+ $this->assertEquals('PHRASEANET', $this->object_mono->get_metadata_namespace());
+ $this->assertEquals('PHRASEANET', $this->object_multi->get_metadata_namespace());
+ }
+
+ public function testGet_metadata_tagname()
+ {
+ $this->assertEquals('NoSource', $this->object_mono->get_metadata_tagname());
+ $this->assertEquals('NoSource', $this->object_multi->get_metadata_tagname());
+
+ $source = '/rdf:RDF/rdf:Description/PHRASEANET:tf-filename';
+
+ $this->object_mono->set_source($source);
+ $this->object_multi->set_source($source);
+
+ $this->assertEquals('tf-filename', $this->object_mono->get_metadata_tagname());
+ $this->assertEquals('tf-filename', $this->object_multi->get_metadata_tagname());
+ }
+
+ public function testIs_on_error()
+ {
+ $this->assertFalse($this->object_mono->is_on_error());
+ $this->assertFalse($this->object_multi->is_on_error());
+ }
+
+ public function testRenameField()
+ {
+ $AddedValue = 'scalar value';
+
+ self::$record_1->set_metadatas(array(
+ array(
+ 'meta_id' => null,
+ 'meta_struct_id' => $this->object_mono->get_id(),
+ 'value' => $AddedValue
+ )
+ ));
+
+ $this->object_mono->set_name('Bonobo yoyo')->save();
+
+ $value = array_pop(self::$record_1->get_caption()->get_field('Bonoboyoyo')->get_values());
+ $this->assertEquals($value->getValue(), $AddedValue);
+ }
+
+ public function testChangeMulti()
+ {
+ $AddedValue_1 = 'scalar value 1';
+ $AddedValue_2 = 'scalar value 2';
+
+ self::$record_1->set_metadatas(array(
+ array(
+ 'meta_id' => null,
+ 'meta_struct_id' => $this->object_multi->get_id(),
+ 'value' => $AddedValue_1
+ ),
+ array(
+ 'meta_id' => null,
+ 'meta_struct_id' => $this->object_multi->get_id(),
+ 'value' => $AddedValue_2
+ )
+ ));
+
+ $this->assertEquals(2, count(self::$record_1->get_caption()->get_field(str_replace(' ', '', $this->name_multi))->get_values()));
+
+ $this->object_multi->set_multi(false)->save();
+
+ $this->assertEquals(1, count(self::$record_1->get_caption()->get_field(str_replace(' ', '', $this->name_multi))->get_values()));
+ }
+
+ /**
+ * @todo Implement testCreate().
+ */
+ public function testCreate()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
'This test has not been implemented yet.'
- );
- }
+ );
+ }
- /**
- * @todo Implement testGet_data_from_cache().
- */
- public function testGet_data_from_cache()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
+ /**
+ * @todo Implement test__sleep().
+ */
+ public function test__sleep()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
'This test has not been implemented yet.'
- );
- }
+ );
+ }
- /**
- * @todo Implement testSet_data_to_cache().
- */
- public function testSet_data_to_cache()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
+ /**
+ * @todo Implement test__wakeup().
+ */
+ public function test__wakeup()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
'This test has not been implemented yet.'
- );
- }
+ );
+ }
- /**
- * @todo Implement testDelete_data_from_cache().
- */
- public function testDelete_data_from_cache()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
+ /**
+ * @todo Implement testGet_cache_key().
+ */
+ public function testGet_cache_key()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
'This test has not been implemented yet.'
- );
- }
+ );
+ }
+ /**
+ * @todo Implement testGet_data_from_cache().
+ */
+ public function testGet_data_from_cache()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ /**
+ * @todo Implement testSet_data_to_cache().
+ */
+ public function testSet_data_to_cache()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ /**
+ * @todo Implement testDelete_data_from_cache().
+ */
+ public function testDelete_data_from_cache()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
}
diff --git a/tests/databox/databox_fieldUnknownTest.php b/tests/databox/databox_fieldUnknownTest.php
deleted file mode 100644
index 756e1ec744..0000000000
--- a/tests/databox/databox_fieldUnknownTest.php
+++ /dev/null
@@ -1,82 +0,0 @@
-markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_metadata_source().
- */
- public function testGet_metadata_source()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_metadata_namespace().
- */
- public function testGet_metadata_namespace()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_metadata_tagname().
- */
- public function testGet_metadata_tagname()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testIs_on_error().
- */
- public function testIs_on_error()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
-}
diff --git a/tests/databox/databox_statusTest.php b/tests/databox/databox_statusTest.php
index 54b6427a24..7d69152e52 100644
--- a/tests/databox/databox_statusTest.php
+++ b/tests/databox/databox_statusTest.php
@@ -4,175 +4,151 @@ require_once __DIR__ . '/../PhraseanetPHPUnitAbstract.class.inc';
class databox_statusTest extends PhraseanetPHPUnitAbstract
{
+ /**
+ * @var databox_status
+ */
+ protected $object;
+ protected $databox;
+ protected static $need_records = 1;
- /**
- * @var databox_status
- */
- protected $object;
- protected $databox;
- protected static $need_records = 1;
-
- public function setUp()
- {
- $this->databox = self::$record_1->get_databox();
- $this->object = $this->databox->get_statusbits();
- }
-
- public function testGetStatus()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- public function testGetDisplayStatus()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGetSearchStatus().
- */
- public function testGetSearchStatus()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGetPath().
- */
- public function testGetPath()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGetUrl().
- */
- public function testGetUrl()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testDeleteStatus().
- */
- public function testDeleteStatus()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testUpdateStatus().
- */
- public function testUpdateStatus()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testDeleteIcon().
- */
- public function testDeleteIcon()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testUpdateIcon().
- */
- public function testUpdateIcon()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testOperation_and().
- */
- public function testOperation_and()
- {
- $this->assertEquals('0', databox_status::operation_and('0x001','0x010'));
- $this->assertEquals('1', databox_status::operation_and('01','11'));
- $this->assertEquals('0', databox_status::operation_and('01','10'));
- $this->assertEquals('10', databox_status::operation_and('11','10'));
- }
-
- /**
- * @todo Implement testOperation_and_not().
- */
- public function testOperation_and_not()
- {
- $this->assertEquals('0', databox_status::operation_and_not('0x001','0x011'));
- $this->assertEquals('0', databox_status::operation_and_not('01','11'));
- $this->assertEquals('1', databox_status::operation_and_not('01','10'));
- $this->assertEquals('1', databox_status::operation_and_not('11','10'));
- $this->assertEquals('10', databox_status::operation_and_not('10','01'));
- }
-
- /**
- * @todo Implement testOperation_or().
- */
- public function testOperation_or()
- {
- $this->assertEquals('10001', databox_status::operation_or('0x001','0x011'));
- $this->assertEquals('11', databox_status::operation_or('01','11'));
- }
-
- /**
- * @todo Implement testDec2bin().
- */
- public function testDec2bin()
- {
- $this->assertEquals('1010', databox_status::dec2bin('10'));
-
- try
+ public function setUp()
{
+ parent::setUp();
+ $this->databox = self::$record_1->get_databox();
+ $this->object = $this->databox->get_statusbits();
}
- catch(Exception $e)
+
+ public function testGetStatus()
{
-
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
}
- }
- public function testHex2bin()
- {
- $this->assertEquals('10100001', databox_status::hex2bin('0x0A1'));
- $this->assertEquals('10100001', databox_status::hex2bin('0A1'));
-
- try
+ public function testGetDisplayStatus()
{
- databox_status::hex2bin('G1');
- $this->fail('Should raise an exception');
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
}
- catch(Exception $e)
+
+ /**
+ * @todo Implement testGetSearchStatus().
+ */
+ public function testGetSearchStatus()
{
-
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
}
- }
+ /**
+ * @todo Implement testGetPath().
+ */
+ public function testGetPath()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ /**
+ * @todo Implement testGetUrl().
+ */
+ public function testGetUrl()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ /**
+ * @todo Implement testDeleteStatus().
+ */
+ public function testDeleteStatus()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ /**
+ * @todo Implement testUpdateStatus().
+ */
+ public function testUpdateStatus()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ /**
+ * @todo Implement testDeleteIcon().
+ */
+ public function testDeleteIcon()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ /**
+ * @todo Implement testUpdateIcon().
+ */
+ public function testUpdateIcon()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ public function testOperation_and()
+ {
+ $this->assertEquals('0', databox_status::operation_and('0x001', '0x010'));
+ $this->assertEquals('1', databox_status::operation_and('01', '11'));
+ $this->assertEquals('0', databox_status::operation_and('01', '10'));
+ $this->assertEquals('10', databox_status::operation_and('11', '10'));
+ }
+
+ public function testOperation_and_not()
+ {
+ $this->assertEquals('0', databox_status::operation_and_not('0x001', '0x011'));
+ $this->assertEquals('0', databox_status::operation_and_not('01', '11'));
+ $this->assertEquals('1', databox_status::operation_and_not('01', '10'));
+ $this->assertEquals('1', databox_status::operation_and_not('11', '10'));
+ $this->assertEquals('10', databox_status::operation_and_not('10', '01'));
+ }
+
+ public function testOperation_or()
+ {
+ $this->assertEquals('10001', databox_status::operation_or('0x001', '0x011'));
+ $this->assertEquals('11', databox_status::operation_or('01', '11'));
+ }
+
+ public function testDec2bin()
+ {
+ $this->assertEquals('1010', databox_status::dec2bin('10'));
+ }
+
+ public function testHex2bin()
+ {
+ $this->assertEquals('10100001', databox_status::hex2bin('0x0A1'));
+ $this->assertEquals('10100001', databox_status::hex2bin('0A1'));
+
+ try {
+ databox_status::hex2bin('G1');
+ $this->fail('Should raise an exception');
+ } catch (Exception $e) {
+
+ }
+ }
}
diff --git a/tests/databox/databox_subdefTest.php b/tests/databox/databox_subdefTest.php
index 23794ba5ad..509f5195dd 100644
--- a/tests/databox/databox_subdefTest.php
+++ b/tests/databox/databox_subdefTest.php
@@ -35,7 +35,7 @@ class databox_subdefTest extends PHPUnit_Framework_TestCase
75
';
- $type = new \Alchemy\Phrasea\Media\Type\Image();
+ $type = new \Alchemy\Phrasea\Media\Type\Image();
$object = new databox_subdef($type, simplexml_load_string($xml));
$this->assertEquals(databox_subdef::CLASS_PREVIEW, $object->get_class());
@@ -55,8 +55,7 @@ class databox_subdefTest extends PHPUnit_Framework_TestCase
$this->assertTrue(is_array($object->getAvailableSubdefTypes()));
$this->assertTrue(count($object->getAvailableSubdefTypes()) > 0);
- foreach ($object->getAvailableSubdefTypes() as $type)
- {
+ foreach ($object->getAvailableSubdefTypes() as $type) {
$this->assertInstanceOf('\\Alchemy\\Phrasea\\Media\\Subdef\\Image', $type);
}
@@ -68,8 +67,7 @@ class databox_subdefTest extends PHPUnit_Framework_TestCase
$options = $object->getOptions();
$this->assertTrue(is_array($options));
- foreach ($options as $option)
- {
+ foreach ($options as $option) {
$this->assertInstanceOf('\\Alchemy\\Phrasea\\Media\\Subdef\\OptionType\\OptionType', $option);
}
}
@@ -109,7 +107,7 @@ class databox_subdefTest extends PHPUnit_Framework_TestCase
libx264
';
- $type = new \Alchemy\Phrasea\Media\Type\Video();
+ $type = new \Alchemy\Phrasea\Media\Type\Video();
$object = new databox_subdef($type, simplexml_load_string($xml));
$this->assertEquals(databox_subdef::CLASS_THUMBNAIL, $object->get_class());
@@ -126,8 +124,7 @@ class databox_subdefTest extends PHPUnit_Framework_TestCase
$this->assertTrue(is_array($object->getAvailableSubdefTypes()));
$this->assertTrue(count($object->getAvailableSubdefTypes()) > 0);
- foreach ($object->getAvailableSubdefTypes() as $type)
- {
+ foreach ($object->getAvailableSubdefTypes() as $type) {
$this->assertInstanceOf('\\Alchemy\\Phrasea\\Media\\Subdef\\Subdef', $type);
}
@@ -139,8 +136,7 @@ class databox_subdefTest extends PHPUnit_Framework_TestCase
$options = $object->getOptions();
$this->assertTrue(is_array($options));
- foreach ($options as $option)
- {
+ foreach ($options as $option) {
$this->assertInstanceOf('\\Alchemy\\Phrasea\\Media\\Subdef\\OptionType\\OptionType', $option);
}
}
@@ -164,7 +160,7 @@ class databox_subdefTest extends PHPUnit_Framework_TestCase
100
';
- $type = new \Alchemy\Phrasea\Media\Type\Video();
+ $type = new \Alchemy\Phrasea\Media\Type\Video();
$object = new databox_subdef($type, simplexml_load_string($xml));
$this->assertInstanceOf('\\MediaAlchemyst\\Specification\\Animation', $object->getSpecs());
@@ -172,8 +168,7 @@ class databox_subdefTest extends PHPUnit_Framework_TestCase
$options = $object->getOptions();
$this->assertTrue(is_array($options));
- foreach ($options as $option)
- {
+ foreach ($options as $option) {
$this->assertInstanceOf('\\Alchemy\\Phrasea\\Media\\Subdef\\OptionType\\OptionType', $option);
}
}
@@ -192,7 +187,7 @@ class databox_subdefTest extends PHPUnit_Framework_TestCase
audio
';
- $type = new \Alchemy\Phrasea\Media\Type\Audio();
+ $type = new \Alchemy\Phrasea\Media\Type\Audio();
$object = new databox_subdef($type, simplexml_load_string($xml));
$this->assertInstanceOf('\\MediaAlchemyst\\Specification\\Audio', $object->getSpecs());
@@ -200,8 +195,7 @@ class databox_subdefTest extends PHPUnit_Framework_TestCase
$options = $object->getOptions();
$this->assertTrue(is_array($options));
- foreach ($options as $option)
- {
+ foreach ($options as $option) {
$this->assertInstanceOf('\\Alchemy\\Phrasea\\Media\\Subdef\\OptionType\\OptionType', $option);
}
}
@@ -220,7 +214,7 @@ class databox_subdefTest extends PHPUnit_Framework_TestCase
flexpaper
';
- $type = new \Alchemy\Phrasea\Media\Type\Flash();
+ $type = new \Alchemy\Phrasea\Media\Type\Flash();
$object = new databox_subdef($type, simplexml_load_string($xml));
$this->assertInstanceOf('\\MediaAlchemyst\\Specification\\Flash', $object->getSpecs());
@@ -228,8 +222,7 @@ class databox_subdefTest extends PHPUnit_Framework_TestCase
$options = $object->getOptions();
$this->assertTrue(is_array($options));
- foreach ($options as $option)
- {
+ foreach ($options as $option) {
$this->assertInstanceOf('\\Alchemy\\Phrasea\\Media\\Subdef\\OptionType\\OptionType', $option);
}
}
@@ -241,8 +234,7 @@ class databox_subdefTest extends PHPUnit_Framework_TestCase
public function testGetAvailableSubdefTypes($object)
{
- foreach ($object->getAvailableSubdefTypes() as $type)
- {
+ foreach ($object->getAvailableSubdefTypes() as $type) {
$this->assertInstanceOf('\\Alchemy\\Phrasea\\Media\\Subdef\\Subdef', $type);
}
}
@@ -256,15 +248,14 @@ class databox_subdefTest extends PHPUnit_Framework_TestCase
image
';
- $typeAudio = new \Alchemy\Phrasea\Media\Type\Audio();
+ $typeAudio = new \Alchemy\Phrasea\Media\Type\Audio();
$typeDocument = new \Alchemy\Phrasea\Media\Type\Document();
- $typeVideo = new \Alchemy\Phrasea\Media\Type\Video();
+ $typeVideo = new \Alchemy\Phrasea\Media\Type\Video();
return array(
- array(new databox_subdef($typeAudio, simplexml_load_string($xmlImage))),
- array(new databox_subdef($typeDocument, simplexml_load_string($xmlImage))),
- array(new databox_subdef($typeVideo, simplexml_load_string($xmlImage))),
+ array(new databox_subdef($typeAudio, simplexml_load_string($xmlImage))),
+ array(new databox_subdef($typeDocument, simplexml_load_string($xmlImage))),
+ array(new databox_subdef($typeVideo, simplexml_load_string($xmlImage))),
);
}
-
}
diff --git a/tests/databox/databox_subdefsStructureTest.php b/tests/databox/databox_subdefsStructureTest.php
deleted file mode 100644
index 07678431ce..0000000000
--- a/tests/databox/databox_subdefsStructureTest.php
+++ /dev/null
@@ -1,82 +0,0 @@
-markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_subdef().
- */
- public function testGet_subdef()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testDelete_subdef().
- */
- public function testDelete_subdef()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testAdd_subdef().
- */
- public function testAdd_subdef()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testSet_subdef().
- */
- public function testSet_subdef()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
-}
diff --git a/tests/formatTest.php b/tests/formatTest.php
deleted file mode 100644
index a0b0b2e9ce..0000000000
--- a/tests/formatTest.php
+++ /dev/null
@@ -1,25 +0,0 @@
-markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- public function testArr_to_csv()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
-}
-
diff --git a/tests/geonamesTest.php b/tests/geonamesTest.php
index 29e8af53db..d667e2ce42 100644
--- a/tests/geonamesTest.php
+++ b/tests/geonamesTest.php
@@ -4,79 +4,75 @@ require_once __DIR__ . '/PhraseanetPHPUnitAbstract.class.inc';
class geonamesTest extends PhraseanetPHPUnitAbstract
{
+ /**
+ * @var geonames
+ */
+ protected $object;
- /**
- * @var geonames
- */
- protected $object;
-
- public function setUp()
- {
- parent::setUp();
- $this->object = new geonames();
- }
-
- public function testName_from_id()
- {
- $result = $this->object->name_from_id(2989317);
- $this->assertEquals("Orléans, France", $result);
- }
-
- public function testGet_country()
- {
- $orleans = $this->object->find_city('orléans, france');
- $this->assertTrue(is_array($orleans));
- $this->assertTrue(count($orleans) === 1);
- $orleans = array_pop($orleans);
-
- $found = $this->object->get_country($orleans['geoname_id']);
-
- $this->assertEquals($found, $orleans['country']);
- $this->assertEquals($found, 'France');
- }
-
- public function testGet_country_code()
- {
- $this->assertEquals('FR', $this->object->get_country_code(2989317));
- $this->assertEquals('', $this->object->get_country_code(298945135163153317));
- $this->assertEquals('', $this->object->get_country_code('29894513516315331dsfsd7'));
- $this->assertEquals('', $this->object->get_country_code('dsfsd'));
- }
-
- public function testFind_city()
- {
- $orleans = $this->object->find_city('orléa');
- $this->assertTrue(is_array($orleans));
- foreach ($orleans as $potential)
+ public function setUp()
{
- $this->assertArrayHasKey('region', $potential);
- $this->assertArrayHasKey('title_highlighted', $potential);
- $this->assertArrayHasKey('country', $potential);
- $this->assertArrayHasKey('title', $potential);
- $this->assertArrayHasKey('country_highlighted', $potential);
- $this->assertArrayHasKey('geoname_id', $potential);
- $this->assertTrue(is_int($potential['geoname_id']));
- $this->assertTrue(is_string($potential['country_highlighted']));
- $this->assertTrue(is_string($potential['title']));
- $this->assertTrue(is_string($potential['country']));
- $this->assertTrue(is_string($potential['title_highlighted']));
- $this->assertTrue(is_string($potential['region']));
+ parent::setUp();
+ $this->object = new geonames();
}
- }
- public function testFind_geoname_from_ip()
- {
- $result = $this->object->find_geoname_from_ip('80.12.81.18');
- $this->assertArrayHasKey('city', $result);
- $this->assertArrayHasKey('country_code', $result);
- $this->assertArrayHasKey('country', $result);
- $this->assertArrayHasKey('fips', $result);
- $this->assertArrayHasKey('longitude', $result);
- $this->assertArrayHasKey('latitude', $result);
- $this->assertEquals("Paris", $result['city']);
- $this->assertEquals("FR", $result['country_code']);
- $this->assertEquals("France", $result['country']);
- }
+ public function testName_from_id()
+ {
+ $result = $this->object->name_from_id(2989317);
+ $this->assertEquals("Orléans, France", $result);
+ }
+ public function testGet_country()
+ {
+ $orleans = $this->object->find_city('orléans, france');
+ $this->assertTrue(is_array($orleans));
+ $this->assertTrue(count($orleans) === 1);
+ $orleans = array_pop($orleans);
+
+ $found = $this->object->get_country($orleans['geoname_id']);
+
+ $this->assertEquals($found, $orleans['country']);
+ $this->assertEquals($found, 'France');
+ }
+
+ public function testGet_country_code()
+ {
+ $this->assertEquals('FR', $this->object->get_country_code(2989317));
+ $this->assertEquals('', $this->object->get_country_code(298945135163153317));
+ $this->assertEquals('', $this->object->get_country_code('29894513516315331dsfsd7'));
+ $this->assertEquals('', $this->object->get_country_code('dsfsd'));
+ }
+
+ public function testFind_city()
+ {
+ $orleans = $this->object->find_city('orléa');
+ $this->assertTrue(is_array($orleans));
+ foreach ($orleans as $potential) {
+ $this->assertArrayHasKey('region', $potential);
+ $this->assertArrayHasKey('title_highlighted', $potential);
+ $this->assertArrayHasKey('country', $potential);
+ $this->assertArrayHasKey('title', $potential);
+ $this->assertArrayHasKey('country_highlighted', $potential);
+ $this->assertArrayHasKey('geoname_id', $potential);
+ $this->assertTrue(is_int($potential['geoname_id']));
+ $this->assertTrue(is_string($potential['country_highlighted']));
+ $this->assertTrue(is_string($potential['title']));
+ $this->assertTrue(is_string($potential['country']));
+ $this->assertTrue(is_string($potential['title_highlighted']));
+ $this->assertTrue(is_string($potential['region']));
+ }
+ }
+
+ public function testFind_geoname_from_ip()
+ {
+ $result = $this->object->find_geoname_from_ip('80.12.81.18');
+ $this->assertArrayHasKey('city', $result);
+ $this->assertArrayHasKey('country_code', $result);
+ $this->assertArrayHasKey('country', $result);
+ $this->assertArrayHasKey('fips', $result);
+ $this->assertArrayHasKey('longitude', $result);
+ $this->assertArrayHasKey('latitude', $result);
+ $this->assertEquals("Paris", $result['city']);
+ $this->assertEquals("FR", $result['country_code']);
+ $this->assertEquals("France", $result['country']);
+ }
}
-
diff --git a/tests/http/http_requestTest.php b/tests/http/http_requestTest.php
index 0060245e1c..4e169b36b0 100644
--- a/tests/http/http_requestTest.php
+++ b/tests/http/http_requestTest.php
@@ -14,26 +14,11 @@ class http_requestTest extends PHPUnit_Framework_TestCase
$this->object = new http_request();
}
- /**
- * Tears down the fixture, for example, closes a network connection.
- * This method is called after a test is executed.
- */
- protected function tearDown()
- {
-
- }
-
- /**
- * @todo Implement testGetInstance().
- */
public function testGetInstance()
{
$this->assertInstanceOf('http_request', http_request::getInstance());
}
- /**
- * @todo Implement testIs_ajax().
- */
public function testIs_ajax()
{
$this->assertFalse($this->object->is_ajax());
@@ -41,9 +26,6 @@ class http_requestTest extends PHPUnit_Framework_TestCase
$this->assertTrue($this->object->is_ajax());
}
- /**
- * @todo Implement testComes_from_flash().
- */
public function testComes_from_flash()
{
$user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null;
@@ -68,9 +50,6 @@ class http_requestTest extends PHPUnit_Framework_TestCase
$this->assertFalse($this->object->comes_from_flash());
}
- /**
- * @todo Implement testGet_code().
- */
public function testGet_code()
{
$this->assertNull($this->object->get_code());
@@ -84,18 +63,12 @@ class http_requestTest extends PHPUnit_Framework_TestCase
$this->assertEquals(0, $this->object->get_code());
}
- /**
- * @todo Implement testSet_code().
- */
public function testSet_code()
{
$this->object->set_code(302);
$this->assertEquals(302, $this->object->get_code());
}
- /**
- * @todo Implement testGet_parms().
- */
public function testGet_parms()
{
$_GET = array('lili' => '25', 'popo' => array('tip', 'top'));
@@ -143,9 +116,6 @@ class http_requestTest extends PHPUnit_Framework_TestCase
$_GET = $_POST = array();
}
- /**
- * @todo Implement testGet_parms_from_serialized_datas().
- */
public function testGet_parms_from_serialized_datas()
{
// Remove the following lines when you implement this test.
@@ -154,9 +124,6 @@ class http_requestTest extends PHPUnit_Framework_TestCase
);
}
- /**
- * @todo Implement testHas_post_datas().
- */
public function testHas_post_datas()
{
$this->assertFalse($this->object->has_post_datas());
@@ -164,18 +131,12 @@ class http_requestTest extends PHPUnit_Framework_TestCase
$this->assertTrue($this->object->has_post_datas());
}
- /**
- * @todo Implement testGet_post_datas().
- */
public function testGet_post_datas()
{
$post = $_POST = array('Plili' => '25', 'Gpopo' => array('mtip', 'btop'));
$this->assertEquals($post, $this->object->get_post_datas());
}
- /**
- * @todo Implement testHas_get_datas().
- */
public function testHas_get_datas()
{
$this->assertFalse($this->object->has_get_datas());
@@ -183,9 +144,6 @@ class http_requestTest extends PHPUnit_Framework_TestCase
$this->assertTrue($this->object->has_get_datas());
}
- /**
- * @todo Implement testHas_datas().
- */
public function testHas_datas()
{
$_POST = $_GET = array();
@@ -213,9 +171,6 @@ class http_requestTest extends PHPUnit_Framework_TestCase
);
}
- /**
- * @todo Implement testIs_command_line().
- */
public function testIs_command_line()
{
$this->assertTrue($this->object->is_command_line());
diff --git a/tests/lazaretFileTest.php b/tests/lazaretFileTest.php
deleted file mode 100644
index 452e7302fd..0000000000
--- a/tests/lazaretFileTest.php
+++ /dev/null
@@ -1,68 +0,0 @@
-markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testDelete().
- */
- public function testDelete()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testSubstitute().
- */
- public function testSubstitute()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testMove_uploaded_to_lazaret().
- */
- public function testMove_uploaded_to_lazaret()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testStream_thumbnail().
- */
- public function testStream_thumbnail()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
-}
diff --git a/tests/lazaretTest.php b/tests/lazaretTest.php
deleted file mode 100644
index af038aecca..0000000000
--- a/tests/lazaretTest.php
+++ /dev/null
@@ -1,29 +0,0 @@
-object = new lazaret;
- }
-
- public function testIsOk()
- {
- $this->markTestIncomplete();
- foreach ($this->object->get_elements() as $element)
- {
-
- }
- }
-
-}
-
diff --git a/tests/listeTest.php b/tests/listeTest.php
deleted file mode 100644
index 0013a3736f..0000000000
--- a/tests/listeTest.php
+++ /dev/null
@@ -1,24 +0,0 @@
-markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
-}
diff --git a/tests/loginTest.php b/tests/loginTest.php
deleted file mode 100644
index 656a8a7e0f..0000000000
--- a/tests/loginTest.php
+++ /dev/null
@@ -1,79 +0,0 @@
-markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testRegister_enabled().
- */
- public function testRegister_enabled()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_language_selector().
- */
- public function testGet_language_selector()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_password_link().
- */
- public function testGet_password_link()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_register_link().
- */
- public function testGet_register_link()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_guest_link().
- */
- public function testGet_guest_link()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
-}
diff --git a/tests/logsTest.php b/tests/logsTest.php
deleted file mode 100644
index 3ca16ea967..0000000000
--- a/tests/logsTest.php
+++ /dev/null
@@ -1,24 +0,0 @@
-markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
-}
diff --git a/tests/mailTest.php b/tests/mailTest.php
deleted file mode 100644
index cb1406fe23..0000000000
--- a/tests/mailTest.php
+++ /dev/null
@@ -1,167 +0,0 @@
-markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testSend_validation_results().
- */
- public function testSend_validation_results()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testHack_alert().
- */
- public function testHack_alert()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testFtp_sent().
- */
- public function testFtp_sent()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testFtp_receive().
- */
- public function testFtp_receive()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testSend_documents().
- */
- public function testSend_documents()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testForgot_passord().
- */
- public function testForgot_passord()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testRegister_confirm().
- */
- public function testRegister_confirm()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testRegister_user().
- */
- public function testRegister_user()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testReset_email().
- */
- public function testReset_email()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testMail_confirm_registered().
- */
- public function testMail_confirm_registered()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testMail_confirm_unregistered().
- */
- public function testMail_confirm_unregistered()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testMail_confirmation().
- */
- public function testMail_confirmation()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testSend_mail().
- */
- public function testSend_mail()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
-}
diff --git a/tests/media/Permalink/media_Permalink_AdapterTest.php b/tests/media/Permalink/media_Permalink_AdapterTest.php
index 65506ac307..e058e67d51 100644
--- a/tests/media/Permalink/media_Permalink_AdapterTest.php
+++ b/tests/media/Permalink/media_Permalink_AdapterTest.php
@@ -4,146 +4,139 @@ require_once __DIR__ . '/../../PhraseanetPHPUnitAbstract.class.inc';
class media_Permalink_AdapterTest extends PhraseanetPHPUnitAbstract
{
+ /**
+ * @var media_Permalink_Adapter
+ */
+ static $object;
+ protected static $need_records = true;
- /**
- * @var media_Permalink_Adapter
- */
- static $object;
- protected static $need_records = true;
+ public static function setUpBeforeClass()
+ {
+ parent::setUpBeforeClass();
+ $databox = self::$record_1->get_databox();
+ static::$object = media_Permalink_Adapter::getPermalink($databox, self::$record_1->get_subdef('document'));
+ }
- public static function setUpBeforeClass()
- {
- parent::setUpBeforeClass();
- $databox = self::$record_1->get_databox();
- static::$object = media_Permalink_Adapter::getPermalink($databox, self::$record_1->get_subdef('document'));
- }
+ public function testGetPermalink()
+ {
+ $this->assertTrue((static::$object instanceof media_Permalink_Adapter));
+ }
- public static function tearDownAfterClass()
- {
- parent::tearDownAfterClass();
- }
+ public function testSet_is_activated()
+ {
+ static::$object->set_is_activated(true);
+ $this->assertTrue(static::$object->get_is_activated());
+ static::$object->set_is_activated(false);
+ $this->assertFalse(static::$object->get_is_activated());
+ static::$object->set_is_activated(true);
+ $this->assertTrue(static::$object->get_is_activated());
+ }
- public function testGetPermalink()
- {
- $this->assertTrue((static::$object instanceof media_Permalink_Adapter));
- }
+ public function testSet_label()
+ {
+ static::$object->set_label('coucou les chicos');
+ $this->assertEquals('coucou-les-chicos', static::$object->get_label());
+ static::$object->set_label('');
+ $this->assertEquals('', static::$object->get_label());
+ static::$object->set_label('JE ANp ra&é"\/,;:!§/.?%µ*ù$]@^\[{#~234567890°+\'(-è_çà');
+ $this->assertEquals('JE-ANp-raeu234567890-e_ca', static::$object->get_label());
+ }
- public function testSet_is_activated()
- {
- static::$object->set_is_activated(true);
- $this->assertTrue(static::$object->get_is_activated());
- static::$object->set_is_activated(false);
- $this->assertFalse(static::$object->get_is_activated());
- static::$object->set_is_activated(true);
- $this->assertTrue(static::$object->get_is_activated());
- }
-
- public function testSet_label()
- {
- static::$object->set_label('coucou les chicos');
- $this->assertEquals('coucou-les-chicos', static::$object->get_label());
- static::$object->set_label('');
- $this->assertEquals('', static::$object->get_label());
- static::$object->set_label('JE ANp ra&é"\/,;:!§/.?%µ*ù$]@^\[{#~234567890°+\'(-è_çà');
- $this->assertEquals('JE-ANp-raeu234567890-e_ca', static::$object->get_label());
- }
-
- public function testGet_url()
- {
- $registry = registry::get_instance();
- $url = $registry->get('GV_ServerName') . 'permalink/v1/' . static::$object->get_label() . '/' . self::$record_1->get_sbas_id() . '/' . self::$record_1->get_record_id() . '/' .
+ public function testGet_url()
+ {
+ $registry = registry::get_instance();
+ $url = $registry->get('GV_ServerName') . 'permalink/v1/' . static::$object->get_label() . '/' . self::$record_1->get_sbas_id() . '/' . self::$record_1->get_record_id() . '/' .
static::$object->get_token() . '/document/';
- $this->assertEquals($url, static::$object->get_url($registry));
- }
+ $this->assertEquals($url, static::$object->get_url($registry));
+ }
- /**
- * @todo Implement testGet_page().
- */
- public function testGet_page()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
+ /**
+ * @todo Implement testGet_page().
+ */
+ public function testGet_page()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
'This test has not been implemented yet.'
- );
- }
+ );
+ }
- /**
- * @todo Implement testGet_id().
- */
- public function testGet_id()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
+ /**
+ * @todo Implement testGet_id().
+ */
+ public function testGet_id()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
'This test has not been implemented yet.'
- );
- }
+ );
+ }
- /**
- * @todo Implement testGet_token().
- */
- public function testGet_token()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
+ /**
+ * @todo Implement testGet_token().
+ */
+ public function testGet_token()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
'This test has not been implemented yet.'
- );
- }
+ );
+ }
- /**
- * @todo Implement testGet_is_activated().
- */
- public function testGet_is_activated()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
+ /**
+ * @todo Implement testGet_is_activated().
+ */
+ public function testGet_is_activated()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
'This test has not been implemented yet.'
- );
- $this->assertTrue(is_bool(static::$object->get_is_activated));
- }
+ );
+ $this->assertTrue(is_bool(static::$object->get_is_activated));
+ }
- /**
- * @todo Implement testGet_created_on().
- */
- public function testGet_created_on()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
+ /**
+ * @todo Implement testGet_created_on().
+ */
+ public function testGet_created_on()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
'This test has not been implemented yet.'
- );
- }
+ );
+ }
- /**
- * @todo Implement testGet_last_modified().
- */
- public function testGet_last_modified()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
+ /**
+ * @todo Implement testGet_last_modified().
+ */
+ public function testGet_last_modified()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
'This test has not been implemented yet.'
- );
- }
+ );
+ }
- /**
- * @todo Implement testGet_label().
- */
- public function testGet_label()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
+ /**
+ * @todo Implement testGet_label().
+ */
+ public function testGet_label()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
'This test has not been implemented yet.'
- );
- }
+ );
+ }
- /**
- * @todo Implement testCreate().
- */
- public function testCreate()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
+ /**
+ * @todo Implement testCreate().
+ */
+ public function testCreate()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
'This test has not been implemented yet.'
- );
- }
-
+ );
+ }
}
diff --git a/tests/media/media_subdefTest.php b/tests/media/media_subdefTest.php
index 5eff4b1954..cf0527510f 100644
--- a/tests/media/media_subdefTest.php
+++ b/tests/media/media_subdefTest.php
@@ -8,10 +8,12 @@ class media_subdefTest extends \PhraseanetPHPUnitAbstract
* @var \media_subdef
*/
protected static $objectPresent;
+
/**
* @var \media_subdef
*/
protected static $objectNotPresent;
+
/**
* @var \record_adapter
*/
@@ -65,7 +67,7 @@ class media_subdefTest extends \PhraseanetPHPUnitAbstract
$this->assertEquals(self::$recordonbleu->get_record_id(), self::$objectPresent->get_record()->get_record_id());
$this->assertEquals(self::$recordonbleu->get_sbas_id(), self::$objectNotPresent->get_record()->get_sbas_id());
$this->assertEquals(self::$recordonbleu->get_sbas_id(), self::$objectPresent->get_record()->get_sbas_id());
-}
+ }
/**
* @covers media_subdef::get_permalink
diff --git a/tests/metadata/description/descriptionTest.php b/tests/metadata/description/descriptionTest.php
index 6e5adc5b17..a0eb2613b6 100644
--- a/tests/metadata/description/descriptionTest.php
+++ b/tests/metadata/description/descriptionTest.php
@@ -4,74 +4,65 @@ require_once __DIR__ . '/../../PhraseanetPHPUnitAbstract.class.inc';
class metadataDescriptionTest extends PhraseanetPHPUnitAbstract
{
+ protected $metadatas = array();
- protected $metadatas = array();
-
- public function setUp()
- {
- $this->metadatas = databox::get_available_metadatas();
- }
-
- public function testMetadatas()
- {
- foreach($this->metadatas as $metadata)
+ public function setUp()
{
- $this->assertInstanceOf('metadata_Interface', $metadata);
- $this->assertInstanceOf('metadata_Abstract', $metadata);
-
- $this->assertTrue(is_bool($metadata::is_multi()));
- $this->assertEquals($metadata::MULTI, $metadata::is_multi());
-
- $this->assertTrue(is_bool($metadata::is_deprecated()));
- $this->assertEquals($metadata::DEPRECATED, $metadata::is_deprecated());
-
- $this->assertTrue(is_bool($metadata::is_readonly()));
- $this->assertEquals($metadata::READONLY, $metadata::is_readonly());
-
- $this->assertTrue(is_bool($metadata:: is_mandatory()));
- $this->assertEquals($metadata::MANDATORY, $metadata::is_mandatory());
-
- $this->assertTrue(is_array($metadata::available_values()));
- foreach($metadata::available_values() as $value)
- {
- $this->assertTrue(is_string($value));
- }
-
- $this->assertTrue(is_string($metadata::get_tagname()));
- $this->assertEquals($metadata::TAGNAME, $metadata::get_tagname());
-
- $this->assertTrue(is_string($metadata::get_type()));
- $this->assertEquals($metadata::TYPE, $metadata::get_type());
-
- $this->assertTrue(is_string($metadata::get_namespace()));
- $this->assertEquals($metadata::NAME_SPACE, $metadata::get_namespace());
-
- $this->assertEquals($metadata::SOURCE, $metadata::get_source());
- if($metadata instanceof metadata_description_nosource)
- {
- $this->assertNull ($metadata::get_source());
- }
- else
- {
- $this->assertTrue(is_string($metadata::get_source()));
- $this->assertTrue(strpos($metadata::get_source(), '/rdf:RDF/rdf:Description/') === 0, get_class($metadata));
- }
-
- $this->assertEquals($metadata::MIN_LENGTH, $metadata::minlength());
- if(!is_null($metadata::minlength()))
- {
- $this->assertTrue(is_int($metadata::minlength()));
- $this->assertTrue($metadata::minlength()>=0);
- }
-
- $this->assertEquals($metadata::MAX_LENGTH, $metadata::maxlength());
- if(!is_null($metadata::maxlength()))
- {
- $this->assertTrue(is_int($metadata::maxlength()));
- $this->assertTrue($metadata::maxlength()>=0);
- }
+ parent::setUp();
+ $this->metadatas = databox::get_available_metadatas();
}
- }
+ public function testMetadatas()
+ {
+ foreach ($this->metadatas as $metadata) {
+ $this->assertInstanceOf('metadata_Interface', $metadata);
+ $this->assertInstanceOf('metadata_Abstract', $metadata);
+
+ $this->assertTrue(is_bool($metadata::is_multi()));
+ $this->assertEquals($metadata::MULTI, $metadata::is_multi());
+
+ $this->assertTrue(is_bool($metadata::is_deprecated()));
+ $this->assertEquals($metadata::DEPRECATED, $metadata::is_deprecated());
+
+ $this->assertTrue(is_bool($metadata::is_readonly()));
+ $this->assertEquals($metadata::READONLY, $metadata::is_readonly());
+
+ $this->assertTrue(is_bool($metadata:: is_mandatory()));
+ $this->assertEquals($metadata::MANDATORY, $metadata::is_mandatory());
+
+ $this->assertTrue(is_array($metadata::available_values()));
+ foreach ($metadata::available_values() as $value) {
+ $this->assertTrue(is_string($value));
+ }
+
+ $this->assertTrue(is_string($metadata::get_tagname()));
+ $this->assertEquals($metadata::TAGNAME, $metadata::get_tagname());
+
+ $this->assertTrue(is_string($metadata::get_type()));
+ $this->assertEquals($metadata::TYPE, $metadata::get_type());
+
+ $this->assertTrue(is_string($metadata::get_namespace()));
+ $this->assertEquals($metadata::NAME_SPACE, $metadata::get_namespace());
+
+ $this->assertEquals($metadata::SOURCE, $metadata::get_source());
+ if ($metadata instanceof metadata_description_nosource) {
+ $this->assertNull($metadata::get_source());
+ } else {
+ $this->assertTrue(is_string($metadata::get_source()));
+ $this->assertTrue(strpos($metadata::get_source(), '/rdf:RDF/rdf:Description/') === 0, get_class($metadata));
+ }
+
+ $this->assertEquals($metadata::MIN_LENGTH, $metadata::minlength());
+ if ( ! is_null($metadata::minlength())) {
+ $this->assertTrue(is_int($metadata::minlength()));
+ $this->assertTrue($metadata::minlength() >= 0);
+ }
+
+ $this->assertEquals($metadata::MAX_LENGTH, $metadata::maxlength());
+ if ( ! is_null($metadata::maxlength())) {
+ $this->assertTrue(is_int($metadata::maxlength()));
+ $this->assertTrue($metadata::maxlength() >= 0);
+ }
+ }
+ }
}
-
diff --git a/tests/module/console/module_console_aboutAuthorsTest.php b/tests/module/console/module_console_aboutAuthorsTest.php
index 3a9025d660..85f56884af 100644
--- a/tests/module/console/module_console_aboutAuthorsTest.php
+++ b/tests/module/console/module_console_aboutAuthorsTest.php
@@ -5,33 +5,29 @@ require_once __DIR__ . '/../../PhraseanetWebTestCaseAuthenticatedAbstract.class.
use Symfony\Component\Console\Tester\CommandTester;
use \Symfony\Component\Console\Application;
-
class module_console_aboutAuthorsTest extends PHPUnit_Framework_TestCase
{
+ /**
+ * @var module_console_aboutAuthors
+ */
+ protected $object;
- /**
- * @var module_console_aboutAuthors
- */
- protected $object;
+ /**
+ * @covers module_console_aboutAuthors::execute
+ */
+ public function testExecute()
+ {
+ // mock the Kernel or create one depending on your needs
+ $application = new Application();
+ $application->add(new module_console_aboutAuthors('about:authors'));
+ $command = $application->find('about:authors');
+ $commandTester = new CommandTester($command);
+ $commandTester->execute(array('command' => $command->getName()));
- /**
- * @covers module_console_aboutAuthors::execute
- */
- public function testExecute()
- {
- // mock the Kernel or create one depending on your needs
- $application = new Application();
- $application->add(new module_console_aboutAuthors('about:authors'));
-
- $command = $application->find('about:authors');
- $commandTester = new CommandTester($command);
- $commandTester->execute(array('command' => $command->getName()));
-
- $this->assertEquals(
+ $this->assertEquals(
trim(file_get_contents(__DIR__ . '/../../../AUTHORS'))
, trim($commandTester->getDisplay())
- );
- }
-
+ );
+ }
}
diff --git a/tests/module/console/module_console_aboutLicenseTest.php b/tests/module/console/module_console_aboutLicenseTest.php
index 261295e91e..770e9f3eb9 100644
--- a/tests/module/console/module_console_aboutLicenseTest.php
+++ b/tests/module/console/module_console_aboutLicenseTest.php
@@ -4,31 +4,30 @@ require_once __DIR__ . '/../../PhraseanetWebTestCaseAuthenticatedAbstract.class.
use Symfony\Component\Console\Tester\CommandTester;
use \Symfony\Component\Console\Application;
+
class module_console_aboutLicenseTest extends PHPUnit_Framework_TestCase
{
+ /**
+ * @var module_console_aboutLicense
+ */
+ protected $object;
- /**
- * @var module_console_aboutLicense
- */
- protected $object;
+ /**
+ * @covers module_console_aboutAuthors::execute
+ */
+ public function testExecute()
+ {
+ // mock the Kernel or create one depending on your needs
+ $application = new Application();
+ $application->add(new module_console_aboutLicense('about:license'));
- /**
- * @covers module_console_aboutAuthors::execute
- */
- public function testExecute()
- {
- // mock the Kernel or create one depending on your needs
- $application = new Application();
- $application->add(new module_console_aboutLicense('about:license'));
+ $command = $application->find('about:license');
+ $commandTester = new CommandTester($command);
+ $commandTester->execute(array('command' => $command->getName()));
- $command = $application->find('about:license');
- $commandTester = new CommandTester($command);
- $commandTester->execute(array('command' => $command->getName()));
-
- $this->assertEquals(
+ $this->assertEquals(
trim(file_get_contents(__DIR__ . '/../../../LICENSE'))
, trim($commandTester->getDisplay())
- );
- }
-
+ );
+ }
}
diff --git a/tests/module/console/module_console_schedulerStartTest.php b/tests/module/console/module_console_schedulerStartTest.php
deleted file mode 100644
index 95b3868efe..0000000000
--- a/tests/module/console/module_console_schedulerStartTest.php
+++ /dev/null
@@ -1,40 +0,0 @@
-markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
-}
diff --git a/tests/module/console/module_console_schedulerStateTest.php b/tests/module/console/module_console_schedulerStateTest.php
index e0b63236d5..59eb190023 100644
--- a/tests/module/console/module_console_schedulerStateTest.php
+++ b/tests/module/console/module_console_schedulerStateTest.php
@@ -4,26 +4,24 @@ require_once __DIR__ . '/../../PhraseanetWebTestCaseAuthenticatedAbstract.class.
use Symfony\Component\Console\Tester\CommandTester;
use \Symfony\Component\Console\Application;
+
class module_console_schedulerStateTest extends PHPUnit_Framework_TestCase
{
- public function testExecute()
- {
- // mock the Kernel or create one depending on your needs
- $application = new Application();
- $application->add(new module_console_schedulerState('system:schedulerState'));
+ public function testExecute()
+ {
+ // mock the Kernel or create one depending on your needs
+ $application = new Application();
+ $application->add(new module_console_schedulerState('system:schedulerState'));
- $command = $application->find('system:schedulerState');
- $commandTester = new CommandTester($command);
- $commandTester->execute(array('command' => $command->getName()));
-
- $task_manager = new task_manager(appbox::get_instance(\bootstrap::getCore()));
- $state = $task_manager->get_scheduler_state();
-
- $sentence = sprintf('Scheduler is %s', $state['status']);
- $this->assertTrue(strpos($commandTester->getDisplay(), $sentence) !== false);
-
- }
+ $command = $application->find('system:schedulerState');
+ $commandTester = new CommandTester($command);
+ $commandTester->execute(array('command' => $command->getName()));
+ $task_manager = new task_manager(appbox::get_instance(\bootstrap::getCore()));
+ $state = $task_manager->get_scheduler_state();
+ $sentence = sprintf('Scheduler is %s', $state['status']);
+ $this->assertTrue(strpos($commandTester->getDisplay(), $sentence) !== false);
+ }
}
diff --git a/tests/module/console/module_console_systemTemplateGeneratorTest.php b/tests/module/console/module_console_systemTemplateGeneratorTest.php
index 9144975283..781ab61bc0 100644
--- a/tests/module/console/module_console_systemTemplateGeneratorTest.php
+++ b/tests/module/console/module_console_systemTemplateGeneratorTest.php
@@ -4,23 +4,23 @@ require_once __DIR__ . '/../../PhraseanetWebTestCaseAuthenticatedAbstract.class.
use Symfony\Component\Console\Tester\CommandTester;
use \Symfony\Component\Console\Application;
+
class module_console_systemTemplateGeneratorTest extends PHPUnit_Framework_TestCase
{
- public function testExecute()
- {
- // mock the Kernel or create one depending on your needs
- $application = new Application();
- $application->add(new module_console_systemTemplateGenerator('system:templateGenerator'));
- $command = $application->find('system:templateGenerator');
- $commandTester = new CommandTester($command);
- $commandTester->execute(array('command' => $command->getName()));
+ public function testExecute()
+ {
+ // mock the Kernel or create one depending on your needs
+ $application = new Application();
+ $application->add(new module_console_systemTemplateGenerator('system:templateGenerator'));
- $last_line = array_pop(explode("\n", trim($commandTester->getDisplay())));
-
- $this->assertTrue(strpos($last_line, 'templates failed') === false, 'Some templates failed');
- $this->assertTrue(strpos($last_line, 'templates generated') !== true, 'Some templates have been generated');
- }
+ $command = $application->find('system:templateGenerator');
+ $commandTester = new CommandTester($command);
+ $commandTester->execute(array('command' => $command->getName()));
+ $last_line = array_pop(explode("\n", trim($commandTester->getDisplay())));
+ $this->assertTrue(strpos($last_line, 'templates failed') === false, 'Some templates failed');
+ $this->assertTrue(strpos($last_line, 'templates generated') !== true, 'Some templates have been generated');
+ }
}
diff --git a/tests/module/console/module_console_systemUpgradeTest.php b/tests/module/console/module_console_systemUpgradeTest.php
deleted file mode 100644
index 2acc00803c..0000000000
--- a/tests/module/console/module_console_systemUpgradeTest.php
+++ /dev/null
@@ -1,40 +0,0 @@
-markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
-}
diff --git a/tests/module/console/module_console_tasklistTest.php b/tests/module/console/module_console_tasklistTest.php
index 60a02e01df..584bb49b84 100644
--- a/tests/module/console/module_console_tasklistTest.php
+++ b/tests/module/console/module_console_tasklistTest.php
@@ -3,39 +3,34 @@
require_once __DIR__ . '/../../PhraseanetWebTestCaseAuthenticatedAbstract.class.inc';
use Symfony\Component\Console\Tester\CommandTester;
-use \Symfony\Component\Console\Application;
+use Symfony\Component\Console\Application;
+
class module_console_tasklistTest extends PHPUnit_Framework_TestCase
{
-
- /**
- * @covers module_console_tasklist::execute
- */
- public function testExecute()
- {
- // mock the Kernel or create one depending on your needs
- $application = new Application();
- $application->add(new module_console_tasklist('task:list'));
-
- $command = $application->find('task:list');
- $commandTester = new CommandTester($command);
- $commandTester->execute(array('command' => $command->getName()));
-
- $task_manager = new task_manager(appbox::get_instance(\bootstrap::getCore()));
- $lines = explode("\n", trim($commandTester->getDisplay()));
-
- if(count($task_manager->get_tasks()) > 0)
+ /**
+ * @covers module_console_tasklist::execute
+ */
+ public function testExecute()
{
- $this->assertEquals(count($task_manager->get_tasks()), count($lines));
- foreach($task_manager->get_tasks() as $task)
- {
- $this->assertTrue(strpos($commandTester->getDisplay(), $task->get_title()) !== false);
- }
- }
- else
- {
- $this->assertEquals(1, $n_lines);
- }
- }
+ // mock the Kernel or create one depending on your needs
+ $application = new Application();
+ $application->add(new module_console_tasklist('task:list'));
+ $command = $application->find('task:list');
+ $commandTester = new CommandTester($command);
+ $commandTester->execute(array('command' => $command->getName()));
+
+ $task_manager = new task_manager(appbox::get_instance(\bootstrap::getCore()));
+ $lines = explode("\n", trim($commandTester->getDisplay()));
+
+ if (count($task_manager->get_tasks()) > 0) {
+ $this->assertEquals(count($task_manager->get_tasks()), count($lines));
+ foreach ($task_manager->get_tasks() as $task) {
+ $this->assertTrue(strpos($commandTester->getDisplay(), $task->get_title()) !== false);
+ }
+ } else {
+ $this->assertEquals(1, $n_lines);
+ }
+ }
}
diff --git a/tests/module/console/module_console_taskrunTest.php b/tests/module/console/module_console_taskrunTest.php
deleted file mode 100644
index ee5b8db8d3..0000000000
--- a/tests/module/console/module_console_taskrunTest.php
+++ /dev/null
@@ -1,40 +0,0 @@
-markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
-}
diff --git a/tests/p4fieldTest.php b/tests/p4fieldTest.php
deleted file mode 100644
index 9788af0450..0000000000
--- a/tests/p4fieldTest.php
+++ /dev/null
@@ -1,35 +0,0 @@
-markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testIsno().
- */
- public function testIsno()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
-}
diff --git a/tests/p4fileTest.php b/tests/p4fileTest.php
deleted file mode 100644
index 0a45c8fdbf..0000000000
--- a/tests/p4fileTest.php
+++ /dev/null
@@ -1,57 +0,0 @@
-markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testArchiveFile().
- */
- public function testArchiveFile()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testCheck_file_error().
- */
- public function testCheck_file_error()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testSubstitute().
- */
- public function testSubstitute()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
-}
diff --git a/tests/p4stringTest.php b/tests/p4stringTest.php
index e59449fc24..416e695385 100644
--- a/tests/p4stringTest.php
+++ b/tests/p4stringTest.php
@@ -71,7 +71,7 @@ class p4stringTest extends PhraseanetPHPUnitAbstract
public function testCleanTags()
{
- $string = ' yuh i jkn lkk jk ';
+ $string = ' yuh i jkn lkk jk ';
$this->assertEquals($string, p4string::cleanTags($string));
$stringb = ' yuh i jkn lkk jk ';
$this->assertEquals($string, p4string::cleanTags($stringb));
@@ -139,6 +139,4 @@ class p4stringTest extends PhraseanetPHPUnitAbstract
$this->assertEquals('00:00', p4string::format_seconds(0));
$this->assertEquals('', p4string::format_seconds(-15));
}
-
}
-
diff --git a/tests/phraseaTest.php b/tests/phraseaTest.php
deleted file mode 100644
index e40fd1ff1e..0000000000
--- a/tests/phraseaTest.php
+++ /dev/null
@@ -1,212 +0,0 @@
-markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testIs_scheduler_started().
- */
- public function testIs_scheduler_started()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testStart().
- */
- public function testStart()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGetHome().
- */
- public function testGetHome()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testClear_sbas_params().
- */
- public function testClear_sbas_params()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testSbas_params().
- */
- public function testSbas_params()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGuest_allowed().
- */
- public function testGuest_allowed()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testLoad_events().
- */
- public function testLoad_events()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testUse_i18n().
- */
- public function testUse_i18n()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testModulesName().
- */
- public function testModulesName()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testSbasFromBas().
- */
- public function testSbasFromBas()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testBaseFromColl().
- */
- public function testBaseFromColl()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testCollFromBas().
- */
- public function testCollFromBas()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testSbas_names().
- */
- public function testSbas_names()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testBas_names().
- */
- public function testBas_names()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testRedirect().
- */
- public function testRedirect()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testHeaders().
- */
- public function testHeaders()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testScheduler_key().
- */
- public function testScheduler_key()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
-}
-
diff --git a/tests/phraseadateTest.php b/tests/phraseadateTest.php
deleted file mode 100644
index 4a84f708ed..0000000000
--- a/tests/phraseadateTest.php
+++ /dev/null
@@ -1,80 +0,0 @@
-markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGetDate().
- */
- public function testGetDate()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGetPrettyString().
- */
- public function testGetPrettyString()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testFormat_mysql().
- */
- public function testFormat_mysql()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testIsodateToDate().
- */
- public function testIsodateToDate()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testDateToIsodate().
- */
- public function testDateToIsodate()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
-}
diff --git a/tests/queriesTest.php b/tests/queriesTest.php
deleted file mode 100644
index ac191d80f1..0000000000
--- a/tests/queriesTest.php
+++ /dev/null
@@ -1,57 +0,0 @@
-markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testTopics_exists().
- */
- public function testTopics_exists()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testDropdown_topics().
- */
- public function testDropdown_topics()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testHistory().
- */
- public function testHistory()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
-}
diff --git a/tests/randomTest.php b/tests/randomTest.php
index 306a254016..7df61d4263 100644
--- a/tests/randomTest.php
+++ b/tests/randomTest.php
@@ -74,9 +74,6 @@ class randomTest extends PhraseanetPHPUnitAbstract
$this->testGetUrlToken();
}
- /**
- * @todo Implement testUpdateToken().
- */
public function testUpdateToken()
{
$this->testGetUrlToken();
@@ -139,4 +136,3 @@ class randomTest extends PhraseanetPHPUnitAbstract
}
}
}
-
diff --git a/tests/record/adapterTest.php b/tests/record/adapterTest.php
index 87b9b78734..ca17cd7445 100644
--- a/tests/record/adapterTest.php
+++ b/tests/record/adapterTest.php
@@ -4,49 +4,42 @@ require_once __DIR__ . '/../PhraseanetPHPUnitAuthenticatedAbstract.class.inc';
class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
{
-
- /**
- * @var record_adapter
- */
- protected static $grouping;
- protected static $need_records = true;
- protected static $need_story = true;
- protected static $need_subdefs = true;
-
- public static function setUpBeforeClass()
- {
- parent::setUpBeforeClass();
- $system_file = self::$record_1->get_hd_file();
- $databox = self::$record_1->get_databox();
- $metadatas = $system_file->extract_metadatas($databox->get_meta_structure());
- static::$record_1->set_metadatas($metadatas['metadatas']);
-
- $databox = self::$record_23->get_databox();
- $system_file = self::$record_23->get_hd_file();
- $metadatas = $system_file->extract_metadatas($databox->get_meta_structure());
- static::$record_23->set_metadatas($metadatas['metadatas']);
-
-
/**
- * Reset thumbtitle in order to have consistent tests (testGet_title)
+ * @var record_adapter
*/
- foreach(static::$record_1->get_databox()->get_meta_structure() as $databox_field)
- {
+ protected static $grouping;
+ protected static $need_records = true;
+ protected static $need_story = true;
+ protected static $need_subdefs = true;
- /* @var $databox_field \databox_field */
- $databox_field->set_thumbtitle(false)->save();
+ public static function setUpBeforeClass()
+ {
+ parent::setUpBeforeClass();
+ $system_file = self::$record_1->get_hd_file();
+ $databox = self::$record_1->get_databox();
+ $metadatas = $system_file->extract_metadatas($databox->get_meta_structure());
+ static::$record_1->set_metadatas($metadatas['metadatas']);
+
+ $databox = self::$record_23->get_databox();
+ $system_file = self::$record_23->get_hd_file();
+ $metadatas = $system_file->extract_metadatas($databox->get_meta_structure());
+ static::$record_23->set_metadatas($metadatas['metadatas']);
+
+
+ /**
+ * Reset thumbtitle in order to have consistent tests (testGet_title)
+ */
+ foreach (static::$record_1->get_databox()->get_meta_structure() as $databox_field) {
+
+ /* @var $databox_field \databox_field */
+ $databox_field->set_thumbtitle(false)->save();
+ }
+
+
+ $system_file = new system_file(__DIR__ . '/../testfiles/cestlafete.jpg');
}
-
- $system_file = new system_file(__DIR__ . '/../testfiles/cestlafete.jpg');
- }
-
- public static function tearDownAfterClass()
- {
- parent::tearDownAfterClass();
- }
-
- /**
+ /**
* Check whether a record is delete from order_elements when
* record::delete is call
* @covers \record_adapter
@@ -85,534 +78,503 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
try {
$order = new set_order($orderId);
} catch (\Exception $e) {
- $this->fail('should not raise an exception' . $e->getMessage() . ' ' . $e->getLine() . ' ' . $e->getFile() . ' ' . $e->getTraceAsString());
+ $this->fail('should not raise an exception' . $e->getMessage() . ' ' . $e->getLine() . ' ' . $e->getFile() . ' ' . $e->getTraceAsString());
}
}
- public function testGet_creation_date()
- {
- $date_obj = new DateTime();
- $this->assertTrue((static::$record_1->get_creation_date() instanceof DateTime));
- $this->assertTrue((static::$record_1->get_creation_date() <= $date_obj));
- }
-
- protected function assertDateAtom($date)
- {
- return $this->assertRegExp('/\d{4}[-]\d{2}[-]\d{2}[T]\d{2}[:]\d{2}[:]\d{2}[+]\d{2}[:]\d{2}/', $date);
- }
-
- public function testGet_uuid()
- {
- $this->assertTrue(uuid::is_valid(static::$record_1->get_uuid()));
- }
-
- public function testGet_modification_date()
- {
- $date_obj = new DateTime();
- $this->assertTrue((static::$record_1->get_creation_date() instanceof DateTime));
- $this->assertTrue((static::$record_1->get_creation_date() <= $date_obj));
- }
-
- public function testGet_number()
- {
- self::$record_1->set_number(24);
- $this->assertEquals(24, self::$record_1->get_number());
- self::$record_1->set_number(42);
- $this->assertEquals(42, self::$record_1->get_number());
- self::$record_1->set_number(0);
- $this->assertEquals(0, self::$record_1->get_number());
- self::$record_1->set_number(null);
- $this->assertEquals(0, self::$record_1->get_number());
- }
-
- public function testSet_number()
- {
- $this->testGet_number();
- }
-
- public function testSet_type()
- {
- try
+ public function testGet_creation_date()
{
- self::$record_1->set_type('jambon');
- $this->fail();
+ $date_obj = new DateTime();
+ $this->assertTrue((static::$record_1->get_creation_date() instanceof DateTime));
+ $this->assertTrue((static::$record_1->get_creation_date() <= $date_obj));
}
- catch (Exception $e)
+
+ protected function assertDateAtom($date)
+ {
+ return $this->assertRegExp('/\d{4}[-]\d{2}[-]\d{2}[T]\d{2}[:]\d{2}[:]\d{2}[+]\d{2}[:]\d{2}/', $date);
+ }
+
+ public function testGet_uuid()
+ {
+ $this->assertTrue(uuid::is_valid(static::$record_1->get_uuid()));
+ }
+
+ public function testGet_modification_date()
+ {
+ $date_obj = new DateTime();
+ $this->assertTrue((static::$record_1->get_creation_date() instanceof DateTime));
+ $this->assertTrue((static::$record_1->get_creation_date() <= $date_obj));
+ }
+
+ public function testGet_number()
+ {
+ self::$record_1->set_number(24);
+ $this->assertEquals(24, self::$record_1->get_number());
+ self::$record_1->set_number(42);
+ $this->assertEquals(42, self::$record_1->get_number());
+ self::$record_1->set_number(0);
+ $this->assertEquals(0, self::$record_1->get_number());
+ self::$record_1->set_number(null);
+ $this->assertEquals(0, self::$record_1->get_number());
+ }
+
+ public function testSet_number()
+ {
+ $this->testGet_number();
+ }
+
+ public function testSet_type()
+ {
+ try {
+ self::$record_1->set_type('jambon');
+ $this->fail();
+ } catch (Exception $e) {
+
+ }
+ $old_type = self::$record_1->get_type();
+ self::$record_1->set_type('video');
+ $this->assertEquals('video', self::$record_1->get_type());
+ self::$record_1->set_type($old_type);
+ $this->assertEquals($old_type, self::$record_1->get_type());
+ }
+
+ public function testIs_grouping()
+ {
+ $this->assertFalse(self::$record_1->is_grouping());
+ $this->assertTrue(self::$story_1->is_grouping());
+ }
+
+ public function testGet_base_id()
+ {
+ $this->assertTrue(is_int(static::$record_1->get_base_id()));
+ $this->assertEquals(self::$collection->get_base_id(), static::$record_1->get_base_id());
+ $this->assertTrue(is_int(self::$story_1->get_base_id()));
+ $this->assertEquals(self::$collection->get_base_id(), self::$story_1->get_base_id());
+ }
+
+ public function testGet_record_id()
+ {
+ $this->assertTrue(is_int(static::$record_1->get_record_id()));
+ $this->assertTrue(is_int(self::$story_1->get_record_id()));
+ }
+
+ public function testGet_thumbnail()
+ {
+ $this->assertTrue((static::$record_1->get_thumbnail() instanceof media_subdef));
+ }
+
+ public function testGet_embedable_medias()
+ {
+ $embeddables = self::$record_1->get_embedable_medias();
+ $this->assertTrue(is_array($embeddables));
+ foreach ($embeddables as $subdef) {
+ $this->assertInstanceOf('media_subdef', $subdef);
+ }
+ }
+
+ public function testGet_status_icons()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ public function testGet_type()
+ {
+ $this->assertTrue(in_array(static::$record_1->get_type(), array('video', 'audio', 'image', 'document', 'flash', 'unknown')));
+ }
+
+ public function testGet_formated_duration()
+ {
+ $this->assertTrue(strpos(self::$record_23->get_formated_duration(), '00:17') === 0);
+ $this->assertEquals('', self::$record_1->get_formated_duration());
+ }
+
+ public function testGet_duration()
+ {
+ $this->assertEquals(17, round(self::$record_23->get_duration()));
+ $this->assertEquals(false, self::$record_1->get_duration());
+ }
+
+ public function testGet_rollover_thumbnail()
+ {
+ $this->assertInstanceOf('media_subdef', self::$record_23->get_rollover_thumbnail());
+ $this->assertNull(self::$record_1->get_rollover_thumbnail());
+ }
+
+ public function testGenerate_subdefs()
{
}
- $old_type = self::$record_1->get_type();
- self::$record_1->set_type('video');
- $this->assertEquals('video', self::$record_1->get_type());
- self::$record_1->set_type($old_type);
- $this->assertEquals($old_type, self::$record_1->get_type());
- }
- public function testIs_grouping()
- {
- $this->assertFalse(self::$record_1->is_grouping());
- $this->assertTrue(self::$story_1->is_grouping());
- }
-
- public function testGet_base_id()
- {
- $this->assertTrue(is_int(static::$record_1->get_base_id()));
- $this->assertEquals(self::$collection->get_base_id(), static::$record_1->get_base_id());
- $this->assertTrue(is_int(self::$story_1->get_base_id()));
- $this->assertEquals(self::$collection->get_base_id(), self::$story_1->get_base_id());
- }
-
- public function testGet_record_id()
- {
- $this->assertTrue(is_int(static::$record_1->get_record_id()));
- $this->assertTrue(is_int(self::$story_1->get_record_id()));
- }
-
- public function testGet_thumbnail()
- {
- $this->assertTrue((static::$record_1->get_thumbnail() instanceof media_subdef));
- }
-
- public function testGet_embedable_medias()
- {
- $embeddables = self::$record_1->get_embedable_medias();
- $this->assertTrue(is_array($embeddables));
- foreach ($embeddables as $subdef)
+ public function testGet_sha256()
{
- $this->assertInstanceOf('media_subdef', $subdef);
+ $this->assertNotNull(static::$record_1->get_sha256());
+ $this->assertRegExp('/[a-zA-Z0-9]{64}/', static::$record_1->get_sha256());
+ $this->assertNull(self::$story_1->get_sha256());
}
- }
- public function testGet_status_icons()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- public function testGet_type()
- {
- $this->assertTrue(in_array(static::$record_1->get_type(), array('video', 'audio', 'image', 'document', 'flash', 'unknown')));
- }
-
- public function testGet_formated_duration()
- {
- $this->assertTrue(strpos(self::$record_23->get_formated_duration(), '00:17') === 0);
- $this->assertEquals('', self::$record_1->get_formated_duration());
- }
-
- public function testGet_duration()
- {
- $this->assertEquals(17, round(self::$record_23->get_duration()));
- $this->assertEquals(false, self::$record_1->get_duration());
- }
-
- public function testGet_rollover_thumbnail()
- {
- $this->assertInstanceOf('media_subdef', self::$record_23->get_rollover_thumbnail());
- $this->assertNull(self::$record_1->get_rollover_thumbnail());
- }
-
- public function testGenerate_subdefs()
- {
-
- }
-
- public function testGet_sha256()
- {
- $this->assertNotNull(static::$record_1->get_sha256());
- $this->assertRegExp('/[a-zA-Z0-9]{64}/', static::$record_1->get_sha256());
- $this->assertNull(self::$story_1->get_sha256());
- }
-
- public function testGet_mime()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $found = $coll = false;
- foreach ($appbox->get_databoxes() as $databox)
+ public function testGet_mime()
{
- foreach ($databox->get_collections() as $collection)
- {
- $found = true;
- $coll = $collection;
- break;
- }
- if ($found)
- break;
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $found = $coll = false;
+ foreach ($appbox->get_databoxes() as $databox) {
+ foreach ($databox->get_collections() as $collection) {
+ $found = true;
+ $coll = $collection;
+ break;
+ }
+ if ($found)
+ break;
+ }
+ if ( ! ($coll instanceof collection))
+ $this->fail('Unable to find a collection');
+
+ $record = record_adapter::create($coll, new system_file(__DIR__ . '/../testfiles/cestlafete.jpg'));
+
+ $this->assertEquals('image/jpeg', $record->get_mime());
+ $record->delete();
}
- if (!($coll instanceof collection))
- $this->fail('Unable to find a collection');
- $record = record_adapter::create($coll, new system_file(__DIR__ . '/../testfiles/cestlafete.jpg'));
-
- $this->assertEquals('image/jpeg', $record->get_mime());
- $record->delete();
- }
-
- public function testGet_status()
- {
- $this->assertRegExp('/[01]{64}/', static::$record_1->get_status());
- }
-
- public function testGet_subdef()
- {
- $this->assertInstanceOf('media_subdef', self::$record_1->get_subdef('document'));
- $this->assertInstanceOf('media_subdef', self::$record_1->get_subdef('preview'));
- $this->assertInstanceOf('media_subdef', self::$record_1->get_subdef('thumbnail'));
- $this->assertInstanceOf('media_subdef', self::$record_23->get_subdef('document'));
- $this->assertInstanceOf('media_subdef', self::$record_23->get_subdef('preview'));
- $this->assertInstanceOf('media_subdef', self::$record_23->get_subdef('thumbnail'));
- $this->assertInstanceOf('media_subdef', self::$record_23->get_subdef('thumbnailGIF'));
- }
-
- public function testGet_subdefs()
- {
- $subdefs = static::$record_1->get_subdefs();
- $this->assertTrue(is_array($subdefs));
- foreach ($subdefs as $subdef)
+ public function testGet_status()
{
- $this->assertInstanceOf('media_subdef', $subdef);
+ $this->assertRegExp('/[01]{64}/', static::$record_1->get_status());
}
- }
- /**
- * @todo Implement testGet_collection_logo().
- */
- public function testGet_collection_logo()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- public function testGet_technical_infos()
- {
- $this->assertTrue(is_array(static::$record_1->get_technical_infos()));
- }
-
- public function testGet_caption()
- {
- $this->assertTrue((static::$record_1->get_caption() instanceof caption_record));
- }
-
- public function testGet_original_name()
- {
- $this->assertTrue(static::$record_1->get_original_name() === self::$record_sf_1->getFilename());
- }
-
- public function testGet_title()
- {
- $this->assertEquals(static::$record_sf_1->getFilename(), static::$record_1->get_title());
- $this->assertEquals(static::$record_sf_23->getFilename(), static::$record_23->get_title());
- }
-
- public function testGet_preview()
- {
- $this->assertTrue((static::$record_1->get_preview() instanceof media_subdef));
- }
-
- public function testHas_preview()
- {
- $this->assertTrue(self::$record_1->has_preview());
- }
-
- public function testGet_serialize_key()
- {
- $this->assertTrue(static::$record_1->get_serialize_key() == static::$record_1->get_sbas_id() . '_' . static::$record_1->get_record_id());
- }
-
- public function testGet_sbas_id()
- {
- $this->assertTrue(is_int(static::$record_1->get_sbas_id()));
- }
-
- public function testSubstitute_subdef()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- public function testSet_metadatas()
- {
-
- $meta_structure_el = self::$collection->get_databox()->get_meta_structure()->get_elements();
-
- $current_caption = self::$record_1->get_caption();
-
- $metadatas = array();
-
- foreach ($meta_structure_el as $meta_el)
+ public function testGet_subdef()
{
- $current_fields = $current_caption->get_fields(array($meta_el->get_name()));
+ $this->assertInstanceOf('media_subdef', self::$record_1->get_subdef('document'));
+ $this->assertInstanceOf('media_subdef', self::$record_1->get_subdef('preview'));
+ $this->assertInstanceOf('media_subdef', self::$record_1->get_subdef('thumbnail'));
+ $this->assertInstanceOf('media_subdef', self::$record_23->get_subdef('document'));
+ $this->assertInstanceOf('media_subdef', self::$record_23->get_subdef('preview'));
+ $this->assertInstanceOf('media_subdef', self::$record_23->get_subdef('thumbnail'));
+ $this->assertInstanceOf('media_subdef', self::$record_23->get_subdef('thumbnailGIF'));
+ }
- $field = null;
+ public function testGet_subdefs()
+ {
+ $subdefs = static::$record_1->get_subdefs();
+ $this->assertTrue(is_array($subdefs));
+ foreach ($subdefs as $subdef) {
+ $this->assertInstanceOf('media_subdef', $subdef);
+ }
+ }
- if (count($current_fields) > 0)
- {
- $field = array_pop($current_fields);
- }
+ /**
+ * @todo Implement testGet_collection_logo().
+ */
+ public function testGet_collection_logo()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
- if($meta_el->is_multi())
- {
- if($field)
- {
- foreach($field->get_values() as $value)
- {
- $metadatas[] = array(
- 'meta_struct_id' => $meta_el->get_id()
- , 'meta_id' => $value->getId()
- , 'value' => ''
- );
- }
+ public function testGet_technical_infos()
+ {
+ $this->assertTrue(is_array(static::$record_1->get_technical_infos()));
+ }
+
+ public function testGet_caption()
+ {
+ $this->assertTrue((static::$record_1->get_caption() instanceof caption_record));
+ }
+
+ public function testGet_original_name()
+ {
+ $this->assertTrue(static::$record_1->get_original_name() === self::$record_sf_1->getFilename());
+ }
+
+ public function testGet_title()
+ {
+ $this->assertEquals(static::$record_sf_1->getFilename(), static::$record_1->get_title());
+ $this->assertEquals(static::$record_sf_23->getFilename(), static::$record_23->get_title());
+ }
+
+ public function testGet_preview()
+ {
+ $this->assertTrue((static::$record_1->get_preview() instanceof media_subdef));
+ }
+
+ public function testHas_preview()
+ {
+ $this->assertTrue(self::$record_1->has_preview());
+ }
+
+ public function testGet_serialize_key()
+ {
+ $this->assertTrue(static::$record_1->get_serialize_key() == static::$record_1->get_sbas_id() . '_' . static::$record_1->get_record_id());
+ }
+
+ public function testGet_sbas_id()
+ {
+ $this->assertTrue(is_int(static::$record_1->get_sbas_id()));
+ }
+
+ public function testSubstitute_subdef()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ public function testSet_metadatas()
+ {
+
+ $meta_structure_el = self::$collection->get_databox()->get_meta_structure()->get_elements();
+
+ $current_caption = self::$record_1->get_caption();
+
+ $metadatas = array();
+
+ foreach ($meta_structure_el as $meta_el) {
+ $current_fields = $current_caption->get_fields(array($meta_el->get_name()));
+
+ $field = null;
+
+ if (count($current_fields) > 0) {
+ $field = array_pop($current_fields);
+ }
+
+ if ($meta_el->is_multi()) {
+ if ($field) {
+ foreach ($field->get_values() as $value) {
+ $metadatas[] = array(
+ 'meta_struct_id' => $meta_el->get_id()
+ , 'meta_id' => $value->getId()
+ , 'value' => ''
+ );
+ }
+ }
+
+ $metadatas[] = array(
+ 'meta_struct_id' => $meta_el->get_id()
+ , 'meta_id' => null
+ , 'value' => 'un'
+ );
+ $metadatas[] = array(
+ 'meta_struct_id' => $meta_el->get_id()
+ , 'meta_id' => null
+ , 'value' => 'jeu'
+ );
+ $metadatas[] = array(
+ 'meta_struct_id' => $meta_el->get_id()
+ , 'meta_id' => null
+ , 'value' => 'de'
+ );
+ $metadatas[] = array(
+ 'meta_struct_id' => $meta_el->get_id()
+ , 'meta_id' => null
+ , 'value' => 'test'
+ );
+ } else {
+ $meta_id = null;
+
+ if ($field) {
+ $meta_id = array_pop($field->get_values())->getId();
+ }
+
+ $metadatas[] = array(
+ 'meta_struct_id' => $meta_el->get_id()
+ , 'meta_id' => $meta_id
+ , 'value' => 'un premier jeu de test'
+ );
+
+ $metadatas[] = array(
+ 'meta_struct_id' => $meta_el->get_id()
+ , 'meta_id' => $meta_id
+ , 'value' => 'un second jeu de test'
+ );
+ }
}
- $metadatas[] = array(
- 'meta_struct_id' => $meta_el->get_id()
- , 'meta_id' => null
- , 'value' => 'un'
- );
- $metadatas[] = array(
- 'meta_struct_id' => $meta_el->get_id()
- , 'meta_id' => null
- , 'value' => 'jeu'
- );
- $metadatas[] = array(
- 'meta_struct_id' => $meta_el->get_id()
- , 'meta_id' => null
- , 'value' => 'de'
- );
- $metadatas[] = array(
- 'meta_struct_id' => $meta_el->get_id()
- , 'meta_id' => null
- , 'value' => 'test'
- );
- }
- else
- {
- $meta_id = null;
+ self::$record_1->set_metadatas($metadatas, true);
- if($field)
- {
- $meta_id = array_pop($field->get_values())->getId();
+ $caption = self::$record_1->get_caption();
+
+
+
+ foreach ($meta_structure_el as $meta_el) {
+ $current_fields = $caption->get_fields(array($meta_el->get_name()));
+
+ $this->assertEquals(1, count($current_fields));
+ $field = $current_fields[0];
+
+ $separator = $meta_el->get_separator();
+
+ if (strlen($separator) > 0) {
+ $separator = $separator[0];
+ } else {
+ $separator = '';
+ }
+
+ $multi_imploded = implode(' ' . $separator . ' ', array('un', 'jeu', 'de', 'test'));
+
+ if ($meta_el->is_multi()) {
+ $initial_values = array();
+ foreach ($field->get_values() as $value) {
+ $initial_values[] = $value->getValue();
+ }
+
+ $this->assertEquals($multi_imploded, implode(' ' . $meta_el->get_separator() . ' ', $initial_values));
+ $this->assertEquals($multi_imploded, $field->get_serialized_values());
+ }
+ else
+ $this->assertEquals('un second jeu de test', $field->get_serialized_values());
}
-
- $metadatas[] = array(
- 'meta_struct_id' => $meta_el->get_id()
- , 'meta_id' => $meta_id
- , 'value' => 'un premier jeu de test'
- );
-
- $metadatas[] = array(
- 'meta_struct_id' => $meta_el->get_id()
- , 'meta_id' => $meta_id
- , 'value' => 'un second jeu de test'
- );
- }
}
- self::$record_1->set_metadatas($metadatas, true);
-
- $caption = self::$record_1->get_caption();
-
-
-
- foreach ($meta_structure_el as $meta_el)
+ public function testReindex()
{
- $current_fields = $caption->get_fields(array($meta_el->get_name()));
-
- $this->assertEquals(1, count($current_fields));
- $field = $current_fields[0];
-
- $separator = $meta_el->get_separator();
-
- if(strlen($separator) > 0)
- {
- $separator = $separator[0];
- }
- else
- {
- $separator = '';
- }
-
- $multi_imploded = implode(' ' . $separator . ' ', array('un', 'jeu', 'de', 'test'));
-
- if ($meta_el->is_multi())
- {
- $initial_values = array();
- foreach($field->get_values() as $value)
- {
- $initial_values[] = $value->getValue();
- }
-
- $this->assertEquals($multi_imploded, implode(' ' . $meta_el->get_separator() . ' ', $initial_values));
- $this->assertEquals($multi_imploded, $field->get_serialized_values());
- }
- else
- $this->assertEquals('un second jeu de test', $field->get_serialized_values());
- }
- }
-
- public function testReindex()
- {
- self::$record_1->reindex();
- $sql = 'SELECT record_id FROM record
+ self::$record_1->reindex();
+ $sql = 'SELECT record_id FROM record
WHERE (status & 7) IN (4,5,6) AND record_id = :record_id';
- $stmt = self::$record_1->get_databox()->get_connection()->prepare($sql);
+ $stmt = self::$record_1->get_databox()->get_connection()->prepare($sql);
- $stmt->execute(array(':record_id' => self::$record_1->get_record_id()));
- $row = $stmt->fetch(PDO::FETCH_ASSOC);
- $stmt->closeCursor();
+ $stmt->execute(array(':record_id' => self::$record_1->get_record_id()));
+ $row = $stmt->fetch(PDO::FETCH_ASSOC);
+ $stmt->closeCursor();
- if (!$row)
- $this->fail();
- if ($row['record_id'] != self::$record_1->get_record_id())
- $this->fail();
- }
+ if ( ! $row)
+ $this->fail();
+ if ($row['record_id'] != self::$record_1->get_record_id())
+ $this->fail();
+ }
- public function testRebuild_subdefs()
- {
+ public function testRebuild_subdefs()
+ {
- self::$record_1->rebuild_subdefs();
- $sql = 'SELECT record_id
+ self::$record_1->rebuild_subdefs();
+ $sql = 'SELECT record_id
FROM record
WHERE jeton & ' . JETON_MAKE_SUBDEF . ' > 0
AND record_id = :record_id';
- $stmt = self::$record_1->get_databox()->get_connection()->prepare($sql);
+ $stmt = self::$record_1->get_databox()->get_connection()->prepare($sql);
- $stmt->execute(array(':record_id' => self::$record_1->get_record_id()));
- $row = $stmt->fetch(PDO::FETCH_ASSOC);
- $stmt->closeCursor();
+ $stmt->execute(array(':record_id' => self::$record_1->get_record_id()));
+ $row = $stmt->fetch(PDO::FETCH_ASSOC);
+ $stmt->closeCursor();
- if (!$row)
- $this->fail();
- if ($row['record_id'] != self::$record_1->get_record_id())
- $this->fail();
- }
+ if ( ! $row)
+ $this->fail();
+ if ($row['record_id'] != self::$record_1->get_record_id())
+ $this->fail();
+ }
- public function testWrite_metas()
- {
- self::$record_1->write_metas();
- $sql = 'SELECT record_id, coll_id, jeton
+ public function testWrite_metas()
+ {
+ self::$record_1->write_metas();
+ $sql = 'SELECT record_id, coll_id, jeton
FROM record WHERE (jeton & ' . JETON_WRITE_META . ' > 0)
AND record_id = :record_id';
- $stmt = self::$record_1->get_databox()->get_connection()->prepare($sql);
+ $stmt = self::$record_1->get_databox()->get_connection()->prepare($sql);
- $stmt->execute(array(':record_id' => self::$record_1->get_record_id()));
- $row = $stmt->fetch(PDO::FETCH_ASSOC);
- $stmt->closeCursor();
+ $stmt->execute(array(':record_id' => self::$record_1->get_record_id()));
+ $row = $stmt->fetch(PDO::FETCH_ASSOC);
+ $stmt->closeCursor();
- if (!$row)
- $this->fail();
- if ($row['record_id'] != self::$record_1->get_record_id())
- $this->fail();
- }
-
- /**
- * @todo Implement testSet_binary_status().
- */
- public function testSet_binary_status()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- public function testGet_record_by_sha()
- {
- $tmp_records = record_adapter::get_record_by_sha(self::$record_1->get_sbas_id(), self::$record_1->get_sha256());
- $this->assertTrue(is_array($tmp_records));
-
- foreach ($tmp_records as $tmp_record)
- {
- $this->assertInstanceOf('record_adapter', $tmp_record);
- $this->assertEquals(self::$record_1->get_sha256(), $tmp_record->get_sha256());
+ if ( ! $row)
+ $this->fail();
+ if ($row['record_id'] != self::$record_1->get_record_id())
+ $this->fail();
}
- $tmp_records = record_adapter::get_record_by_sha(self::$record_1->get_sbas_id(), self::$record_1->get_sha256(), self::$record_1->get_record_id());
- $this->assertTrue(is_array($tmp_records));
- $this->assertTrue(count($tmp_records) === 1);
-
- foreach ($tmp_records as $tmp_record)
+ /**
+ * @todo Implement testSet_binary_status().
+ */
+ public function testSet_binary_status()
{
- $this->assertInstanceOf('record_adapter', $tmp_record);
- $this->assertEquals(self::$record_1->get_sha256(), $tmp_record->get_sha256());
- $this->assertEquals(self::$record_1->get_record_id(), $tmp_record->get_record_id());
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
}
- }
- public function testGet_hd_file()
- {
- $this->assertInstanceOf('system_file', self::$record_1->get_hd_file());
- }
-
- /**
- * @todo Implement testLog_view().
- */
- public function testLog_view()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- public function testRotate_subdefs()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet_container_baskets().
- */
- public function testGet_container_baskets()
- {
- $em = self::$core->getEntityManager();
-
- $basket = $this->insertOneBasket();
- $this->assertInstanceOf('\Entities\Basket', $basket);
-
- /* @var $basket \Entities\Basket */
- $basket_element = new \Entities\BasketElement();
- $basket_element->setRecord(self::$record_1);
- $basket_element->setBasket($basket);
-
- $em->persist($basket_element);
-
- $basket->addBasketElement($basket_element);
- $basket = $em->merge($basket);
-
- $em->flush();
-
- $found = $sselcont_id = false;
-
- $sbas_id = self::$record_1->get_sbas_id();
- $record_id = self::$record_1->get_record_id();
-
- foreach (self::$record_1->get_container_baskets() as $c_basket)
+ public function testGet_record_by_sha()
{
- if ($c_basket->getId() == $basket->getId())
- {
- $found = true;
- foreach ($c_basket->getElements() as $b_el)
- {
- if ($b_el->getRecord()->get_record_id() == $record_id && $b_el->getRecord()->get_sbas_id() == $sbas_id)
- $sselcont_id = $b_el->getId();
+ $tmp_records = record_adapter::get_record_by_sha(self::$record_1->get_sbas_id(), self::$record_1->get_sha256());
+ $this->assertTrue(is_array($tmp_records));
+
+ foreach ($tmp_records as $tmp_record) {
+ $this->assertInstanceOf('record_adapter', $tmp_record);
+ $this->assertEquals(self::$record_1->get_sha256(), $tmp_record->get_sha256());
+ }
+
+ $tmp_records = record_adapter::get_record_by_sha(self::$record_1->get_sbas_id(), self::$record_1->get_sha256(), self::$record_1->get_record_id());
+ $this->assertTrue(is_array($tmp_records));
+ $this->assertTrue(count($tmp_records) === 1);
+
+ foreach ($tmp_records as $tmp_record) {
+ $this->assertInstanceOf('record_adapter', $tmp_record);
+ $this->assertEquals(self::$record_1->get_sha256(), $tmp_record->get_sha256());
+ $this->assertEquals(self::$record_1->get_record_id(), $tmp_record->get_record_id());
}
- }
}
+ public function testGet_hd_file()
+ {
+ $this->assertInstanceOf('system_file', self::$record_1->get_hd_file());
+ }
- if (!$found)
- $this->fail();
- }
+ /**
+ * @todo Implement testLog_view().
+ */
+ public function testLog_view()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+ public function testRotate_subdefs()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ public function testGet_container_baskets()
+ {
+ $em = self::$core->getEntityManager();
+
+ $basket = $this->insertOneBasket();
+ $this->assertInstanceOf('\Entities\Basket', $basket);
+
+ /* @var $basket \Entities\Basket */
+ $basket_element = new \Entities\BasketElement();
+ $basket_element->setRecord(self::$record_1);
+ $basket_element->setBasket($basket);
+
+ $em->persist($basket_element);
+
+ $basket->addBasketElement($basket_element);
+ $basket = $em->merge($basket);
+
+ $em->flush();
+
+ $found = $sselcont_id = false;
+
+ $sbas_id = self::$record_1->get_sbas_id();
+ $record_id = self::$record_1->get_record_id();
+
+ foreach (self::$record_1->get_container_baskets() as $c_basket) {
+ if ($c_basket->getId() == $basket->getId()) {
+ $found = true;
+ foreach ($c_basket->getElements() as $b_el) {
+ if ($b_el->getRecord()->get_record_id() == $record_id && $b_el->getRecord()->get_sbas_id() == $sbas_id)
+ $sselcont_id = $b_el->getId();
+ }
+ }
+ }
+
+
+ if ( ! $found)
+ $this->fail();
+ }
}
-
diff --git a/tests/recordutilsTest.php b/tests/recordutilsTest.php
deleted file mode 100644
index 59fb06049c..0000000000
--- a/tests/recordutilsTest.php
+++ /dev/null
@@ -1,63 +0,0 @@
-markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testWatermark().
- */
- public function testWatermark()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testStamp().
- */
- public function testStamp()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testEmbed_preview().
- */
- public function testEmbed_preview()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testBinary_datas().
- */
- public function testBinary_datas()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
-}
diff --git a/tests/registryTest.php b/tests/registryTest.php
index 5788b7c0f8..342e38100b 100644
--- a/tests/registryTest.php
+++ b/tests/registryTest.php
@@ -185,4 +185,3 @@ class registryTest extends PhraseanetPHPUnitAbstract
$this->assertFalse($this->object->is_set('key_test'));
}
}
-
diff --git a/tests/registry_setupTest.php b/tests/registry_setupTest.php
deleted file mode 100644
index 44b6660763..0000000000
--- a/tests/registry_setupTest.php
+++ /dev/null
@@ -1,64 +0,0 @@
-markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testGet().
- */
- public function testGet()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testSet().
- */
- public function testSet()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testIs_set().
- */
- public function testIs_set()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testUn_set().
- */
- public function testUn_set()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
-}
-
diff --git a/tests/report/activityTest.php b/tests/report/activityTest.php
index 38f56c0d6e..07906d49e8 100644
--- a/tests/report/activityTest.php
+++ b/tests/report/activityTest.php
@@ -1,200 +1,179 @@
dmax = $date->format("Y-m-d H:i:s");
- $date->modify('-6 month');
- $this->dmin = $date->format("Y-m-d H:i:s");
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $databoxes = $appbox->get_databoxes();
- $this->ret = array();
- foreach ($databoxes as $databox)
+ /**
+ *
+ * @var module_report_activity
+ */
+ protected $report;
+
+ public function setUp()
{
- $colls = $databox->get_collections();
- $rett = array();
- foreach ($colls as $coll)
- {
- $rett[$coll->get_coll_id()] = $coll->get_coll_id();
- }
- $this->ret[$databox->get_sbas_id()] = implode(',', $rett);
+ parent::setUp();
+ $date = new Datetime();
+ $this->dmax = $date->format("Y-m-d H:i:s");
+ $date->modify('-6 month');
+ $this->dmin = $date->format("Y-m-d H:i:s");
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $databoxes = $appbox->get_databoxes();
+ $this->ret = array();
+ foreach ($databoxes as $databox) {
+ $colls = $databox->get_collections();
+ $rett = array();
+ foreach ($colls as $coll) {
+ $rett[$coll->get_coll_id()] = $coll->get_coll_id();
+ }
+ $this->ret[$databox->get_sbas_id()] = implode(',', $rett);
+ }
}
- }
- public function testBuildReport()
- {
- $conf = array(
- 'user' => array("", 1, 0, 1, 1),
- 'date' => array("", 1, 0, 1, 1),
- 'record_id' => array("", 1, 1, 1, 1),
- 'file' => array("", 1, 0, 1, 1),
- 'mime' => array("", 1, 0, 1, 1),
- 'size' => array("", 1, 0, 1, 1)
- );
-
- foreach ($this->ret as $sbasid => $colllist)
+ public function testBuildReport()
{
- $report = new module_report_activity(
- $this->dmin,
- $this->dmax,
- $sbasid,
- $colllist
- );
- $report->setUser_id(self::$user->get_id());
- $this->activerPerHours($report);
- $this->ConnexionBase($report);
- $this->activiteAddedDocument($report, $sbasid, $colllist);
- $this->activiteAddedTopTenUser($report, $sbasid, $colllist);
- $this->activiteEditedDocument($report, $sbasid, $colllist);
- $this->activiteTopTenSiteView($report, $sbasid, $colllist);
- $this->activity($report, $sbasid, $colllist);
- $this->activityDay($report, $sbasid, $colllist);
- $this->activityQuestion($report, $sbasid, $colllist);
- $this->allDownloadByUserBase($report);
- $this->allQuestion($report);
- $this->detailDownload($report);
- $this->downloadByBaseByDay($report);
- $this->otherTest($report);
- $this->push($report);
- $this->topQuestion($report);
- $this->topTenUser($report, $sbasid, $colllist);
+ $conf = array(
+ 'user' => array("", 1, 0, 1, 1),
+ 'date' => array("", 1, 0, 1, 1),
+ 'record_id' => array("", 1, 1, 1, 1),
+ 'file' => array("", 1, 0, 1, 1),
+ 'mime' => array("", 1, 0, 1, 1),
+ 'size' => array("", 1, 0, 1, 1)
+ );
+
+ foreach ($this->ret as $sbasid => $colllist) {
+ $report = new module_report_activity(
+ $this->dmin,
+ $this->dmax,
+ $sbasid,
+ $colllist
+ );
+ $report->setUser_id(self::$user->get_id());
+ $this->activerPerHours($report);
+ $this->ConnexionBase($report);
+ $this->activiteAddedDocument($report, $sbasid, $colllist);
+ $this->activiteAddedTopTenUser($report, $sbasid, $colllist);
+ $this->activiteEditedDocument($report, $sbasid, $colllist);
+ $this->activiteTopTenSiteView($report, $sbasid, $colllist);
+ $this->activity($report, $sbasid, $colllist);
+ $this->activityDay($report, $sbasid, $colllist);
+ $this->activityQuestion($report, $sbasid, $colllist);
+ $this->allDownloadByUserBase($report);
+ $this->allQuestion($report);
+ $this->detailDownload($report);
+ $this->downloadByBaseByDay($report);
+ $this->otherTest($report);
+ $this->push($report);
+ $this->topQuestion($report);
+ $this->topTenUser($report, $sbasid, $colllist);
+ }
}
- }
+ public function otherTest($report)
+ {
+ $report->setTop(15);
+ $this->assertEquals(15, $report->getTop());
+ }
- public function otherTest($report)
- {
- $report->setTop(15);
- $this->assertEquals(15, $report->getTop());
- }
+ public function activerPerHours($report)
+ {
+ $activityHours = $report->getActivityPerHours();
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $activityHours);
+ }
- public function activerPerHours($report)
- {
- $activityHours = $report->getActivityPerHours();
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $activityHours);
- }
+ public function allQuestion($report)
+ {
+ $allQuestion = $report->getAllQuestionByUser(self::$user->get_id(), 'usrid');
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $allQuestion);
+ }
- public function allQuestion($report)
- {
- $allQuestion = $report->getAllQuestionByUser(self::$user->get_id(), 'usrid');
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $allQuestion);
- }
+ public function topQuestion($report)
+ {
+ $topQuestion = $report->getTopQuestion();
+ $topQuestion2 = $report->getTopQuestion(false, true);
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $topQuestion);
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $topQuestion2);
+ }
+ public function allDownloadByUserBase($report)
+ {
+ $allDownload = $report->getAllDownloadByUserBase(self::$user->get_id());
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $allDownload);
+ }
- public function topQuestion($report)
- {
- $topQuestion = $report->getTopQuestion();
- $topQuestion2 = $report->getTopQuestion(false, true);
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $topQuestion);
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $topQuestion2);
- }
+ public function downloadByBaseByDay($report)
+ {
+ $dlBaseDay = $report->getDownloadByBaseByDay();
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $dlBaseDay);
+ }
- public function allDownloadByUserBase($report)
- {
- $allDownload = $report->getAllDownloadByUserBase(self::$user->get_id());
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $allDownload);
- }
+ public function ConnexionBase($report)
+ {
+ $connexionBase = $report->getConnexionBase();
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $connexionBase);
+ }
- public function downloadByBaseByDay($report)
- {
- $dlBaseDay = $report->getDownloadByBaseByDay();
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $dlBaseDay);
- }
+ public function detailDownload($report)
+ {
+ $detailDl = $report->getDetailDownload();
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $detailDl);
+ }
- public function ConnexionBase($report)
- {
- $connexionBase = $report->getConnexionBase();
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $connexionBase);
- }
+ public function push($report)
+ {
+ $push = $report->getPush();
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $push);
+ }
- public function detailDownload($report)
- {
- $detailDl = $report->getDetailDownload();
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $detailDl);
- }
+ public function topTenUser($report, $sbasid, $colllist)
+ {
+ $result = $report->topTenUser($this->dmin, $this->dmax, $sbasid, $colllist);
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $result);
+ }
- public function push($report)
- {
- $push = $report->getPush();
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $push);
- }
+ public function activity($report, $sbasid, $colllist)
+ {
+ $result = $report->activity($this->dmin, $this->dmax, $sbasid, $colllist);
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $result);
+ }
- public function topTenUser($report, $sbasid, $colllist)
- {
- $result = $report->topTenUser($this->dmin, $this->dmax, $sbasid, $colllist);
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $result);
- }
+ public function activityDay($report, $sbasid, $colllist)
+ {
+ $result = $report->activityDay($this->dmin, $this->dmax, $sbasid, $colllist);
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $result);
+ }
- public function activity($report, $sbasid, $colllist)
- {
- $result = $report->activity($this->dmin, $this->dmax, $sbasid, $colllist);
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $result);
- }
+ public function activityQuestion($report, $sbasid, $colllist)
+ {
+ $result = $report->activityQuestion($this->dmin, $this->dmax, $sbasid, $colllist);
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $result);
+ }
- public function activityDay($report, $sbasid, $colllist)
- {
- $result = $report->activityDay($this->dmin, $this->dmax, $sbasid, $colllist);
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $result);
- }
+ public function activiteTopTenSiteView($report, $sbasid, $colllist)
+ {
+ $result = $report->activiteTopTenSiteView($this->dmin, $this->dmax, $sbasid, $colllist);
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $result);
+ }
- public function activityQuestion($report, $sbasid, $colllist)
- {
- $result = $report->activityQuestion($this->dmin, $this->dmax, $sbasid, $colllist);
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $result);
- }
-
- public function activiteTopTenSiteView($report, $sbasid, $colllist)
- {
- $result = $report->activiteTopTenSiteView($this->dmin, $this->dmax, $sbasid, $colllist);
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $result);
- }
-
- public function activiteAddedDocument($report, $sbasid, $colllist)
- {
- $result = $report->activiteAddedDocument($this->dmin, $this->dmax, $sbasid, $colllist);
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $result);
- }
-
- public function activiteEditedDocument($report, $sbasid, $colllist)
- {
- $result = $report->activiteEditedDocument($this->dmin, $this->dmax, $sbasid, $colllist);
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $result);
- }
-
- public function activiteAddedTopTenUser($report, $sbasid, $colllist)
- {
- $result = $report->activiteAddedTopTenUser($this->dmin, $this->dmax, $sbasid, $colllist);
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $result);
- }
+ public function activiteAddedDocument($report, $sbasid, $colllist)
+ {
+ $result = $report->activiteAddedDocument($this->dmin, $this->dmax, $sbasid, $colllist);
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $result);
+ }
+ public function activiteEditedDocument($report, $sbasid, $colllist)
+ {
+ $result = $report->activiteEditedDocument($this->dmin, $this->dmax, $sbasid, $colllist);
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $result);
+ }
+ public function activiteAddedTopTenUser($report, $sbasid, $colllist)
+ {
+ $result = $report->activiteAddedTopTenUser($this->dmin, $this->dmax, $sbasid, $colllist);
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $result);
+ }
}
diff --git a/tests/report/addTest.php b/tests/report/addTest.php
index 6e7e671b74..8524096786 100644
--- a/tests/report/addTest.php
+++ b/tests/report/addTest.php
@@ -1,185 +1,170 @@
dmax = $date->format("Y-m-d H:i:s");
- $date->modify('-6 month');
- $this->dmin = $date->format("Y-m-d H:i:s");
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $databoxes = $appbox->get_databoxes();
- $this->ret = array();
- foreach ($databoxes as $databox)
+ public function setUp()
{
- $colls = $databox->get_collections();
- $rett = array();
- foreach ($colls as $coll)
- {
- $rett[$coll->get_coll_id()] = $coll->get_coll_id();
- }
- $this->ret[$databox->get_sbas_id()] = implode(',', $rett);
- }
- }
-
- public function ColFilter()
- {
- $ret = $this->report->colFilter('user');
-
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $ret);
- foreach ($ret as $result)
- {
- $this->assertArrayHasKey('val', $result);
- $this->assertArrayHasKey('value', $result);
- }
- }
-
- public function testBuildReport()
- {
- $conf = array(
- 'user' => array("", 1, 0, 1, 1),
- 'date' => array("", 1, 0, 1, 1),
- 'record_id' => array("", 1, 1, 1, 1),
- 'file' => array("", 1, 0, 1, 1),
- 'mime' => array("", 1, 0, 1, 1),
- 'size' => array("", 1, 0, 1, 1)
- );
-
- foreach ($this->ret as $sbasid => $collections)
- {
- $this->report = new module_report_add(
- $this->dmin,
- $this->dmax,
- $sbasid,
- $collections
- );
-
- $result = $this->report->buildReport($conf);
-
- $this->reporttestPage($result);
- if (count($result['result']) > 0)$this->reporttestConf($conf);
- if (count($result['result']) > 0) $this->reporttestResult($result, $conf);
-
- $this->ColFilter();
- }
-
-
- foreach ($this->ret as $sbasid => $collections)
- {
- $this->report = new module_report_add(
- $this->dmin,
- $this->dmax,
- $sbasid,
- $collections
- );
-
- $this->ColFilter();
-
- $result = $this->report->buildReport(false, 'user');
- $this->reporttestPage($result);
- if (count($result['result']) > 0) $this->reporttestConf($conf, 'user');
- if (count($result['result']) > 0) $this->reporttestResult($result, $conf, 'user');
- }
- }
-
- public function reporttestPage($report)
- {
- $this->assertLessThanOrEqual($this->report->getNbRecord(), count($report['result']));
-
- $nbPage = $this->report->getTotal() / $this->report->getNbRecord();
-
- if ($this->report->getTotal() > $this->report->getNbRecord()) $this->assertTrue($report['display_nav']);
- else $this->assertFalse($report['display_nav']);
-
- if ($report['page'] == 1) $this->assertFalse($report['previous_page']);
- else $this->assertEquals($report['page'] - 1, $report['previous_page']);
-
-
- if (intval(ceil($nbPage)) == $report['page'] || intval(ceil($nbPage)) == 0) $this->assertFalse($report['next_page']);
- else $this->assertEquals($report['page'] + 1, $report['next_page']);
- }
-
- public function reporttestConf($conf, $groupby = false)
- {
- if ($groupby) $this->assertEquals(count($this->report->getDisplay()), 2);
- else $this->assertEquals(count($this->report->getDisplay()), count($conf));
-
- if (!$groupby)
- {
- foreach ($this->report->getDisplay() as $col => $colconf)
- {
- $this->assertArrayHaskey($col, $conf);
- $this->assertTrue(is_array($colconf));
- $this->assertArrayHasKey('title', $colconf);
- $this->assertArrayHasKey('sort', $colconf);
- $this->assertArrayHasKey('bound', $colconf);
- $this->assertArrayHasKey('filter', $colconf);
- $this->assertArrayHasKey('groupby', $colconf);
- $i = 0;
- foreach ($colconf as $key => $value)
- {
- if ($i == 1) $this->assertEquals($conf[$col][$i], $value);
- elseif ($i == 2) $this->assertEquals($conf[$col][$i], $value);
- elseif ($i == 3) $this->assertEquals($conf[$col][$i], $value);
- elseif ($i == 4) $this->assertEquals($conf[$col][$i], $value);
- $i++;
+ parent::setUp();
+ $date = new Datetime();
+ $this->dmax = $date->format("Y-m-d H:i:s");
+ $date->modify('-6 month');
+ $this->dmin = $date->format("Y-m-d H:i:s");
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $databoxes = $appbox->get_databoxes();
+ $this->ret = array();
+ foreach ($databoxes as $databox) {
+ $colls = $databox->get_collections();
+ $rett = array();
+ foreach ($colls as $coll) {
+ $rett[$coll->get_coll_id()] = $coll->get_coll_id();
+ }
+ $this->ret[$databox->get_sbas_id()] = implode(',', $rett);
}
- }
}
- else
- {
- $this->assertArrayHasKey($groupby, $this->report->getDisplay());
- $this->assertArrayHasKey('nombre', $this->report->getDisplay());
- }
- }
- public function reporttestResult($report, $conf, $groupby = false)
- {
- if (!$groupby)
+ public function ColFilter()
{
- foreach ($report['result'] as $row)
- {
- foreach ($conf as $key => $value)
- {
+ $ret = $this->report->colFilter('user');
- $this->assertArrayHasKey($key, $row);
- $condition = is_string($row[$key]) || is_int($row[$key]);
- $this->assertTrue($condition);
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $ret);
+ foreach ($ret as $result) {
+ $this->assertArrayHasKey('val', $result);
+ $this->assertArrayHasKey('value', $result);
}
- }
}
- else
- {
- foreach ($report['result'] as $row)
- {
- $this->assertArrayHasKey($groupby, $row);
- $this->assertArrayHasKey('nombre', $row);
- }
- }
- }
+ public function testBuildReport()
+ {
+ $conf = array(
+ 'user' => array("", 1, 0, 1, 1),
+ 'date' => array("", 1, 0, 1, 1),
+ 'record_id' => array("", 1, 1, 1, 1),
+ 'file' => array("", 1, 0, 1, 1),
+ 'mime' => array("", 1, 0, 1, 1),
+ 'size' => array("", 1, 0, 1, 1)
+ );
+
+ foreach ($this->ret as $sbasid => $collections) {
+ $this->report = new module_report_add(
+ $this->dmin,
+ $this->dmax,
+ $sbasid,
+ $collections
+ );
+
+ $result = $this->report->buildReport($conf);
+
+ $this->reporttestPage($result);
+ if (count($result['result']) > 0)
+ $this->reporttestConf($conf);
+ if (count($result['result']) > 0)
+ $this->reporttestResult($result, $conf);
+
+ $this->ColFilter();
+ }
+
+
+ foreach ($this->ret as $sbasid => $collections) {
+ $this->report = new module_report_add(
+ $this->dmin,
+ $this->dmax,
+ $sbasid,
+ $collections
+ );
+
+ $this->ColFilter();
+
+ $result = $this->report->buildReport(false, 'user');
+ $this->reporttestPage($result);
+ if (count($result['result']) > 0)
+ $this->reporttestConf($conf, 'user');
+ if (count($result['result']) > 0)
+ $this->reporttestResult($result, $conf, 'user');
+ }
+ }
+
+ public function reporttestPage($report)
+ {
+ $this->assertLessThanOrEqual($this->report->getNbRecord(), count($report['result']));
+
+ $nbPage = $this->report->getTotal() / $this->report->getNbRecord();
+
+ if ($this->report->getTotal() > $this->report->getNbRecord())
+ $this->assertTrue($report['display_nav']);
+ else
+ $this->assertFalse($report['display_nav']);
+
+ if ($report['page'] == 1)
+ $this->assertFalse($report['previous_page']);
+ else
+ $this->assertEquals($report['page'] - 1, $report['previous_page']);
+
+
+ if (intval(ceil($nbPage)) == $report['page'] || intval(ceil($nbPage)) == 0)
+ $this->assertFalse($report['next_page']);
+ else
+ $this->assertEquals($report['page'] + 1, $report['next_page']);
+ }
+
+ public function reporttestConf($conf, $groupby = false)
+ {
+ if ($groupby)
+ $this->assertEquals(count($this->report->getDisplay()), 2);
+ else
+ $this->assertEquals(count($this->report->getDisplay()), count($conf));
+
+ if ( ! $groupby) {
+ foreach ($this->report->getDisplay() as $col => $colconf) {
+ $this->assertArrayHaskey($col, $conf);
+ $this->assertTrue(is_array($colconf));
+ $this->assertArrayHasKey('title', $colconf);
+ $this->assertArrayHasKey('sort', $colconf);
+ $this->assertArrayHasKey('bound', $colconf);
+ $this->assertArrayHasKey('filter', $colconf);
+ $this->assertArrayHasKey('groupby', $colconf);
+ $i = 0;
+ foreach ($colconf as $key => $value) {
+ if ($i == 1)
+ $this->assertEquals($conf[$col][$i], $value);
+ elseif ($i == 2)
+ $this->assertEquals($conf[$col][$i], $value);
+ elseif ($i == 3)
+ $this->assertEquals($conf[$col][$i], $value);
+ elseif ($i == 4)
+ $this->assertEquals($conf[$col][$i], $value);
+ $i ++;
+ }
+ }
+ }
+ else {
+ $this->assertArrayHasKey($groupby, $this->report->getDisplay());
+ $this->assertArrayHasKey('nombre', $this->report->getDisplay());
+ }
+ }
+
+ public function reporttestResult($report, $conf, $groupby = false)
+ {
+ if ( ! $groupby) {
+ foreach ($report['result'] as $row) {
+ foreach ($conf as $key => $value) {
+
+ $this->assertArrayHasKey($key, $row);
+ $condition = is_string($row[$key]) || is_int($row[$key]);
+ $this->assertTrue($condition);
+ }
+ }
+ } else {
+ foreach ($report['result'] as $row) {
+ $this->assertArrayHasKey($groupby, $row);
+ $this->assertArrayHasKey('nombre', $row);
+ }
+ }
+ }
}
diff --git a/tests/report/connexionReportTest.php b/tests/report/connexionReportTest.php
index b593082c8b..da79e90781 100644
--- a/tests/report/connexionReportTest.php
+++ b/tests/report/connexionReportTest.php
@@ -1,215 +1,187 @@
dmax = $date->format("Y-m-d H:i:s");
- $date->modify('-6 month');
- $this->dmin = $date->format("Y-m-d H:i:s");
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $databoxes = $appbox->get_databoxes();
- $this->ret = array();
- foreach ($databoxes as $databox)
+ public function setUp()
{
- $colls = $databox->get_collections();
- $rett = array();
- foreach ($colls as $coll)
- {
- $rett[$coll->get_coll_id()] = $coll->get_coll_id();
- }
- $this->ret[$databox->get_sbas_id()] = implode(',', $rett);
- }
- }
-
- public function ColFilter()
- {
- $ret = $this->report->colFilter('user');
-
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY,
- $ret);
- foreach ($ret as $result)
- {
- $this->assertArrayHasKey('val', $result);
- $this->assertArrayHasKey('value', $result);
- }
- }
-
- public function testBuildReport()
- {
- $conf = array(
- 'user' => array(_('phraseanet::utilisateurs'), 1, 1, 1, 1),
- 'ddate' => array(_('report:: date'), 1, 0, 1, 1),
- 'ip' => array(_('report:: IP'), 1, 0, 0, 0),
- 'appli' => array(_('report:: modules'), 1, 0, 0, 0),
- 'fonction' => array(_('report::fonction'), 1, 1, 1, 1),
- 'activite' => array(_('report::activite'), 1, 1, 1, 1),
- 'pays' => array(_('report::pays'), 1, 1, 1, 1),
- 'societe' => array(_('report::societe'), 1, 1, 1, 1)
- );
-
- $nbResult = 0;
- foreach ($this->ret as $sbasid => $collections)
- {
- $this->report = new module_report_connexion(
- $this->dmin,
- $this->dmax,
- $sbasid,
- $collections
- );
- $this->ColFilter();
- $result = $this->report->buildReport($conf);
-
- if(count($result)>$nbResult)
- $this->save_report = $this->report;
-
- $nbResult = count($result);
- $this->reporttestPage($result);
- if (count($result['result']) > 0) $this->reporttestConf($conf);
- if (count($result['result']) > 0) $this->reporttestResult($result, $conf);
- }
-
- foreach ($this->ret as $sbasid => $collections)
- {
- $this->report = new module_report_connexion(
- $this->dmin,
- $this->dmax,
- $sbasid,
- $collections
- );
-
- $this->ColFilter();
-
- $result = $this->report->buildReport(false, 'user');
- $this->reporttestPage($result);
- if (count($result['result']) > 0) $this->reporttestConf($conf, 'user');
- if (count($result['result']) > 0) $this->reporttestResult($result, $conf, 'user');
-
- }
-
- $result = $this->save_report->buildReport(false, 'user');
- }
-
-
- public function reporttestPage($report)
- {
- $this->assertLessThanOrEqual($this->report->getNbRecord(), count($report['result']));
-
- $nbPage = $this->report->getTotal() / $this->report->getNbRecord();
-
- if ($this->report->getTotal() > $this->report->getNbRecord())
- $this->assertTrue($report['display_nav']);
- else $this->assertFalse($report['display_nav']);
-
- if ($report['page'] == 1) $this->assertFalse($report['previous_page']);
- else $this->assertEquals($report['page'] - 1, $report['previous_page']);
-
- if (intval(ceil($nbPage)) == $report['page'])
- $this->assertFalse($report['next_page']);
- else $this->assertEquals($report['page'] + 1, $report['next_page']);
- }
-
- public function reporttestConf($conf, $groupby = false)
- {
- if($groupby)
- $this->assertEquals(count($this->report->getDisplay()), 2);
- else
- $this->assertEquals(count($this->report->getDisplay()), count($conf));
-
- if(!$groupby)
- {
- foreach($this->report->getDisplay() as $col => $colconf)
- {
- $this->assertArrayHaskey($col, $conf);
- $this->assertTrue(is_array($colconf));
- $this->assertArrayHasKey('title', $colconf);
- $this->assertArrayHasKey('sort', $colconf);
- $this->assertArrayHasKey('bound', $colconf);
- $this->assertArrayHasKey('filter', $colconf);
- $this->assertArrayHasKey('groupby', $colconf);
- $i = 0;
- foreach($colconf as $key => $value)
- {
- if($i == 1)
- $this->assertEquals($conf[$col][$i], $value);
- elseif($i == 2)
- $this->assertEquals($conf[$col][$i], $value);
- elseif($i == 3)
- $this->assertEquals($conf[$col][$i], $value);
- elseif($i == 4)
- $this->assertEquals($conf[$col][$i], $value);
- $i++;
- }
- }
- }
- else
- {
- $this->assertArrayHasKey($groupby, $this->report->getDisplay());
- $this->assertArrayHasKey('nb', $this->report->getDisplay());
- }
- }
-
- public function reporttestResult($report, $conf, $groupby = false)
- {
- if(!$groupby)
- {
- foreach ($report['result'] as $row)
- {
- foreach ($conf as $key => $value)
- {
-
- $this->assertArrayHasKey($key, $row);
- $condition = is_string($row[$key]) || is_int($row[$key]);
- $this->assertTrue($condition);
+ parent::setUp();
+ $date = new Datetime();
+ $this->dmax = $date->format("Y-m-d H:i:s");
+ $date->modify('-6 month');
+ $this->dmin = $date->format("Y-m-d H:i:s");
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $databoxes = $appbox->get_databoxes();
+ $this->ret = array();
+ foreach ($databoxes as $databox) {
+ $colls = $databox->get_collections();
+ $rett = array();
+ foreach ($colls as $coll) {
+ $rett[$coll->get_coll_id()] = $coll->get_coll_id();
+ }
+ $this->ret[$databox->get_sbas_id()] = implode(',', $rett);
}
- }
}
- else
- {
- foreach ($report['result'] as $row)
- {
- $this->assertArrayHasKey($groupby, $row);
- $this->assertArrayHasKey('nb', $row);
- }
- }
- }
- public function reporttestResultWithChamp($report, $conf)
- {
- foreach ($report['result'] as $row)
+ public function ColFilter()
{
- foreach ($conf as $key => $value)
- {
- $this->assertArrayHasKey($value, $row);
- $condition = is_string($row[$value]);
- $this->assertTrue($condition);
- }
- }
- }
+ $ret = $this->report->colFilter('user');
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $ret);
+ foreach ($ret as $result) {
+ $this->assertArrayHasKey('val', $result);
+ $this->assertArrayHasKey('value', $result);
+ }
+ }
+
+ public function testBuildReport()
+ {
+ $conf = array(
+ 'user' => array(_('phraseanet::utilisateurs'), 1, 1, 1, 1),
+ 'ddate' => array(_('report:: date'), 1, 0, 1, 1),
+ 'ip' => array(_('report:: IP'), 1, 0, 0, 0),
+ 'appli' => array(_('report:: modules'), 1, 0, 0, 0),
+ 'fonction' => array(_('report::fonction'), 1, 1, 1, 1),
+ 'activite' => array(_('report::activite'), 1, 1, 1, 1),
+ 'pays' => array(_('report::pays'), 1, 1, 1, 1),
+ 'societe' => array(_('report::societe'), 1, 1, 1, 1)
+ );
+
+ $nbResult = 0;
+ foreach ($this->ret as $sbasid => $collections) {
+ $this->report = new module_report_connexion(
+ $this->dmin,
+ $this->dmax,
+ $sbasid,
+ $collections
+ );
+ $this->ColFilter();
+ $result = $this->report->buildReport($conf);
+
+ if (count($result) > $nbResult)
+ $this->save_report = $this->report;
+
+ $nbResult = count($result);
+ $this->reporttestPage($result);
+ if (count($result['result']) > 0)
+ $this->reporttestConf($conf);
+ if (count($result['result']) > 0)
+ $this->reporttestResult($result, $conf);
+ }
+
+ foreach ($this->ret as $sbasid => $collections) {
+ $this->report = new module_report_connexion(
+ $this->dmin,
+ $this->dmax,
+ $sbasid,
+ $collections
+ );
+
+ $this->ColFilter();
+
+ $result = $this->report->buildReport(false, 'user');
+ $this->reporttestPage($result);
+ if (count($result['result']) > 0)
+ $this->reporttestConf($conf, 'user');
+ if (count($result['result']) > 0)
+ $this->reporttestResult($result, $conf, 'user');
+ }
+
+ $result = $this->save_report->buildReport(false, 'user');
+ }
+
+ public function reporttestPage($report)
+ {
+ $this->assertLessThanOrEqual($this->report->getNbRecord(), count($report['result']));
+
+ $nbPage = $this->report->getTotal() / $this->report->getNbRecord();
+
+ if ($this->report->getTotal() > $this->report->getNbRecord())
+ $this->assertTrue($report['display_nav']);
+ else
+ $this->assertFalse($report['display_nav']);
+
+ if ($report['page'] == 1)
+ $this->assertFalse($report['previous_page']);
+ else
+ $this->assertEquals($report['page'] - 1, $report['previous_page']);
+
+ if (intval(ceil($nbPage)) == $report['page'])
+ $this->assertFalse($report['next_page']);
+ else
+ $this->assertEquals($report['page'] + 1, $report['next_page']);
+ }
+
+ public function reporttestConf($conf, $groupby = false)
+ {
+ if ($groupby)
+ $this->assertEquals(count($this->report->getDisplay()), 2);
+ else
+ $this->assertEquals(count($this->report->getDisplay()), count($conf));
+
+ if ( ! $groupby) {
+ foreach ($this->report->getDisplay() as $col => $colconf) {
+ $this->assertArrayHaskey($col, $conf);
+ $this->assertTrue(is_array($colconf));
+ $this->assertArrayHasKey('title', $colconf);
+ $this->assertArrayHasKey('sort', $colconf);
+ $this->assertArrayHasKey('bound', $colconf);
+ $this->assertArrayHasKey('filter', $colconf);
+ $this->assertArrayHasKey('groupby', $colconf);
+ $i = 0;
+ foreach ($colconf as $key => $value) {
+ if ($i == 1)
+ $this->assertEquals($conf[$col][$i], $value);
+ elseif ($i == 2)
+ $this->assertEquals($conf[$col][$i], $value);
+ elseif ($i == 3)
+ $this->assertEquals($conf[$col][$i], $value);
+ elseif ($i == 4)
+ $this->assertEquals($conf[$col][$i], $value);
+ $i ++;
+ }
+ }
+ }
+ else {
+ $this->assertArrayHasKey($groupby, $this->report->getDisplay());
+ $this->assertArrayHasKey('nb', $this->report->getDisplay());
+ }
+ }
+
+ public function reporttestResult($report, $conf, $groupby = false)
+ {
+ if ( ! $groupby) {
+ foreach ($report['result'] as $row) {
+ foreach ($conf as $key => $value) {
+
+ $this->assertArrayHasKey($key, $row);
+ $condition = is_string($row[$key]) || is_int($row[$key]);
+ $this->assertTrue($condition);
+ }
+ }
+ } else {
+ foreach ($report['result'] as $row) {
+ $this->assertArrayHasKey($groupby, $row);
+ $this->assertArrayHasKey('nb', $row);
+ }
+ }
+ }
+
+ public function reporttestResultWithChamp($report, $conf)
+ {
+ foreach ($report['result'] as $row) {
+ foreach ($conf as $key => $value) {
+ $this->assertArrayHasKey($value, $row);
+ $condition = is_string($row[$value]);
+ $this->assertTrue($condition);
+ }
+ }
+ }
}
diff --git a/tests/report/dashboardTest.php b/tests/report/dashboardTest.php
index b90949669b..dbf4516dc9 100644
--- a/tests/report/dashboardTest.php
+++ b/tests/report/dashboardTest.php
@@ -1,136 +1,106 @@
dashboard = new module_report_dashboard(self::$user);
- $this->dashboard->setDate('-2 month', 'now');
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $this->dashboard->legendDay);
- $this->assertNotNull($this->dashboard->dmin);
- $this->assertNotNull($this->dashboard->dmax);
- $this->assertGreaterThanOrEqual(1, count($this->dashboard->authorizedCollection));
- $this->assertEquals($this->dashboard->authorizedCollection, $this->dashboard->authorizedCollection());
-
-
- foreach ($this->dashboard->authorizedCollection as $coll)
+ public function setUp()
{
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $coll);
- $this->assertArrayHasKey('sbas_id', $coll);
- $this->assertArrayHasKey('coll', $coll);
- $this->assertArrayHasKey('name', $coll);
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_INT, $coll['sbas_id']);
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $coll['name']);
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $coll['coll']);
- }
- }
+ parent::setUp();
+ $this->dashboard = new module_report_dashboard(self::$user);
+ $this->dashboard->setDate('-2 month', 'now');
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $this->dashboard->legendDay);
+ $this->assertNotNull($this->dashboard->dmin);
+ $this->assertNotNull($this->dashboard->dmax);
+ $this->assertGreaterThanOrEqual(1, count($this->dashboard->authorizedCollection));
+ $this->assertEquals($this->dashboard->authorizedCollection, $this->dashboard->authorizedCollection());
- public function testValid()
- {
-// $this->assertFalse($this->dashboard->isValid());
-// $this->dashboard->execute();
-// $this->assertTrue($this->dashboard->isValid());
- }
- public function testExecute()
- {
- $this->dashboard->execute();
- $dashboard = $this->dashboard->getDash();
- $auth = $this->dashboard->authorizedCollection;
-
- $this->verify($dashboard);
- }
-
- public function verify($dashboard)
- {
- $date1 = new DateTime($this->dashboard->dmin);
- $date2 = new DateTime($this->dashboard->dmax);
- $interval = $date1->diff($date2);
- $nbDay = $interval->format("%a");
- $int = array('nb_dl', 'nb_conn');
- $top = array('top_ten_user_doc', 'top_ten_user_poiddoc', 'top_dl_document', 'top_ten_question', 'ask', 'top_ten_added');
- $activity = array('activity', 'activity_day', 'activity_added');
- foreach ($dashboard as $key => $dash)
- {
- if (count($dash) == 0)
- continue;
-
- if (in_array($key, $int))
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_INT, $dash);
- elseif (in_array($key, $top))
- {
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $dash);
- $this->assertLessThanOrEqual($this->dashboard->nbtop, count($dash));
- $lastvalue = null;
- foreach ($dash as $value)
- {
- if (is_null($lastvalue))
- $lastvalue = $value['nb'];
- $this->assertLessThanOrEqual($lastvalue, $value['nb']);
- $lastvalue = $value['nb'];
+ foreach ($this->dashboard->authorizedCollection as $coll) {
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $coll);
+ $this->assertArrayHasKey('sbas_id', $coll);
+ $this->assertArrayHasKey('coll', $coll);
+ $this->assertArrayHasKey('name', $coll);
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_INT, $coll['sbas_id']);
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $coll['name']);
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $coll['coll']);
}
- }
- elseif (in_array($key, $activity))
- {
- if ($key == 'activity')
- {
- $this->assertEquals(24, count($dash));
- }
- else
- {
- if ($key == 'activity_added')
- {
-
- }
- $this->assertLessThanOrEqual($nbDay, count($dash));
- }
- }
}
- }
- public function testGetTitleDate()
- {
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->dashboard->getTitleDate('dmax'));
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->dashboard->getTitleDate('dmin'));
- try
+ public function testValid()
{
- $this->dashboard->getTitleDate('none');
- $this->fail('must throw an axception right here');
+ $this->markTestIncomplete('');
}
- catch (Exception $e)
+
+ public function testExecute()
{
+ $this->dashboard->execute();
+ $dashboard = $this->dashboard->getDash();
+ $auth = $this->dashboard->authorizedCollection;
+ $this->verify($dashboard);
}
- }
- public function testGetListeBase()
- {
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->dashboard->getListeBase(' '));
- }
+ public function verify($dashboard)
+ {
+ $date1 = new DateTime($this->dashboard->dmin);
+ $date2 = new DateTime($this->dashboard->dmax);
+ $interval = $date1->diff($date2);
+ $nbDay = $interval->format("%a");
+ $int = array('nb_dl', 'nb_conn');
+ $top = array('top_ten_user_doc', 'top_ten_user_poiddoc', 'top_dl_document', 'top_ten_question', 'ask', 'top_ten_added');
+ $activity = array('activity', 'activity_day', 'activity_added');
+ foreach ($dashboard as $key => $dash) {
+ if (count($dash) == 0)
+ continue;
- public function testGroup()
- {
- $this->assertInstanceOf('module_report_dashboard_group', $this->dashboard->group());
- }
+ if (in_array($key, $int))
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_INT, $dash);
+ elseif (in_array($key, $top)) {
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $dash);
+ $this->assertLessThanOrEqual($this->dashboard->nbtop, count($dash));
+ $lastvalue = null;
+ foreach ($dash as $value) {
+ if (is_null($lastvalue))
+ $lastvalue = $value['nb'];
+ $this->assertLessThanOrEqual($lastvalue, $value['nb']);
+ $lastvalue = $value['nb'];
+ }
+ }
+ elseif (in_array($key, $activity)) {
+ if ($key == 'activity') {
+ $this->assertEquals(24, count($dash));
+ } else {
+ if ($key == 'activity_added') {
+ }
+ $this->assertLessThanOrEqual($nbDay, count($dash));
+ }
+ }
+ }
+ }
+
+ public function testGetTitleDate()
+ {
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->dashboard->getTitleDate('dmax'));
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->dashboard->getTitleDate('dmin'));
+ try {
+ $this->dashboard->getTitleDate('none');
+ $this->fail('must throw an axception right here');
+ } catch (Exception $e) {
+
+ }
+ }
+
+ public function testGetListeBase()
+ {
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->dashboard->getListeBase(' '));
+ }
+
+ public function testGroup()
+ {
+ $this->assertInstanceOf('module_report_dashboard_group', $this->dashboard->group());
+ }
}
diff --git a/tests/report/downloadReportTest.php b/tests/report/downloadReportTest.php
index 9bcde38551..2886d4a3cb 100644
--- a/tests/report/downloadReportTest.php
+++ b/tests/report/downloadReportTest.php
@@ -1,251 +1,217 @@
dmax = $date->format("Y-m-d H:i:s");
- $date->modify('-6 month');
- $this->dmin = $date->format("Y-m-d H:i:s");
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $databoxes = $appbox->get_databoxes();
- $this->ret = array();
- foreach ($databoxes as $databox)
+ public function setUp()
{
- $colls = $databox->get_collections();
- $rett = array();
- foreach ($colls as $coll)
- {
- $rett[$coll->get_coll_id()] = $coll->get_coll_id();
- }
- $this->ret[$databox->get_sbas_id()] = implode(',', $rett);
- }
- }
-
- public function ColFilter()
- {
- $ret = $this->report->colFilter('user');
- $this->manyCol($ret);
- $ret = $this->report->colFilter('ddate');
- $this->manyCol($ret);
- $ret = $this->report->colFilter('coll_id');
- $this->manyCol($ret);
- }
-
- public function manyCol($ret)
- {
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $ret);
- foreach ($ret as $result)
- {
- $this->assertArrayHasKey('val', $result);
- $this->assertArrayHasKey('value', $result);
- }
- }
-
- public function testBuildReport()
- {
- $conf = array(
- 'user' => array(_('report:: utilisateurs'), 1, 1, 1, 1),
- 'ddate' => array(_('report:: date'), 1, 0, 1, 1),
- 'record_id' => array(_('report:: record id'), 1, 1, 1, 1),
- 'final' => array(_('phrseanet:: sous definition'), 1, 0, 1, 1),
- 'coll_id' => array(_('report:: collections'), 1, 0, 1, 1),
- 'comment' => array(_('report:: commentaire'), 1, 0, 0, 0),
- 'fonction' => array(_('report:: fonction'), 1, 1, 1, 1),
- 'activite' => array(_('report:: activite'), 1, 1, 1, 1),
- 'pays' => array(_('report:: pays'), 1, 1, 1, 1),
- 'societe' => array(_('report:: societe'), 1, 1, 1, 1)
- );
-
- foreach ($this->ret as $sbasid => $collections)
- {
- $this->report = new module_report_download(
- $this->dmin,
- $this->dmax,
- $sbasid,
- $collections
- );
-
- $this->ColFilter();
- $result = $this->report->buildReport($conf);
-
- $this->reporttestPage($result);
- if (count($result['result']) > 0)
- $this->reporttestConf($conf);
- if (count($result['result']) > 0)
- $this->reporttestResult($result, $conf);
- }
-
- foreach ($this->ret as $sbasid => $collections)
- {
- $this->report = new module_report_download(
- $this->dmin,
- $this->dmax,
- $sbasid,
- $collections
- );
-
- $this->ColFilter();
-
- $result = $this->report->buildReport(false, 'fonction');
-
- $this->reporttestPage($result);
- if (count($result['result']) > 0)
- $this->reporttestConf($conf, 'fonction');
- if (count($result['result']) > 0)
- $this->reporttestResult($result, $conf, 'fonction');
- }
-
- foreach ($this->ret as $sbasid => $collections)
- {
- $this->report = new module_report_download(
- $this->dmin,
- $this->dmax,
- $sbasid,
- $collections
- );
-
- $this->ColFilter();
-
- $result = $this->report->buildReport(false, 'record_id', 'DOC');
- $this->reporttestPage($result);
- if (count($result['result']) > 0)
- $this->reporttestConf($conf, 'record_id');
- if (count($result['result']) > 0)
- $this->reporttestResult($result, $conf, 'record_id');
- }
-
- foreach ($this->ret as $sbasid => $collections)
- {
- $this->report = new module_report_download(
- $this->dmin,
- $this->dmax,
- $sbasid,
- $collections
- );
-
- $this->ColFilter();
-
- $result = $this->report->buildReport(false, 'user', 'DOC');
- $this->reporttestPage($result);
- if (count($result['result']) > 0)
- $this->reporttestConf($conf, 'user');
- if (count($result['result']) > 0)
- $this->reporttestResult($result, $conf, 'user');
- }
- }
-
- public function reporttestPage($report)
- {
- $this->assertLessThanOrEqual($this->report->getNbRecord(), count($report['result']));
-
- $nbPage = $this->report->getTotal() / $this->report->getNbRecord();
-
- if ($this->report->getTotal() > $this->report->getNbRecord())
- $this->assertTrue($report['display_nav']);
- else
- $this->assertFalse($report['display_nav']);
-
- if ($report['page'] == 1)
- $this->assertFalse($report['previous_page']);
- else
- $this->assertEquals($report['page'] - 1, $report['previous_page']);
-
- if (intval(ceil($nbPage)) == $report['page'] || intval(ceil($nbPage)) == 0)
- $this->assertFalse($report['next_page']);
- else
- $this->assertEquals($report['page'] + 1, $report['next_page']);
- }
-
- public function reporttestConf($conf, $groupby = false)
- {
- if ($groupby)
- {
- if ($groupby != 'record_id')
- $this->assertEquals(count($this->report->getDisplay()), 2);
- }
- else
- $this->assertEquals(count($this->report->getDisplay()), count($conf));
-
- if (!$groupby)
- {
- foreach ($this->report->getDisplay() as $col => $colconf)
- {
- $this->assertArrayHaskey($col, $conf);
- $this->assertTrue(is_array($colconf));
- $this->assertArrayHasKey('title', $colconf);
- $this->assertArrayHasKey('sort', $colconf);
- $this->assertArrayHasKey('bound', $colconf);
- $this->assertArrayHasKey('filter', $colconf);
- $this->assertArrayHasKey('groupby', $colconf);
- $i = 0;
- foreach ($colconf as $key => $value)
- {
- if ($i == 1)
- $this->assertEquals($conf[$col][$i], $value);
- elseif ($i == 2)
- $this->assertEquals($conf[$col][$i], $value);
- elseif ($i == 3)
- $this->assertEquals($conf[$col][$i], $value);
- elseif ($i == 4)
- $this->assertEquals($conf[$col][$i], $value);
- $i++;
+ parent::setUp();
+ $date = new Datetime();
+ $this->dmax = $date->format("Y-m-d H:i:s");
+ $date->modify('-6 month');
+ $this->dmin = $date->format("Y-m-d H:i:s");
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $databoxes = $appbox->get_databoxes();
+ $this->ret = array();
+ foreach ($databoxes as $databox) {
+ $colls = $databox->get_collections();
+ $rett = array();
+ foreach ($colls as $coll) {
+ $rett[$coll->get_coll_id()] = $coll->get_coll_id();
+ }
+ $this->ret[$databox->get_sbas_id()] = implode(',', $rett);
}
- }
}
- else
- {
- $this->assertArrayHasKey($groupby, $this->report->getDisplay());
+ public function ColFilter()
+ {
+ $ret = $this->report->colFilter('user');
+ $this->manyCol($ret);
+ $ret = $this->report->colFilter('ddate');
+ $this->manyCol($ret);
+ $ret = $this->report->colFilter('coll_id');
+ $this->manyCol($ret);
}
- }
- public function reporttestResult($report, $conf, $groupby = false)
- {
- if (!$groupby)
+ public function manyCol($ret)
{
- foreach ($report['result'] as $row)
- {
- foreach ($conf as $key => $value)
- {
-
- $this->assertArrayHasKey($key, $row);
- $condition = is_string($row[$key]) || is_int($row[$key]);
- $this->assertTrue($condition);
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $ret);
+ foreach ($ret as $result) {
+ $this->assertArrayHasKey('val', $result);
+ $this->assertArrayHasKey('value', $result);
}
- }
}
- else
- {
- foreach ($report['result'] as $row)
- {
- $this->assertArrayHasKey($groupby, $row);
- }
- }
- }
+ public function testBuildReport()
+ {
+ $conf = array(
+ 'user' => array(_('report:: utilisateurs'), 1, 1, 1, 1),
+ 'ddate' => array(_('report:: date'), 1, 0, 1, 1),
+ 'record_id' => array(_('report:: record id'), 1, 1, 1, 1),
+ 'final' => array(_('phrseanet:: sous definition'), 1, 0, 1, 1),
+ 'coll_id' => array(_('report:: collections'), 1, 0, 1, 1),
+ 'comment' => array(_('report:: commentaire'), 1, 0, 0, 0),
+ 'fonction' => array(_('report:: fonction'), 1, 1, 1, 1),
+ 'activite' => array(_('report:: activite'), 1, 1, 1, 1),
+ 'pays' => array(_('report:: pays'), 1, 1, 1, 1),
+ 'societe' => array(_('report:: societe'), 1, 1, 1, 1)
+ );
+
+ foreach ($this->ret as $sbasid => $collections) {
+ $this->report = new module_report_download(
+ $this->dmin,
+ $this->dmax,
+ $sbasid,
+ $collections
+ );
+
+ $this->ColFilter();
+ $result = $this->report->buildReport($conf);
+
+ $this->reporttestPage($result);
+ if (count($result['result']) > 0)
+ $this->reporttestConf($conf);
+ if (count($result['result']) > 0)
+ $this->reporttestResult($result, $conf);
+ }
+
+ foreach ($this->ret as $sbasid => $collections) {
+ $this->report = new module_report_download(
+ $this->dmin,
+ $this->dmax,
+ $sbasid,
+ $collections
+ );
+
+ $this->ColFilter();
+
+ $result = $this->report->buildReport(false, 'fonction');
+
+ $this->reporttestPage($result);
+ if (count($result['result']) > 0)
+ $this->reporttestConf($conf, 'fonction');
+ if (count($result['result']) > 0)
+ $this->reporttestResult($result, $conf, 'fonction');
+ }
+
+ foreach ($this->ret as $sbasid => $collections) {
+ $this->report = new module_report_download(
+ $this->dmin,
+ $this->dmax,
+ $sbasid,
+ $collections
+ );
+
+ $this->ColFilter();
+
+ $result = $this->report->buildReport(false, 'record_id', 'DOC');
+ $this->reporttestPage($result);
+ if (count($result['result']) > 0)
+ $this->reporttestConf($conf, 'record_id');
+ if (count($result['result']) > 0)
+ $this->reporttestResult($result, $conf, 'record_id');
+ }
+
+ foreach ($this->ret as $sbasid => $collections) {
+ $this->report = new module_report_download(
+ $this->dmin,
+ $this->dmax,
+ $sbasid,
+ $collections
+ );
+
+ $this->ColFilter();
+
+ $result = $this->report->buildReport(false, 'user', 'DOC');
+ $this->reporttestPage($result);
+ if (count($result['result']) > 0)
+ $this->reporttestConf($conf, 'user');
+ if (count($result['result']) > 0)
+ $this->reporttestResult($result, $conf, 'user');
+ }
+ }
+
+ public function reporttestPage($report)
+ {
+ $this->assertLessThanOrEqual($this->report->getNbRecord(), count($report['result']));
+
+ $nbPage = $this->report->getTotal() / $this->report->getNbRecord();
+
+ if ($this->report->getTotal() > $this->report->getNbRecord())
+ $this->assertTrue($report['display_nav']);
+ else
+ $this->assertFalse($report['display_nav']);
+
+ if ($report['page'] == 1)
+ $this->assertFalse($report['previous_page']);
+ else
+ $this->assertEquals($report['page'] - 1, $report['previous_page']);
+
+ if (intval(ceil($nbPage)) == $report['page'] || intval(ceil($nbPage)) == 0)
+ $this->assertFalse($report['next_page']);
+ else
+ $this->assertEquals($report['page'] + 1, $report['next_page']);
+ }
+
+ public function reporttestConf($conf, $groupby = false)
+ {
+ if ($groupby) {
+ if ($groupby != 'record_id')
+ $this->assertEquals(count($this->report->getDisplay()), 2);
+ }
+ else
+ $this->assertEquals(count($this->report->getDisplay()), count($conf));
+
+ if ( ! $groupby) {
+ foreach ($this->report->getDisplay() as $col => $colconf) {
+ $this->assertArrayHaskey($col, $conf);
+ $this->assertTrue(is_array($colconf));
+ $this->assertArrayHasKey('title', $colconf);
+ $this->assertArrayHasKey('sort', $colconf);
+ $this->assertArrayHasKey('bound', $colconf);
+ $this->assertArrayHasKey('filter', $colconf);
+ $this->assertArrayHasKey('groupby', $colconf);
+ $i = 0;
+ foreach ($colconf as $key => $value) {
+ if ($i == 1)
+ $this->assertEquals($conf[$col][$i], $value);
+ elseif ($i == 2)
+ $this->assertEquals($conf[$col][$i], $value);
+ elseif ($i == 3)
+ $this->assertEquals($conf[$col][$i], $value);
+ elseif ($i == 4)
+ $this->assertEquals($conf[$col][$i], $value);
+ $i ++;
+ }
+ }
+ }
+ else {
+
+ $this->assertArrayHasKey($groupby, $this->report->getDisplay());
+ }
+ }
+
+ public function reporttestResult($report, $conf, $groupby = false)
+ {
+ if ( ! $groupby) {
+ foreach ($report['result'] as $row) {
+ foreach ($conf as $key => $value) {
+
+ $this->assertArrayHasKey($key, $row);
+ $condition = is_string($row[$key]) || is_int($row[$key]);
+ $this->assertTrue($condition);
+ }
+ }
+ } else {
+ foreach ($report['result'] as $row) {
+ $this->assertArrayHasKey($groupby, $row);
+ }
+ }
+ }
}
diff --git a/tests/report/editTest.php b/tests/report/editTest.php
index fb0869b205..bc339d2c1a 100644
--- a/tests/report/editTest.php
+++ b/tests/report/editTest.php
@@ -1,196 +1,178 @@
dmax = $date->format("Y-m-d H:i:s");
- $date->modify('-6 month');
- $this->dmin = $date->format("Y-m-d H:i:s");
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $databoxes = $appbox->get_databoxes();
- $this->ret = array();
- foreach ($databoxes as $databox)
+ public function setUp()
{
- $colls = $databox->get_collections();
- $rett = array();
- foreach ($colls as $coll)
- {
- $rett[$coll->get_coll_id()] = $coll->get_coll_id();
- }
- $this->ret[$databox->get_sbas_id()] = implode(',', $rett);
- }
- }
-
-
- public function testBuildReport()
- {
- $conf = array(
- 'user' => array("", 1, 0, 1, 1),
- 'date' => array("", 1, 0, 1, 1),
- 'record_id' => array("", 1, 1, 1, 1),
- 'file' => array("", 1, 0, 1, 1),
- 'mime' => array("", 1, 0, 1, 1),
- 'size' => array("", 1, 0, 1, 1)
- );
-
- foreach ($this->ret as $sbasid => $collections)
- {
- $this->report = new module_report_edit(
- $this->dmin,
- $this->dmax,
- $sbasid,
- $collections
- );
-
- $result = $this->report->buildReport($conf);
-
- $this->reporttestPage($result);
- if (count($result['result']) > 0) $this->reporttestConf($conf);
- if (count($result['result']) > 0) $this->reporttestResult($result, $conf);
-
- $this->ColFilter();
- }
-
- foreach ($this->ret as $sbasid => $collections)
- {
- $this->report = new module_report_edit(
- $this->dmin,
- $this->dmax,
- $sbasid,
- $collections
- );
-
- $this->ColFilter();
-
- $result = $this->report->buildReport(false, 'user');
- $this->reporttestPage($result);
- if (count($result['result']) > 0) $this->reporttestConf($conf, 'user');
- if (count($result['result']) > 0) $this->reporttestResult($result, $conf, 'user');
- }
- }
-
- public function ColFilter()
- {
- $ret = $this->report->colFilter('user');
- $this->manyCol($ret);
- $ret = $this->report->colFilter('getter');
- $this->manyCol($ret);
- $ret = $this->report->colFilter('date');
- $this->manyCol($ret);
- $ret = $this->report->colFilter('size');
- $this->manyCol($ret);
-
- }
-
- public function manyCol($ret)
- {
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY,
- $ret);
- foreach ($ret as $result)
- {
- $this->assertArrayHasKey('val', $result);
- $this->assertArrayHasKey('value', $result);
- }
- }
-
- public function reporttestPage($report)
- {
- $this->assertLessThanOrEqual($this->report->getNbRecord(), count($report['result']));
-
- $nbPage = $this->report->getTotal() / $this->report->getNbRecord();
-
- if ($this->report->getTotal() > $this->report->getNbRecord()) $this->assertTrue($report['display_nav']);
- else $this->assertFalse($report['display_nav']);
-
- if ($report['page'] == 1) $this->assertFalse($report['previous_page']);
- else $this->assertEquals($report['page'] - 1, $report['previous_page']);
-
- if (intval(ceil($nbPage)) == $report['page'] || intval(ceil($nbPage)) == 0) $this->assertFalse($report['next_page']);
- else $this->assertEquals($report['page'] + 1, $report['next_page']);
- }
-
- public function reporttestConf($conf, $groupby = false)
- {
- if ($groupby) $this->assertEquals(count($this->report->getDisplay()), 2);
- else $this->assertEquals(count($this->report->getDisplay()), count($conf));
-
- if (!$groupby)
- {
- foreach ($this->report->getDisplay() as $col => $colconf)
- {
- $this->assertArrayHaskey($col, $conf);
- $this->assertTrue(is_array($colconf));
- $this->assertArrayHasKey('title', $colconf);
- $this->assertArrayHasKey('sort', $colconf);
- $this->assertArrayHasKey('bound', $colconf);
- $this->assertArrayHasKey('filter', $colconf);
- $this->assertArrayHasKey('groupby', $colconf);
- $i = 0;
- foreach ($colconf as $key => $value)
- {
- if ($i == 1) $this->assertEquals($conf[$col][$i], $value);
- elseif ($i == 2) $this->assertEquals($conf[$col][$i], $value);
- elseif ($i == 3) $this->assertEquals($conf[$col][$i], $value);
- elseif ($i == 4) $this->assertEquals($conf[$col][$i], $value);
- $i++;
+ parent::setUp();
+ $date = new Datetime();
+ $this->dmax = $date->format("Y-m-d H:i:s");
+ $date->modify('-6 month');
+ $this->dmin = $date->format("Y-m-d H:i:s");
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $databoxes = $appbox->get_databoxes();
+ $this->ret = array();
+ foreach ($databoxes as $databox) {
+ $colls = $databox->get_collections();
+ $rett = array();
+ foreach ($colls as $coll) {
+ $rett[$coll->get_coll_id()] = $coll->get_coll_id();
+ }
+ $this->ret[$databox->get_sbas_id()] = implode(',', $rett);
}
- }
}
- else
- {
- $this->assertArrayHasKey($groupby, $this->report->getDisplay());
- $this->assertArrayHasKey('nombre', $this->report->getDisplay());
- }
- }
- public function reporttestResult($report, $conf, $groupby = false)
- {
- if (!$groupby)
+ public function testBuildReport()
{
- foreach ($report['result'] as $row)
- {
- foreach ($conf as $key => $value)
- {
+ $conf = array(
+ 'user' => array("", 1, 0, 1, 1),
+ 'date' => array("", 1, 0, 1, 1),
+ 'record_id' => array("", 1, 1, 1, 1),
+ 'file' => array("", 1, 0, 1, 1),
+ 'mime' => array("", 1, 0, 1, 1),
+ 'size' => array("", 1, 0, 1, 1)
+ );
- $this->assertArrayHasKey($key, $row);
- $condition = is_string($row[$key]) || is_int($row[$key]);
- $this->assertTrue($condition);
+ foreach ($this->ret as $sbasid => $collections) {
+ $this->report = new module_report_edit(
+ $this->dmin,
+ $this->dmax,
+ $sbasid,
+ $collections
+ );
+
+ $result = $this->report->buildReport($conf);
+
+ $this->reporttestPage($result);
+ if (count($result['result']) > 0)
+ $this->reporttestConf($conf);
+ if (count($result['result']) > 0)
+ $this->reporttestResult($result, $conf);
+
+ $this->ColFilter();
}
- }
- }
- else
- {
- foreach ($report['result'] as $row)
- {
- $this->assertArrayHasKey($groupby, $row);
- $this->assertArrayHasKey('nombre', $row);
- }
- }
- }
+ foreach ($this->ret as $sbasid => $collections) {
+ $this->report = new module_report_edit(
+ $this->dmin,
+ $this->dmax,
+ $sbasid,
+ $collections
+ );
+
+ $this->ColFilter();
+
+ $result = $this->report->buildReport(false, 'user');
+ $this->reporttestPage($result);
+ if (count($result['result']) > 0)
+ $this->reporttestConf($conf, 'user');
+ if (count($result['result']) > 0)
+ $this->reporttestResult($result, $conf, 'user');
+ }
+ }
+
+ public function ColFilter()
+ {
+ $ret = $this->report->colFilter('user');
+ $this->manyCol($ret);
+ $ret = $this->report->colFilter('getter');
+ $this->manyCol($ret);
+ $ret = $this->report->colFilter('date');
+ $this->manyCol($ret);
+ $ret = $this->report->colFilter('size');
+ $this->manyCol($ret);
+ }
+
+ public function manyCol($ret)
+ {
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $ret);
+ foreach ($ret as $result) {
+ $this->assertArrayHasKey('val', $result);
+ $this->assertArrayHasKey('value', $result);
+ }
+ }
+
+ public function reporttestPage($report)
+ {
+ $this->assertLessThanOrEqual($this->report->getNbRecord(), count($report['result']));
+
+ $nbPage = $this->report->getTotal() / $this->report->getNbRecord();
+
+ if ($this->report->getTotal() > $this->report->getNbRecord())
+ $this->assertTrue($report['display_nav']);
+ else
+ $this->assertFalse($report['display_nav']);
+
+ if ($report['page'] == 1)
+ $this->assertFalse($report['previous_page']);
+ else
+ $this->assertEquals($report['page'] - 1, $report['previous_page']);
+
+ if (intval(ceil($nbPage)) == $report['page'] || intval(ceil($nbPage)) == 0)
+ $this->assertFalse($report['next_page']);
+ else
+ $this->assertEquals($report['page'] + 1, $report['next_page']);
+ }
+
+ public function reporttestConf($conf, $groupby = false)
+ {
+ if ($groupby)
+ $this->assertEquals(count($this->report->getDisplay()), 2);
+ else
+ $this->assertEquals(count($this->report->getDisplay()), count($conf));
+
+ if ( ! $groupby) {
+ foreach ($this->report->getDisplay() as $col => $colconf) {
+ $this->assertArrayHaskey($col, $conf);
+ $this->assertTrue(is_array($colconf));
+ $this->assertArrayHasKey('title', $colconf);
+ $this->assertArrayHasKey('sort', $colconf);
+ $this->assertArrayHasKey('bound', $colconf);
+ $this->assertArrayHasKey('filter', $colconf);
+ $this->assertArrayHasKey('groupby', $colconf);
+ $i = 0;
+ foreach ($colconf as $key => $value) {
+ if ($i == 1)
+ $this->assertEquals($conf[$col][$i], $value);
+ elseif ($i == 2)
+ $this->assertEquals($conf[$col][$i], $value);
+ elseif ($i == 3)
+ $this->assertEquals($conf[$col][$i], $value);
+ elseif ($i == 4)
+ $this->assertEquals($conf[$col][$i], $value);
+ $i ++;
+ }
+ }
+ }
+ else {
+ $this->assertArrayHasKey($groupby, $this->report->getDisplay());
+ $this->assertArrayHasKey('nombre', $this->report->getDisplay());
+ }
+ }
+
+ public function reporttestResult($report, $conf, $groupby = false)
+ {
+ if ( ! $groupby) {
+ foreach ($report['result'] as $row) {
+ foreach ($conf as $key => $value) {
+
+ $this->assertArrayHasKey($key, $row);
+ $condition = is_string($row[$key]) || is_int($row[$key]);
+ $this->assertTrue($condition);
+ }
+ }
+ } else {
+ foreach ($report['result'] as $row) {
+ $this->assertArrayHasKey($groupby, $row);
+ $this->assertArrayHasKey('nombre', $row);
+ }
+ }
+ }
}
diff --git a/tests/report/filterTest.php b/tests/report/filterTest.php
index 33da4b2c13..b2897ba7fe 100644
--- a/tests/report/filterTest.php
+++ b/tests/report/filterTest.php
@@ -1,113 +1,95 @@
dmax = $date->format("Y-m-d H:i:s");
- $date->modify('-6 month');
- $this->dmin = $date->format("Y-m-d H:i:s");
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $databoxes = $appbox->get_databoxes();
- $this->ret = array();
- foreach ($databoxes as $databox)
+ public function setUp()
{
- $colls = $databox->get_collections();
- $rett = array();
- foreach ($colls as $coll)
- {
- $rett[$coll->get_coll_id()] = $coll->get_coll_id();
- }
- $this->ret[$databox->get_sbas_id()] = implode(',', $rett);
+ parent::setUp();
+ $date = new Datetime();
+ $this->dmax = $date->format("Y-m-d H:i:s");
+ $date->modify('-6 month');
+ $this->dmin = $date->format("Y-m-d H:i:s");
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $databoxes = $appbox->get_databoxes();
+ $this->ret = array();
+ foreach ($databoxes as $databox) {
+ $colls = $databox->get_collections();
+ $rett = array();
+ foreach ($colls as $coll) {
+ $rett[$coll->get_coll_id()] = $coll->get_coll_id();
+ }
+ $this->ret[$databox->get_sbas_id()] = implode(',', $rett);
+ }
+ $this->initFilter();
}
- $this->initFilter();
- }
public function initFilter()
{
- $conf = array(
- 'user' => array(_('phraseanet::utilisateurs'), 1, 1, 1, 1),
- 'ddate' => array(_('report:: date'), 1, 0, 1, 1),
- 'ip' => array(_('report:: IP'), 1, 0, 0, 0),
- 'appli' => array(_('report:: modules'), 1, 0, 0, 0),
- 'fonction' => array(_('report::fonction'), 1, 1, 1, 1),
- 'activite' => array(_('report::activite'), 1, 1, 1, 1),
- 'pays' => array(_('report::pays'), 1, 1, 1, 1),
- 'societe' => array(_('report::societe'), 1, 1, 1, 1)
- );
-
- foreach ($this->ret as $sbasid => $collections)
- {
- $this->report = new module_report_connexion(
- $this->dmin,
- $this->dmax,
- $sbasid,
- $collections
+ $conf = array(
+ 'user' => array(_('phraseanet::utilisateurs'), 1, 1, 1, 1),
+ 'ddate' => array(_('report:: date'), 1, 0, 1, 1),
+ 'ip' => array(_('report:: IP'), 1, 0, 0, 0),
+ 'appli' => array(_('report:: modules'), 1, 0, 0, 0),
+ 'fonction' => array(_('report::fonction'), 1, 1, 1, 1),
+ 'activite' => array(_('report::activite'), 1, 1, 1, 1),
+ 'pays' => array(_('report::pays'), 1, 1, 1, 1),
+ 'societe' => array(_('report::societe'), 1, 1, 1, 1)
);
- break;
- }
+
+ foreach ($this->ret as $sbasid => $collections) {
+ $this->report = new module_report_connexion(
+ $this->dmin,
+ $this->dmax,
+ $sbasid,
+ $collections
+ );
+ break;
+ }
}
public function testFilter()
{
- $filter = new module_report_filter(array(), $this->report->getTransQueryString());
- $this->assertEquals(array(), $filter->getTabFilter());
- $filter->addFilter('x', 'LIKE', 'y');
- $filter->addFilter('x', 'LIKE', 'z');
- $filter->addFilter('1', '=', '1');
- $filter->addFilter('1', '=', '1');
- $tabfilter = $filter->getTabFilter();
- $this->assertEquals(2, count($tabfilter));
- $added_filter = $tabfilter[0];
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY,$added_filter);
- $this->assertArrayHasKey('f', $added_filter);
- $this->assertArrayHasKey('o', $added_filter);
- $this->assertArrayHasKey('v', $added_filter);
- $this->assertEquals('x', $added_filter['f']);
- $this->assertEquals('LIKE', $added_filter['o']);
- $this->assertEquals('y', $added_filter['v']);
- $active_column = $filter->getActiveColumn();
- $this->assertEquals('x', $active_column[0]);
+ $filter = new module_report_filter(array(), $this->report->getTransQueryString());
+ $this->assertEquals(array(), $filter->getTabFilter());
+ $filter->addFilter('x', 'LIKE', 'y');
+ $filter->addFilter('x', 'LIKE', 'z');
+ $filter->addFilter('1', '=', '1');
+ $filter->addFilter('1', '=', '1');
+ $tabfilter = $filter->getTabFilter();
+ $this->assertEquals(2, count($tabfilter));
+ $added_filter = $tabfilter[0];
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $added_filter);
+ $this->assertArrayHasKey('f', $added_filter);
+ $this->assertArrayHasKey('o', $added_filter);
+ $this->assertArrayHasKey('v', $added_filter);
+ $this->assertEquals('x', $added_filter['f']);
+ $this->assertEquals('LIKE', $added_filter['o']);
+ $this->assertEquals('y', $added_filter['v']);
+ $active_column = $filter->getActiveColumn();
+ $this->assertEquals('x', $active_column[0]);
- $tabfilter = $filter->getTabFilter();
- $this->assertEquals(2, count($tabfilter));
- $filter->addFilter('y', '=', 'z');
- $tabfilter = $filter->getTabFilter();
- $this->assertEquals(3, count($tabfilter));
- $filter->addFilter('user', '=', 'o');
- $tabfilter = $filter->getTabFilter();
- $this->assertEquals(4, count($tabfilter));
- $filter->addFilter('a', 'OR', '');
- $filter->addFilter('appli', '=', 'a:1:{i:0;i:1;}');
- $filter->addFilter('ddate', '=', 'o');
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $filter->getPostingFilter());
- $nbBefore = count($filter->getTabFilter());
- $filter->removeFilter('ddate');
- $nbAfter = count($filter->getTabFilter());
- $this->assertEquals($nbBefore - 1, $nbAfter);
+ $tabfilter = $filter->getTabFilter();
+ $this->assertEquals(2, count($tabfilter));
+ $filter->addFilter('y', '=', 'z');
+ $tabfilter = $filter->getTabFilter();
+ $this->assertEquals(3, count($tabfilter));
+ $filter->addFilter('user', '=', 'o');
+ $tabfilter = $filter->getTabFilter();
+ $this->assertEquals(4, count($tabfilter));
+ $filter->addFilter('a', 'OR', '');
+ $filter->addFilter('appli', '=', 'a:1:{i:0;i:1;}');
+ $filter->addFilter('ddate', '=', 'o');
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $filter->getPostingFilter());
+ $nbBefore = count($filter->getTabFilter());
+ $filter->removeFilter('ddate');
+ $nbAfter = count($filter->getTabFilter());
+ $this->assertEquals($nbBefore - 1, $nbAfter);
}
}
diff --git a/tests/report/pushTest.php b/tests/report/pushTest.php
index eec715b609..869dfc8296 100644
--- a/tests/report/pushTest.php
+++ b/tests/report/pushTest.php
@@ -1,185 +1,170 @@
dmax = $date->format("Y-m-d H:i:s");
- $date->modify('-6 month');
- $this->dmin = $date->format("Y-m-d H:i:s");
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $databoxes = $appbox->get_databoxes();
- $this->ret = array();
- foreach ($databoxes as $databox)
+ public function setUp()
{
- $colls = $databox->get_collections();
- $rett = array();
- foreach ($colls as $coll)
- {
- $rett[$coll->get_coll_id()] = $coll->get_coll_id();
- }
- $this->ret[$databox->get_sbas_id()] = implode(',', $rett);
- }
- }
-
- public function ColFilter()
- {
- $ret = $this->report->colFilter('user');
-
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $ret);
- foreach ($ret as $result)
- {
- $this->assertArrayHasKey('val', $result);
- $this->assertArrayHasKey('value', $result);
- }
- }
-
- public function testBuildReport()
- {
- $conf = array(
- 'user' => array("", 1, 0, 1, 1),
- 'getter' => array("Destinataire", 1, 0, 1, 1),
- 'date' => array("", 1, 0, 1, 1),
- 'record_id' => array("", 1, 1, 1, 1),
- 'file' => array("", 1, 0, 1, 1),
- 'mime' => array("", 1, 0, 1, 1),
- 'size' => array("", 1, 0, 1, 1)
- );
-
- foreach ($this->ret as $sbasid => $collections)
- {
- $this->report = new module_report_push(
- $this->dmin,
- $this->dmax,
- $sbasid,
- $collections
- );
-
- $result = $this->report->buildReport($conf);
-
- $this->reporttestPage($result);
- if (count($result['result']) > 0) $this->reporttestConf($conf);
- if (count($result['result']) > 0) $this->reporttestResult($result, $conf);
-
- $this->ColFilter();
- }
-
- foreach ($this->ret as $sbasid => $collections)
- {
- $this->report = new module_report_push(
- $this->dmin,
- $this->dmax,
- $sbasid,
- $collections
- );
-
- $this->ColFilter();
-
- $result = $this->report->buildReport(false, 'user');
-
- $this->reporttestPage($result);
- if (count($result['result']) > 0) $this->reporttestConf($conf, 'user');
- if (count($result['result']) > 0) $this->reporttestResult($result, $conf, 'user');
- }
- }
-
- public function reporttestPage($report)
- {
- $this->assertLessThanOrEqual($this->report->getNbRecord(), count($report['result']));
-
- $nbPage = $this->report->getTotal() / $this->report->getNbRecord();
-
- if ($this->report->getTotal() > $this->report->getNbRecord()) $this->assertTrue($report['display_nav']);
- else $this->assertFalse($report['display_nav']);
-
- if ($report['page'] == 1) $this->assertFalse($report['previous_page']);
- else $this->assertEquals($report['page'] - 1, $report['previous_page']);
-
- if (intval(ceil($nbPage)) == $report['page'] || intval(ceil($nbPage)) == 0) $this->assertFalse($report['next_page']);
- else $this->assertEquals($report['page'] + 1, $report['next_page']);
- }
-
- public function reporttestConf($conf, $groupby = false)
- {
- if ($groupby) $this->assertEquals(count($this->report->getDisplay()), 2);
- else $this->assertEquals(count($this->report->getDisplay()), count($conf));
-
- if (!$groupby)
- {
- foreach ($this->report->getDisplay() as $col => $colconf)
- {
- $this->assertArrayHaskey($col, $conf);
- $this->assertTrue(is_array($colconf));
- $this->assertArrayHasKey('title', $colconf);
- $this->assertArrayHasKey('sort', $colconf);
- $this->assertArrayHasKey('bound', $colconf);
- $this->assertArrayHasKey('filter', $colconf);
- $this->assertArrayHasKey('groupby', $colconf);
- $i = 0;
- foreach ($colconf as $key => $value)
- {
- if ($i == 1) $this->assertEquals($conf[$col][$i], $value);
- elseif ($i == 2) $this->assertEquals($conf[$col][$i], $value);
- elseif ($i == 3) $this->assertEquals($conf[$col][$i], $value);
- elseif ($i == 4) $this->assertEquals($conf[$col][$i], $value);
- $i++;
+ parent::setUp();
+ $date = new Datetime();
+ $this->dmax = $date->format("Y-m-d H:i:s");
+ $date->modify('-6 month');
+ $this->dmin = $date->format("Y-m-d H:i:s");
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $databoxes = $appbox->get_databoxes();
+ $this->ret = array();
+ foreach ($databoxes as $databox) {
+ $colls = $databox->get_collections();
+ $rett = array();
+ foreach ($colls as $coll) {
+ $rett[$coll->get_coll_id()] = $coll->get_coll_id();
+ }
+ $this->ret[$databox->get_sbas_id()] = implode(',', $rett);
}
- }
}
- else
- {
- $this->assertArrayHasKey($groupby, $this->report->getDisplay());
- $this->assertArrayHasKey('nombre', $this->report->getDisplay());
- }
- }
- public function reporttestResult($report, $conf, $groupby = false)
- {
- if (!$groupby)
+ public function ColFilter()
{
- foreach ($report['result'] as $row)
- {
- foreach ($conf as $key => $value)
- {
+ $ret = $this->report->colFilter('user');
- $this->assertArrayHasKey($key, $row);
- $condition = is_string($row[$key]) || is_int($row[$key]);
- $this->assertTrue($condition);
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $ret);
+ foreach ($ret as $result) {
+ $this->assertArrayHasKey('val', $result);
+ $this->assertArrayHasKey('value', $result);
}
- }
}
- else
- {
- foreach ($report['result'] as $row)
- {
- $this->assertArrayHasKey($groupby, $row);
- $this->assertArrayHasKey('nombre', $row);
- }
- }
- }
+ public function testBuildReport()
+ {
+ $conf = array(
+ 'user' => array("", 1, 0, 1, 1),
+ 'getter' => array("Destinataire", 1, 0, 1, 1),
+ 'date' => array("", 1, 0, 1, 1),
+ 'record_id' => array("", 1, 1, 1, 1),
+ 'file' => array("", 1, 0, 1, 1),
+ 'mime' => array("", 1, 0, 1, 1),
+ 'size' => array("", 1, 0, 1, 1)
+ );
+
+ foreach ($this->ret as $sbasid => $collections) {
+ $this->report = new module_report_push(
+ $this->dmin,
+ $this->dmax,
+ $sbasid,
+ $collections
+ );
+
+ $result = $this->report->buildReport($conf);
+
+ $this->reporttestPage($result);
+ if (count($result['result']) > 0)
+ $this->reporttestConf($conf);
+ if (count($result['result']) > 0)
+ $this->reporttestResult($result, $conf);
+
+ $this->ColFilter();
+ }
+
+ foreach ($this->ret as $sbasid => $collections) {
+ $this->report = new module_report_push(
+ $this->dmin,
+ $this->dmax,
+ $sbasid,
+ $collections
+ );
+
+ $this->ColFilter();
+
+ $result = $this->report->buildReport(false, 'user');
+
+ $this->reporttestPage($result);
+ if (count($result['result']) > 0)
+ $this->reporttestConf($conf, 'user');
+ if (count($result['result']) > 0)
+ $this->reporttestResult($result, $conf, 'user');
+ }
+ }
+
+ public function reporttestPage($report)
+ {
+ $this->assertLessThanOrEqual($this->report->getNbRecord(), count($report['result']));
+
+ $nbPage = $this->report->getTotal() / $this->report->getNbRecord();
+
+ if ($this->report->getTotal() > $this->report->getNbRecord())
+ $this->assertTrue($report['display_nav']);
+ else
+ $this->assertFalse($report['display_nav']);
+
+ if ($report['page'] == 1)
+ $this->assertFalse($report['previous_page']);
+ else
+ $this->assertEquals($report['page'] - 1, $report['previous_page']);
+
+ if (intval(ceil($nbPage)) == $report['page'] || intval(ceil($nbPage)) == 0)
+ $this->assertFalse($report['next_page']);
+ else
+ $this->assertEquals($report['page'] + 1, $report['next_page']);
+ }
+
+ public function reporttestConf($conf, $groupby = false)
+ {
+ if ($groupby)
+ $this->assertEquals(count($this->report->getDisplay()), 2);
+ else
+ $this->assertEquals(count($this->report->getDisplay()), count($conf));
+
+ if ( ! $groupby) {
+ foreach ($this->report->getDisplay() as $col => $colconf) {
+ $this->assertArrayHaskey($col, $conf);
+ $this->assertTrue(is_array($colconf));
+ $this->assertArrayHasKey('title', $colconf);
+ $this->assertArrayHasKey('sort', $colconf);
+ $this->assertArrayHasKey('bound', $colconf);
+ $this->assertArrayHasKey('filter', $colconf);
+ $this->assertArrayHasKey('groupby', $colconf);
+ $i = 0;
+ foreach ($colconf as $key => $value) {
+ if ($i == 1)
+ $this->assertEquals($conf[$col][$i], $value);
+ elseif ($i == 2)
+ $this->assertEquals($conf[$col][$i], $value);
+ elseif ($i == 3)
+ $this->assertEquals($conf[$col][$i], $value);
+ elseif ($i == 4)
+ $this->assertEquals($conf[$col][$i], $value);
+ $i ++;
+ }
+ }
+ }
+ else {
+ $this->assertArrayHasKey($groupby, $this->report->getDisplay());
+ $this->assertArrayHasKey('nombre', $this->report->getDisplay());
+ }
+ }
+
+ public function reporttestResult($report, $conf, $groupby = false)
+ {
+ if ( ! $groupby) {
+ foreach ($report['result'] as $row) {
+ foreach ($conf as $key => $value) {
+
+ $this->assertArrayHasKey($key, $row);
+ $condition = is_string($row[$key]) || is_int($row[$key]);
+ $this->assertTrue($condition);
+ }
+ }
+ } else {
+ foreach ($report['result'] as $row) {
+ $this->assertArrayHasKey($groupby, $row);
+ $this->assertArrayHasKey('nombre', $row);
+ }
+ }
+ }
}
diff --git a/tests/report/questionReportTest.php b/tests/report/questionReportTest.php
index e9e166af73..2dba17db34 100644
--- a/tests/report/questionReportTest.php
+++ b/tests/report/questionReportTest.php
@@ -1,205 +1,174 @@
dmax = $date->format("Y-m-d H:i:s");
- $date->modify('-6 month');
- $this->dmin = $date->format("Y-m-d H:i:s");
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $databoxes = $appbox->get_databoxes();
- $this->ret = array();
- foreach ($databoxes as $databox)
+ public function setUp()
{
- $colls = $databox->get_collections();
- $rett = array();
- foreach ($colls as $coll)
- {
- $rett[$coll->get_coll_id()] = $coll->get_coll_id();
- }
- $this->ret[$databox->get_sbas_id()] = implode(',', $rett);
- }
- }
-
- public function ColFilter()
- {
- $ret = $this->report->colFilter('user');
- $this->moreFilter($ret);
- $ret = $this->report->colFilter('ddate');
- $this->moreFilter($ret);
- }
-
- public function moreFilter($ret)
- {
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $ret);
- foreach ($ret as $result)
- {
- $this->assertArrayHasKey('val', $result);
- $this->assertArrayHasKey('value', $result);
- }
- }
-
- public function testBuildReport()
- {
- $conf = array(
- 'user' => array(_('report:: utilisateur'), 1, 1, 1, 1),
- 'search' => array(_('report:: question'), 1, 0, 1, 1),
- 'ddate' => array(_('report:: date'), 1, 0, 1, 1),
- 'fonction' => array(_('report:: fonction'), 1, 1, 1, 1),
- 'activite' => array(_('report:: activite'), 1, 1, 1, 1),
- 'pays' => array(_('report:: pays'), 1, 1, 1, 1),
- 'societe' => array(_('report:: societe'), 1, 1, 1, 1)
- );
-
- foreach ($this->ret as $sbasid => $collections)
- {
- $this->report = new module_report_question(
- $this->dmin,
- $this->dmax,
- $sbasid,
- $collections
- );
-
- $this->ColFilter();
-
- $result = $this->report->buildReport($conf);
- $this->reporttestPage($result);
- if (count($result['result']) > 0)
- $this->reporttestConf($conf);
- if (count($result['result']) > 0)
- $this->reporttestResult($result, $conf);
- }
-
- foreach ($this->ret as $sbasid => $collections)
- {
- $this->report = new module_report_question(
- $this->dmin,
- $this->dmax,
- $sbasid,
- $collections
- );
-
- $this->ColFilter();
-
- $result = $this->report->buildReport(false, 'user');
- $this->reporttestPage($result);
- if (count($result['result']) > 0)
- $this->reporttestConf($conf, 'user');
- if (count($result['result']) > 0)
- $this->reporttestResult($result, $conf, 'user');
- }
- }
-
- public function reporttestPage($report)
- {
- $this->assertLessThanOrEqual($this->report->getNbRecord(), count($report['result']));
-
- $nbPage = ceil($this->report->getTotal() / $this->report->getNbRecord());
-
- if ($this->report->getTotal() > $this->report->getNbRecord())
- $this->assertTrue($report['display_nav']);
- else
- $this->assertFalse($report['display_nav']);
-
- if ($report['page'] == 1)
- $this->assertFalse($report['previous_page']);
- else
- $this->assertEquals($report['page'] - 1, $report['previous_page']);
-
- if (intval($nbPage) > $report['page'])
- $this->assertEquals($report['page'] + 1, $report['next_page']);
- else
- $this->assertFalse($report['next_page']);
- }
-
- public function reporttestConf($conf, $groupby = false)
- {
- if ($groupby)
- $this->assertEquals(count($this->report->getDisplay()), 2);
- else
- $this->assertEquals(count($this->report->getDisplay()), count($conf));
-
- if (!$groupby)
- {
- foreach ($this->report->getDisplay() as $col => $colconf)
- {
- $this->assertArrayHaskey($col, $conf);
- $this->assertTrue(is_array($colconf));
- $this->assertArrayHasKey('title', $colconf);
- $this->assertArrayHasKey('sort', $colconf);
- $this->assertArrayHasKey('bound', $colconf);
- $this->assertArrayHasKey('filter', $colconf);
- $this->assertArrayHasKey('groupby', $colconf);
- $i = 0;
- foreach ($colconf as $key => $value)
- {
- if ($i == 1)
- $this->assertEquals($conf[$col][$i], $value);
- elseif ($i == 2)
- $this->assertEquals($conf[$col][$i], $value);
- elseif ($i == 3)
- $this->assertEquals($conf[$col][$i], $value);
- elseif ($i == 4)
- $this->assertEquals($conf[$col][$i], $value);
- $i++;
+ parent::setUp();
+ $date = new Datetime();
+ $this->dmax = $date->format("Y-m-d H:i:s");
+ $date->modify('-6 month');
+ $this->dmin = $date->format("Y-m-d H:i:s");
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $databoxes = $appbox->get_databoxes();
+ $this->ret = array();
+ foreach ($databoxes as $databox) {
+ $colls = $databox->get_collections();
+ $rett = array();
+ foreach ($colls as $coll) {
+ $rett[$coll->get_coll_id()] = $coll->get_coll_id();
+ }
+ $this->ret[$databox->get_sbas_id()] = implode(',', $rett);
}
- }
}
- else
+
+ public function ColFilter()
{
- $this->assertArrayHasKey($groupby, $this->report->getDisplay());
- $this->assertArrayHasKey('nb', $this->report->getDisplay());
+ $ret = $this->report->colFilter('user');
+ $this->moreFilter($ret);
+ $ret = $this->report->colFilter('ddate');
+ $this->moreFilter($ret);
}
- }
- public function reporttestResult($report, $conf, $groupby = false)
- {
- if (!$groupby)
+ public function moreFilter($ret)
{
- foreach ($report['result'] as $row)
- {
- foreach ($conf as $key => $value)
- {
-
- $this->assertArrayHasKey($key, $row);
- $condition = is_string($row[$key]) || is_int($row[$key]);
- $this->assertTrue($condition);
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $ret);
+ foreach ($ret as $result) {
+ $this->assertArrayHasKey('val', $result);
+ $this->assertArrayHasKey('value', $result);
}
- }
}
- else
- {
- foreach ($report['result'] as $row)
- {
- $this->assertArrayHasKey($groupby, $row);
- $this->assertArrayHasKey('nb', $row);
- }
- }
- }
+ public function testBuildReport()
+ {
+ $conf = array(
+ 'user' => array(_('report:: utilisateur'), 1, 1, 1, 1),
+ 'search' => array(_('report:: question'), 1, 0, 1, 1),
+ 'ddate' => array(_('report:: date'), 1, 0, 1, 1),
+ 'fonction' => array(_('report:: fonction'), 1, 1, 1, 1),
+ 'activite' => array(_('report:: activite'), 1, 1, 1, 1),
+ 'pays' => array(_('report:: pays'), 1, 1, 1, 1),
+ 'societe' => array(_('report:: societe'), 1, 1, 1, 1)
+ );
+
+ foreach ($this->ret as $sbasid => $collections) {
+ $this->report = new module_report_question(
+ $this->dmin,
+ $this->dmax,
+ $sbasid,
+ $collections
+ );
+
+ $this->ColFilter();
+
+ $result = $this->report->buildReport($conf);
+ $this->reporttestPage($result);
+ if (count($result['result']) > 0)
+ $this->reporttestConf($conf);
+ if (count($result['result']) > 0)
+ $this->reporttestResult($result, $conf);
+ }
+
+ foreach ($this->ret as $sbasid => $collections) {
+ $this->report = new module_report_question(
+ $this->dmin,
+ $this->dmax,
+ $sbasid,
+ $collections
+ );
+
+ $this->ColFilter();
+
+ $result = $this->report->buildReport(false, 'user');
+ $this->reporttestPage($result);
+ if (count($result['result']) > 0)
+ $this->reporttestConf($conf, 'user');
+ if (count($result['result']) > 0)
+ $this->reporttestResult($result, $conf, 'user');
+ }
+ }
+
+ public function reporttestPage($report)
+ {
+ $this->assertLessThanOrEqual($this->report->getNbRecord(), count($report['result']));
+
+ $nbPage = ceil($this->report->getTotal() / $this->report->getNbRecord());
+
+ if ($this->report->getTotal() > $this->report->getNbRecord())
+ $this->assertTrue($report['display_nav']);
+ else
+ $this->assertFalse($report['display_nav']);
+
+ if ($report['page'] == 1)
+ $this->assertFalse($report['previous_page']);
+ else
+ $this->assertEquals($report['page'] - 1, $report['previous_page']);
+
+ if (intval($nbPage) > $report['page'])
+ $this->assertEquals($report['page'] + 1, $report['next_page']);
+ else
+ $this->assertFalse($report['next_page']);
+ }
+
+ public function reporttestConf($conf, $groupby = false)
+ {
+ if ($groupby)
+ $this->assertEquals(count($this->report->getDisplay()), 2);
+ else
+ $this->assertEquals(count($this->report->getDisplay()), count($conf));
+
+ if ( ! $groupby) {
+ foreach ($this->report->getDisplay() as $col => $colconf) {
+ $this->assertArrayHaskey($col, $conf);
+ $this->assertTrue(is_array($colconf));
+ $this->assertArrayHasKey('title', $colconf);
+ $this->assertArrayHasKey('sort', $colconf);
+ $this->assertArrayHasKey('bound', $colconf);
+ $this->assertArrayHasKey('filter', $colconf);
+ $this->assertArrayHasKey('groupby', $colconf);
+ $i = 0;
+ foreach ($colconf as $key => $value) {
+ if ($i == 1)
+ $this->assertEquals($conf[$col][$i], $value);
+ elseif ($i == 2)
+ $this->assertEquals($conf[$col][$i], $value);
+ elseif ($i == 3)
+ $this->assertEquals($conf[$col][$i], $value);
+ elseif ($i == 4)
+ $this->assertEquals($conf[$col][$i], $value);
+ $i ++;
+ }
+ }
+ }
+ else {
+ $this->assertArrayHasKey($groupby, $this->report->getDisplay());
+ $this->assertArrayHasKey('nb', $this->report->getDisplay());
+ }
+ }
+
+ public function reporttestResult($report, $conf, $groupby = false)
+ {
+ if ( ! $groupby) {
+ foreach ($report['result'] as $row) {
+ foreach ($conf as $key => $value) {
+
+ $this->assertArrayHasKey($key, $row);
+ $condition = is_string($row[$key]) || is_int($row[$key]);
+ $this->assertTrue($condition);
+ }
+ }
+ } else {
+ foreach ($report['result'] as $row) {
+ $this->assertArrayHasKey($groupby, $row);
+ $this->assertArrayHasKey('nb', $row);
+ }
+ }
+ }
}
diff --git a/tests/report/reportTest.php b/tests/report/reportTest.php
index 87ff968e3e..cf568f9286 100644
--- a/tests/report/reportTest.php
+++ b/tests/report/reportTest.php
@@ -1,182 +1,161 @@
xml = '
+ public function setUp()
+ {
+ parent::setUp();
+ $this->xml = '
hello
';
- $date = new Datetime();
- $this->dmax = $date->format("Y-m-d H:i:s");
- $date->modify('-6 month');
- $this->dmin = $date->format("Y-m-d H:i:s");
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $databoxes = $appbox->get_databoxes();
- $this->ret = array();
- foreach ($databoxes as $databox)
- {
- $colls = $databox->get_collections();
- $rett = array();
- foreach ($colls as $coll)
- {
- $rett[$coll->get_coll_id()] = $coll->get_coll_id();
- }
- $this->ret[$databox->get_sbas_id()] = implode(',', $rett);
+ $date = new Datetime();
+ $this->dmax = $date->format("Y-m-d H:i:s");
+ $date->modify('-6 month');
+ $this->dmin = $date->format("Y-m-d H:i:s");
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $databoxes = $appbox->get_databoxes();
+ $this->ret = array();
+ foreach ($databoxes as $databox) {
+ $colls = $databox->get_collections();
+ $rett = array();
+ foreach ($colls as $coll) {
+ $rett[$coll->get_coll_id()] = $coll->get_coll_id();
+ }
+ $this->ret[$databox->get_sbas_id()] = implode(',', $rett);
+ }
}
- }
- public function testReport()
- {
- foreach ($this->ret as $sbasid => $collections)
+
+ public function testReport()
{
- $this->report = new module_report($this->dmin, $this->dmax, $sbasid, $collections);
- $this->report->setUser_id(self::$user->get_id());
- $this->assertEquals($collections, $this->report->getListCollId());
- $this->host($this->report);
+ foreach ($this->ret as $sbasid => $collections) {
+ $this->report = new module_report($this->dmin, $this->dmax, $sbasid, $collections);
+ $this->report->setUser_id(self::$user->get_id());
+ $this->assertEquals($collections, $this->report->getListCollId());
+ $this->host($this->report);
+ }
}
- }
- public function host($report)
- {
- $host ='http://www.google.fr/search?q=helloworld&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:fr:official&client=firefox-a#pq=fake%20url%20constructor&hl=fr&sugexp=gsnos%2Cn%3D2&cp=8&gs_id=y&xhr=t&q=hello+world&pf=p&sclient=psy&client=firefox-a&hs=mIa&rls=org.mozilla:fr%3Aofficial&source=hp&pbx=1&oq=hello+wo&aq=0&aqi=g2&aql=t&gs_sm=&gs_upl=&bav=on.2,or.r_gc.r_pw.&fp=ab54cb1d4456efee&biw=1152&bih=712';
- $host = $report->getHost($host);
- $this->assertEquals('www.google.fr', $host);
- $host ='http://localhost.phr4/login';
- $host = $report->getHost($host);
- $this->assertEquals('localhost.phr4', $host);
- }
-
- /**
- * @todo refactor
- */
-// public function SqlBuilder()
-// {
-// $domain = $this->report->sqlBuilder("connexion");
-// $this->assertInstanceOf('module_report_sqlconnexion', $domain);
-// $domain = $this->report->sqlBuilder("download");
-// $this->assertInstanceOf('module_report_sqldownload', $domain);
-// $domain = $this->report->sqlBuilder("question");
-// $this->assertInstanceOf('module_report_sqlquestion', $domain);
-// $domain = $this->report->sqlBuilder("action");
-// $this->assertInstanceOf('module_report_sqlaction', $domain);
-// $domain = $this->report->sqlBuilder("unknow");
-// $this->assertEquals($this->report->getReq(), $domain);
-// }
-
- public function SetBound()
- {
- $this->report->setBound('test', true);
- $bound = $this->report->getBound();
- $this->assertArrayhaskey('test', $bound);
- $this->assertEquals(1, $bound['test']);
- $this->report->setBound('test', false);
- $bound = $this->report->getBound();
- $this->assertArrayhaskey('test', $bound);
- $this->assertEquals(0, $bound['test']);
- }
-
- public function SetOrder()
- {
- $this->report->setOrder('champs', 'order');
- $order = $this->report->getOrder();
- $this->assertEquals('champs', $order['champ']);
- $this->assertEquals('order', $order['order']);
- $this->assertEquals('champs', $this->report->getOrder('champ'));
- }
-
- public function testGetterSetter()
- {
-
-
- $report = new module_report($this->dmin, $this->dmax, 1 , '');
- $bool = true;
- $report->setPrettyString($bool);
- $this->assertEquals($bool, $report->getPrettyString());
- $title = 'test';
- $report->setTitle($title);
- $this->assertEquals($title, $report->getTitle());
- $bool = false;
- $report->setCsv($bool);
- $this->assertEquals($bool, $report->getCsv());
- $filter = array('test', 'array');
- $report->setFilter($filter);
- $this->assertEquals($filter, $report->getTabFilter());
- $periode = "2 years";
- $report->setPeriode($periode);
- $this->assertEquals($periode, $report->getPeriode());
- $postingFilter = 'my posting filter !';
- $report->setpostingFilter($postingFilter);
- $this->assertEquals($postingFilter, $report->getPostingFilter());
- $page = 223;
- $limit = 125;
- $report->setLimit($page, $limit);
- $this->assertEquals($page, $report->getNbPage());
- $this->assertEquals($limit, $report->getNbRecord());
- $report->setGroupBy($bool);
- $this->assertEquals($bool, $report->getGroupBy());
- $column = array('col1', 'col2');
- $report->setActiveColumn($column);
- $this->assertEquals($column, $report->getActiveColumn());
- $report->setConfig($bool);
- $report->setPrint($bool);
- $report->setHasLimit($bool);
- $this->assertFalse($report->getConfig());
- $this->assertFalse($report->getPrint());
- $this->assertFalse($report->getHasLimit());
- $result = array('result', 'result');
- $report->setResult($result);
- $this->assertEquals($result, $report->getResult());
- $total = 3200;
- $report->setTotal($total);
- $this->assertEquals($total, $report->getTotal());
- $default_display = array('a', 'b', 'c');
- $report->setDefault_display($default_display);
- $this->assertEquals($default_display, $report->getDefault_display());
- }
-
-
- public function testOther()
- {
-
- foreach ($this->ret as $sbasid => $collections)
+ public function host($report)
{
- $report = $this->getMock('module_report', array('buildReq', 'buildResult'), array(), '', FALSE);
- $report->setSbas_id($sbasid);
- $this->assertEquals($sbasid, $report->getSbas_id());
- $report->setRequest('SELECT
+ $host = 'http://www.google.fr/search?q=helloworld&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:fr:official&client=firefox-a#pq=fake%20url%20constructor&hl=fr&sugexp=gsnos%2Cn%3D2&cp=8&gs_id=y&xhr=t&q=hello+world&pf=p&sclient=psy&client=firefox-a&hs=mIa&rls=org.mozilla:fr%3Aofficial&source=hp&pbx=1&oq=hello+wo&aq=0&aqi=g2&aql=t&gs_sm=&gs_upl=&bav=on.2,or.r_gc.r_pw.&fp=ab54cb1d4456efee&biw=1152&bih=712';
+ $host = $report->getHost($host);
+ $this->assertEquals('www.google.fr', $host);
+ $host = 'http://localhost.phr4/login';
+ $host = $report->getHost($host);
+ $this->assertEquals('localhost.phr4', $host);
+ }
+
+ public function SqlBuilder()
+ {
+ $this->markTestSkipped('to refactor');
+ $domain = $this->report->sqlBuilder("connexion");
+ $this->assertInstanceOf('module_report_sqlconnexion', $domain);
+ $domain = $this->report->sqlBuilder("download");
+ $this->assertInstanceOf('module_report_sqldownload', $domain);
+ $domain = $this->report->sqlBuilder("question");
+ $this->assertInstanceOf('module_report_sqlquestion', $domain);
+ $domain = $this->report->sqlBuilder("action");
+ $this->assertInstanceOf('module_report_sqlaction', $domain);
+ $domain = $this->report->sqlBuilder("unknow");
+ $this->assertEquals($this->report->getReq(), $domain);
+ }
+
+ public function SetBound()
+ {
+ $this->report->setBound('test', true);
+ $bound = $this->report->getBound();
+ $this->assertArrayhaskey('test', $bound);
+ $this->assertEquals(1, $bound['test']);
+ $this->report->setBound('test', false);
+ $bound = $this->report->getBound();
+ $this->assertArrayhaskey('test', $bound);
+ $this->assertEquals(0, $bound['test']);
+ }
+
+ public function SetOrder()
+ {
+ $this->report->setOrder('champs', 'order');
+ $order = $this->report->getOrder();
+ $this->assertEquals('champs', $order['champ']);
+ $this->assertEquals('order', $order['order']);
+ $this->assertEquals('champs', $this->report->getOrder('champ'));
+ }
+
+ public function testGetterSetter()
+ {
+
+
+ $report = new module_report($this->dmin, $this->dmax, 1, '');
+ $bool = true;
+ $report->setPrettyString($bool);
+ $this->assertEquals($bool, $report->getPrettyString());
+ $title = 'test';
+ $report->setTitle($title);
+ $this->assertEquals($title, $report->getTitle());
+ $bool = false;
+ $report->setCsv($bool);
+ $this->assertEquals($bool, $report->getCsv());
+ $filter = array('test', 'array');
+ $report->setFilter($filter);
+ $this->assertEquals($filter, $report->getTabFilter());
+ $periode = "2 years";
+ $report->setPeriode($periode);
+ $this->assertEquals($periode, $report->getPeriode());
+ $postingFilter = 'my posting filter !';
+ $report->setpostingFilter($postingFilter);
+ $this->assertEquals($postingFilter, $report->getPostingFilter());
+ $page = 223;
+ $limit = 125;
+ $report->setLimit($page, $limit);
+ $this->assertEquals($page, $report->getNbPage());
+ $this->assertEquals($limit, $report->getNbRecord());
+ $report->setGroupBy($bool);
+ $this->assertEquals($bool, $report->getGroupBy());
+ $column = array('col1', 'col2');
+ $report->setActiveColumn($column);
+ $this->assertEquals($column, $report->getActiveColumn());
+ $report->setConfig($bool);
+ $report->setPrint($bool);
+ $report->setHasLimit($bool);
+ $this->assertFalse($report->getConfig());
+ $this->assertFalse($report->getPrint());
+ $this->assertFalse($report->getHasLimit());
+ $result = array('result', 'result');
+ $report->setResult($result);
+ $this->assertEquals($result, $report->getResult());
+ $total = 3200;
+ $report->setTotal($total);
+ $this->assertEquals($total, $report->getTotal());
+ $default_display = array('a', 'b', 'c');
+ $report->setDefault_display($default_display);
+ $this->assertEquals($default_display, $report->getDefault_display());
+ }
+
+ public function testOther()
+ {
+
+ foreach ($this->ret as $sbasid => $collections) {
+ $report = $this->getMock('module_report', array('buildReq', 'buildResult'), array(), '', FALSE);
+ $report->setSbas_id($sbasid);
+ $this->assertEquals($sbasid, $report->getSbas_id());
+ $report->setRequest('SELECT
user,
usrid,
log.date as ddate,
@@ -190,10 +169,10 @@ class reportTest extends PhraseanetPHPUnitAbstract
appli,
ip
FROM log ');
- $report->expects($this->any())->method('buildReq')->will($this->returnValue(''));
- $report->expects($this->any())->method('buildResult')->will($this->returnValue(array()));
- $result = $report->buildReport(false, 'user');
+ $report->expects($this->any())->method('buildReq')->will($this->returnValue(''));
+ $report->expects($this->any())->method('buildResult')->will($this->returnValue(array()));
+ $result = $report->buildReport(false, 'user');
// $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $report->getChamps());
+ }
}
- }
}
diff --git a/tests/report/sqlActionTest.php b/tests/report/sqlActionTest.php
index 35526bf1ec..785889572d 100644
--- a/tests/report/sqlActionTest.php
+++ b/tests/report/sqlActionTest.php
@@ -1,39 +1,21 @@
action = new module_report_sqlaction($this->getMock('module_report', array(), array(), '', false));
+ }
- public function setUp()
- {
- $this->action = new module_report_sqlaction($this->getMock('module_report', array(), array() , '', false));
-
- }
-
- public function testGetAction()
- {
- $this->assertEquals('add', $this->action->getAction());
- $this->action->setAction('unknowAction');
- $this->assertEquals('add', $this->action->getAction());
- }
+ public function testGetAction()
+ {
+ $this->assertEquals('add', $this->action->getAction());
+ $this->action->setAction('unknowAction');
+ $this->assertEquals('add', $this->action->getAction());
+ }
}
diff --git a/tests/report/sqlFilterTest.php b/tests/report/sqlFilterTest.php
index f74e031a48..3703dd521f 100644
--- a/tests/report/sqlFilterTest.php
+++ b/tests/report/sqlFilterTest.php
@@ -1,187 +1,145 @@
format("Y-m-d H:i:s");
- $date->modify('-6 month');
- $dmin = $date->format("Y-m-d H:i:s");
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $databoxes = $appbox->get_databoxes();
- $ret = array();
- foreach ($databoxes as $databox)
+ public function setUp()
{
- $colls = $databox->get_collections();
- $rett = array();
- foreach ($colls as $coll)
- {
- $rett[$coll->get_coll_id()] = $coll->get_coll_id();
- }
- $ret[$databox->get_sbas_id()] = implode(',', $rett);
- }
- foreach ($ret as $sbasid => $collections)
- {
- $report = new module_report_connexion(
- $dmin,
- $dmax,
- $sbasid,
- $collections
- );
- if(!$this->report instanceof module_report)
- {
- $this->report = $report;
- }
- elseif($report->getTotal() > $this->report->getTotal())
- {
- $this->report = $report;
- }
+ parent::setUp();
+ $date = new Datetime();
+ $dmax = $date->format("Y-m-d H:i:s");
+ $date->modify('-6 month');
+ $dmin = $date->format("Y-m-d H:i:s");
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $databoxes = $appbox->get_databoxes();
+ $ret = array();
+ foreach ($databoxes as $databox) {
+ $colls = $databox->get_collections();
+ $rett = array();
+ foreach ($colls as $coll) {
+ $rett[$coll->get_coll_id()] = $coll->get_coll_id();
+ }
+ $ret[$databox->get_sbas_id()] = implode(',', $rett);
+ }
+ foreach ($ret as $sbasid => $collections) {
+ $report = new module_report_connexion(
+ $dmin,
+ $dmax,
+ $sbasid,
+ $collections
+ );
+ if ( ! $this->report instanceof module_report) {
+ $this->report = $report;
+ } elseif ($report->getTotal() > $this->report->getTotal()) {
+ $this->report = $report;
+ }
+ }
+
+ $this->report->setFilter(array(array('f' => 'user', 'o' => '=', 'v' => 'admin'), array('f' => 'ddate', 'o' => 'LIKE', 'v' => '*'), array('f' => '1', 'o' => 'OR', 'v' => '1')));
+ $this->report->setUser_id(self::$user->get_id());
+ $this->report->setOrder('user', 'ASC');
+ $this->filter = new module_report_sqlfilter($this->report);
}
- $this->report->setFilter(array(array('f' => 'user', 'o' => '=', 'v'=>'admin'), array('f' => 'ddate', 'o' => 'LIKE', 'v'=>'*'), array('f' => '1', 'o' => 'OR', 'v'=>'1')));
- $this->report->setUser_id(self::$user->get_id());
- $this->report->setOrder('user', 'ASC');
- $this->filter = new module_report_sqlfilter($this->report);
- }
-
- public function checkFilter($filter)
- {
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $filter);
- $this->assertArrayHasKey('params', $filter);
- $this->assertArrayHasKey('sql', $filter);
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $filter['params']);
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $filter['sql']);
- foreach($filter['params'] as $key => $value)
+ public function checkFilter($filter)
{
- $this->assertRegExp('/'.$key.'/', $filter['sql']);
- }
- }
-
- public function testGvFilter()
- {
- $filter = $this->filter->getGvSitFilter();
- $this->checkFilter($filter);
- }
-
- public function testUserIDFilter()
- {
- $filter = $this->filter->getUserIdFilter(2);
- $this->assertTrue(in_array(2, $filter['params']));
- $this->checkFilter($filter);
- }
-
- public function testDateFilter()
- {
- $filter = $this->filter->getDateFilter();
- $this->checkFilter($filter);
- }
-
- public function testUserFilter()
- {
- $f = $this->report->getTabFilter();
-
- if (sizeof($f) == 0)
- {
- $this->assertFalse($this->filter->getUserFilter());
- }
- else
- {
- $filter = $this->filter->getUserFilter();
- $this->checkFilter($filter);
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $filter);
+ $this->assertArrayHasKey('params', $filter);
+ $this->assertArrayHasKey('sql', $filter);
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $filter['params']);
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $filter['sql']);
+ foreach ($filter['params'] as $key => $value) {
+ $this->assertRegExp('/' . $key . '/', $filter['sql']);
+ }
}
- }
-
- public function testCollectionFilter()
- {
- if($this->report->getUserId() == '')
+ public function testGvFilter()
{
- $this->assertFalse($this->filter->getCollectionFilter());
- }
- elseif(count(explode(",", $this->report->getListCollId()) > 0))
- {
- $filter = $this->filter->getCollectionFilter();
- $this->checkFilter($filter);
- }
- else
- {
- $this->assertFalse($this->filter->getCollectionFilter());
- }
- }
-
- public function testRecordFilter()
- {
- if($this->report->getUserId() == '')
- {
- $this->assertFalse($this->filter->getRecordFilter());
- }
- else
- {
- $filter = $this->filter->getRecordFilter();
- $this->checkFilter($filter);
- }
- }
-
- public function testLimitFilter()
- {
- $p = $this->report->getNbPage();
- $r = $this->report->getNbRecord();
-
- if ($p && $r)
- {
- $filter = $this->filter->getLimitFilter();
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $filter);
- }
- else
- {
- $this->assertFalse($this->filter->getLimitFilter());
+ $filter = $this->filter->getGvSitFilter();
+ $this->checkFilter($filter);
}
- }
-
- public function testOrderFilter()
- {
- if (sizeof($this->report->getOrder()) > 0)
+ public function testUserIDFilter()
{
- $filter = $this->filter->getOrderFilter();
- $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $filter);
+ $filter = $this->filter->getUserIdFilter(2);
+ $this->assertTrue(in_array(2, $filter['params']));
+ $this->checkFilter($filter);
}
- else
- {
- $this->assertFalse($this->filter->getOrderFilter());
- }
- }
- public function testReportFilter()
- {
- $filter = $this->filter->getReportFilter();
- $this->checkFilter($filter);
- }
+ public function testDateFilter()
+ {
+ $filter = $this->filter->getDateFilter();
+ $this->checkFilter($filter);
+ }
+
+ public function testUserFilter()
+ {
+ $f = $this->report->getTabFilter();
+
+ if (sizeof($f) == 0) {
+ $this->assertFalse($this->filter->getUserFilter());
+ } else {
+ $filter = $this->filter->getUserFilter();
+ $this->checkFilter($filter);
+ }
+ }
+
+ public function testCollectionFilter()
+ {
+ if ($this->report->getUserId() == '') {
+ $this->assertFalse($this->filter->getCollectionFilter());
+ } elseif (count(explode(",", $this->report->getListCollId()) > 0)) {
+ $filter = $this->filter->getCollectionFilter();
+ $this->checkFilter($filter);
+ } else {
+ $this->assertFalse($this->filter->getCollectionFilter());
+ }
+ }
+
+ public function testRecordFilter()
+ {
+ if ($this->report->getUserId() == '') {
+ $this->assertFalse($this->filter->getRecordFilter());
+ } else {
+ $filter = $this->filter->getRecordFilter();
+ $this->checkFilter($filter);
+ }
+ }
+
+ public function testLimitFilter()
+ {
+ $p = $this->report->getNbPage();
+ $r = $this->report->getNbRecord();
+
+ if ($p && $r) {
+ $filter = $this->filter->getLimitFilter();
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $filter);
+ } else {
+ $this->assertFalse($this->filter->getLimitFilter());
+ }
+ }
+
+ public function testOrderFilter()
+ {
+ if (sizeof($this->report->getOrder()) > 0) {
+ $filter = $this->filter->getOrderFilter();
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $filter);
+ } else {
+ $this->assertFalse($this->filter->getOrderFilter());
+ }
+ }
+
+ public function testReportFilter()
+ {
+ $filter = $this->filter->getReportFilter();
+ $this->checkFilter($filter);
+ }
}
diff --git a/tests/report/sqlTest.php b/tests/report/sqlTest.php
index b86f461a59..d810add1e8 100644
--- a/tests/report/sqlTest.php
+++ b/tests/report/sqlTest.php
@@ -1,43 +1,27 @@
getMock('module_report', array(), array(), '', false);
- $this->sql = new module_report_sql($report);
- }
+ public function setUp()
+ {
+ parent::setUp();
+ $report = $this->getMock('module_report', array(), array(), '', false);
+ $this->sql = new module_report_sql($report);
+ }
- public function testSql()
- {
- $sqlFilter = $this->getMock('module_report_sqlfilter', array('getCorFilter'), array(), '', false);
- $sqlFilter->expects($this->any())->method('getCorFilter')->will($this->onConsecutiveCalls(array(), array('hello'=>'world')));
- $this->sql->setFilter($sqlFilter);
- $this->assertEquals('hello', $this->sql->getTransQuery('hello'));
- $this->assertEquals('world', $this->sql->getTransQuery('hello'));
- $this->sql->setGroupby('test');
- $this->assertEquals('test', $this->sql->getGroupBy());
- $this->sql->setOn('on');
- $this->assertEquals('on', $this->sql->getOn());
- }
+ public function testSql()
+ {
+ $sqlFilter = $this->getMock('module_report_sqlfilter', array('getCorFilter'), array(), '', false);
+ $sqlFilter->expects($this->any())->method('getCorFilter')->will($this->onConsecutiveCalls(array(), array('hello' => 'world')));
+ $this->sql->setFilter($sqlFilter);
+ $this->assertEquals('hello', $this->sql->getTransQuery('hello'));
+ $this->assertEquals('world', $this->sql->getTransQuery('hello'));
+ $this->sql->setGroupby('test');
+ $this->assertEquals('test', $this->sql->getGroupBy());
+ $this->sql->setOn('on');
+ $this->assertEquals('on', $this->sql->getOn());
+ }
}
diff --git a/tests/searchEngine_optionsTest.php b/tests/searchEngine_optionsTest.php
index 9db1ef3a78..f43aac4510 100644
--- a/tests/searchEngine_optionsTest.php
+++ b/tests/searchEngine_optionsTest.php
@@ -4,239 +4,238 @@ require_once __DIR__ . '/PhraseanetPHPUnitAuthenticatedAbstract.class.inc';
class searchEngine_optionsTest extends PhraseanetPHPUnitAuthenticatedAbstract
{
+ /**
+ * @var searchEngine_options
+ */
+ protected $object;
- /**
- * @var searchEngine_options
- */
- protected $object;
+ public function setUp()
+ {
+ parent::setUp();
+ $this->object = new searchEngine_options();
+ }
- public function setUp()
- {
- $this->object = new searchEngine_options();
- }
+ public function testSet_locale()
+ {
+ $locale = 'BABA';
+ $this->object->set_locale($locale);
+ $this->assertEquals($locale, $this->object->get_locale());
+ }
- public function testSet_locale()
- {
- $locale = 'BABA';
- $this->object->set_locale($locale);
- $this->assertEquals($locale, $this->object->get_locale());
- }
+ public function testGet_locale()
+ {
+ $locale = null;
+ $this->object->set_locale($locale);
+ $this->assertEquals($locale, $this->object->get_locale());
+ }
- public function testGet_locale()
- {
- $locale = null;
- $this->object->set_locale($locale);
- $this->assertEquals($locale, $this->object->get_locale());
- }
+ public function testSet_sort()
+ {
+ $by = 'NAME';
+ $sort = 'ASC';
+ $this->object->set_sort($by, $sort);
+ $this->assertEquals($by, $this->object->get_sortby());
+ $this->assertEquals($sort, $this->object->get_sortord());
+ $this->object->set_sort($by);
+ $this->assertEquals($by, $this->object->get_sortby());
+ $this->assertEquals(searchEngine_options::SORT_MODE_DESC, $this->object->get_sortord());
+ }
- public function testSet_sort()
- {
- $by = 'NAME';
- $sort = 'ASC';
- $this->object->set_sort($by, $sort);
- $this->assertEquals($by, $this->object->get_sortby());
- $this->assertEquals($sort, $this->object->get_sortord());
- $this->object->set_sort($by);
- $this->assertEquals($by, $this->object->get_sortby());
- $this->assertEquals(searchEngine_options::SORT_MODE_DESC, $this->object->get_sortord());
- }
+ public function testGet_sortby()
+ {
+ $by = 'NAME';
+ $sort = 'DESC';
+ $this->object->set_sort($by, $sort);
+ $this->assertEquals($by, $this->object->get_sortby());
+ $this->assertEquals($sort, $this->object->get_sortord());
+ }
- public function testGet_sortby()
- {
- $by = 'NAME';
- $sort = 'DESC';
- $this->object->set_sort($by, $sort);
- $this->assertEquals($by, $this->object->get_sortby());
- $this->assertEquals($sort, $this->object->get_sortord());
- }
+ public function testGet_sortord()
+ {
+ $by = 'NAME';
+ $sort = 'DESC';
+ $this->object->set_sort($by, $sort);
+ $this->assertEquals($by, $this->object->get_sortby());
+ $this->assertEquals($sort, $this->object->get_sortord());
+ }
- public function testGet_sortord()
- {
- $by = 'NAME';
- $sort = 'DESC';
- $this->object->set_sort($by, $sort);
- $this->assertEquals($by, $this->object->get_sortby());
- $this->assertEquals($sort, $this->object->get_sortord());
- }
+ public function testSet_use_stemming()
+ {
+ $bool = true;
+ $this->object->set_use_stemming($bool);
+ $this->assertEquals($bool, $this->object->get_use_stemming());
+ $bool = false;
+ $this->object->set_use_stemming($bool);
+ $this->assertEquals($bool, $this->object->get_use_stemming());
+ }
- public function testSet_use_stemming()
- {
- $bool = true;
- $this->object->set_use_stemming($bool);
- $this->assertEquals($bool, $this->object->get_use_stemming());
- $bool = false;
- $this->object->set_use_stemming($bool);
- $this->assertEquals($bool, $this->object->get_use_stemming());
- }
+ public function testGet_use_stemming()
+ {
+ $bool = true;
+ $this->object->set_use_stemming($bool);
+ $this->assertEquals($bool, $this->object->get_use_stemming());
+ $bool = false;
+ $this->object->set_use_stemming($bool);
+ $this->assertEquals($bool, $this->object->get_use_stemming());
+ }
- public function testGet_use_stemming()
- {
- $bool = true;
- $this->object->set_use_stemming($bool);
- $this->assertEquals($bool, $this->object->get_use_stemming());
- $bool = false;
- $this->object->set_use_stemming($bool);
- $this->assertEquals($bool, $this->object->get_use_stemming());
- }
+ public function testSet_search_type()
+ {
+ $type = "caca";
+ $this->object->set_search_type($type);
+ $this->assertEquals(searchEngine_options::RECORD_RECORD, $this->object->get_search_type());
+ $type = searchEngine_options::RECORD_RECORD;
+ $this->object->set_search_type($type);
+ $this->assertEquals(searchEngine_options::RECORD_RECORD, $this->object->get_search_type());
+ $type = searchEngine_options::RECORD_GROUPING;
+ $this->object->set_search_type($type);
+ $this->assertEquals(searchEngine_options::RECORD_GROUPING, $this->object->get_search_type());
+ }
- public function testSet_search_type()
- {
- $type = "caca";
- $this->object->set_search_type($type);
- $this->assertEquals(searchEngine_options::RECORD_RECORD, $this->object->get_search_type());
- $type = searchEngine_options::RECORD_RECORD;
- $this->object->set_search_type($type);
- $this->assertEquals(searchEngine_options::RECORD_RECORD, $this->object->get_search_type());
- $type = searchEngine_options::RECORD_GROUPING;
- $this->object->set_search_type($type);
- $this->assertEquals(searchEngine_options::RECORD_GROUPING, $this->object->get_search_type());
- }
+ public function testGet_search_type()
+ {
+ $type = "caca";
+ $this->object->set_search_type($type);
+ $this->assertEquals(searchEngine_options::RECORD_RECORD, $this->object->get_search_type());
+ $type = searchEngine_options::RECORD_RECORD;
+ $this->object->set_search_type($type);
+ $this->assertEquals(searchEngine_options::RECORD_RECORD, $this->object->get_search_type());
+ $type = searchEngine_options::RECORD_GROUPING;
+ $this->object->set_search_type($type);
+ $this->assertEquals(searchEngine_options::RECORD_GROUPING, $this->object->get_search_type());
+ }
- public function testGet_search_type()
- {
- $type = "caca";
- $this->object->set_search_type($type);
- $this->assertEquals(searchEngine_options::RECORD_RECORD, $this->object->get_search_type());
- $type = searchEngine_options::RECORD_RECORD;
- $this->object->set_search_type($type);
- $this->assertEquals(searchEngine_options::RECORD_RECORD, $this->object->get_search_type());
- $type = searchEngine_options::RECORD_GROUPING;
- $this->object->set_search_type($type);
- $this->assertEquals(searchEngine_options::RECORD_GROUPING, $this->object->get_search_type());
- }
+ public function testSet_bases()
+ {
+ $bases = array_keys(self::$user->ACL()->get_granted_base());
+ $this->object->set_bases($bases, self::$user->ACL());
+ $this->assertEquals(array_values($bases), array_values($this->object->get_bases()));
+ }
- public function testSet_bases()
- {
- $bases = array_keys(self::$user->ACL()->get_granted_base());
- $this->object->set_bases($bases, self::$user->ACL());
- $this->assertEquals(array_values($bases), array_values($this->object->get_bases()));
- }
+ public function testGet_bases()
+ {
+ $bases = array_keys(self::$user->ACL()->get_granted_base());
+ $this->object->set_bases($bases, self::$user->ACL());
+ $this->assertEquals(array_values($bases), array_values($this->object->get_bases()));
+ }
- public function testGet_bases()
- {
- $bases = array_keys(self::$user->ACL()->get_granted_base());
- $this->object->set_bases($bases, self::$user->ACL());
- $this->assertEquals(array_values($bases), array_values($this->object->get_bases()));
- }
-
- public function testSet_fields()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
+ public function testSet_fields()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
'This test has not been implemented yet.'
- );
- }
+ );
+ }
- public function testGet_fields()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
+ public function testGet_fields()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
'This test has not been implemented yet.'
- );
- }
+ );
+ }
- public function testSet_status()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
+ public function testSet_status()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
'This test has not been implemented yet.'
- );
- }
+ );
+ }
- public function testGet_status()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
+ public function testGet_status()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
'This test has not been implemented yet.'
- );
- }
+ );
+ }
- public function testSet_record_type()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
+ public function testSet_record_type()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
'This test has not been implemented yet.'
- );
- }
+ );
+ }
- public function testGet_record_type()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
+ public function testGet_record_type()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
'This test has not been implemented yet.'
- );
- }
+ );
+ }
- public function testSet_min_date()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
+ public function testSet_min_date()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
'This test has not been implemented yet.'
- );
- }
+ );
+ }
- public function testGet_min_date()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
+ public function testGet_min_date()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
'This test has not been implemented yet.'
- );
- }
+ );
+ }
- public function testSet_max_date()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
+ public function testSet_max_date()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
'This test has not been implemented yet.'
- );
- }
+ );
+ }
- public function testGet_max_date()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
+ public function testGet_max_date()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
'This test has not been implemented yet.'
- );
- }
+ );
+ }
- public function testSet_date_fields()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
+ public function testSet_date_fields()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
'This test has not been implemented yet.'
- );
- }
+ );
+ }
- public function testGet_date_fields()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
+ public function testGet_date_fields()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
'This test has not been implemented yet.'
- );
- }
+ );
+ }
- public function testSerialize()
- {
- $bases = array_keys(self::$user->ACL()->get_granted_base());
- $this->object->set_bases($bases, self::$user->ACL());
- $this->object->set_date_fields(array());
- $this->object->set_locale('fr_FR');
- $this->object->set_max_date(null);
- $this->object->set_min_date(null);
- $this->object->set_record_type(searchEngine_options::TYPE_AUDIO);
- $this->object->set_search_type(searchEngine_options::RECORD_RECORD);
- $this->object->set_sort('Name','DESC');
- $this->object->set_status(array());
- $this->object->set_use_stemming(true);
- $this->assertEquals($this->object, unserialize(serialize($this->object)));
- }
+ public function testSerialize()
+ {
+ $bases = array_keys(self::$user->ACL()->get_granted_base());
+ $this->object->set_bases($bases, self::$user->ACL());
+ $this->object->set_date_fields(array());
+ $this->object->set_locale('fr_FR');
+ $this->object->set_max_date(null);
+ $this->object->set_min_date(null);
+ $this->object->set_record_type(searchEngine_options::TYPE_AUDIO);
+ $this->object->set_search_type(searchEngine_options::RECORD_RECORD);
+ $this->object->set_sort('Name', 'DESC');
+ $this->object->set_status(array());
+ $this->object->set_use_stemming(true);
+ $this->assertEquals($this->object, unserialize(serialize($this->object)));
+ }
- public function testUnserialize()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
+ public function testUnserialize()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
'This test has not been implemented yet.'
- );
- }
-
+ );
+ }
}
diff --git a/tests/setupTest.php b/tests/setupTest.php
deleted file mode 100644
index 026808557d..0000000000
--- a/tests/setupTest.php
+++ /dev/null
@@ -1,198 +0,0 @@
-markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testCheck_binaries().
- */
- public function testCheck_binaries()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testCheck_mod_auth_token().
- */
- public function testCheck_mod_auth_token()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testCheck_apache().
- */
- public function testCheck_apache()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testCheck_phrasea().
- */
- public function testCheck_phrasea()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testCheck_writability().
- */
- public function testCheck_writability()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testCheck_mail_form().
- */
- public function testCheck_mail_form()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testCheck_php_version().
- */
- public function testCheck_php_version()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testCheck_php_extension().
- */
- public function testCheck_php_extension()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
-
- /**
- * @todo Implement testCheck_cache_memcache().
- */
- public function testCheck_cache_memcache()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testCheck_cache_opcode().
- */
- public function testCheck_cache_opcode()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testCheck_php_configuration().
- */
- public function testCheck_php_configuration()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testCheck_sphinx_search().
- */
- public function testCheck_sphinx_search()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testCheck_system_locales().
- */
- public function testCheck_system_locales()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testCreateAdmin().
- */
- public function testCreateAdmin()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testWrite_config().
- */
- public function testWrite_config()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testCreateBase().
- */
- public function testCreateBase()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
-}
-
diff --git a/tests/sphinxrtTest.php b/tests/sphinxrtTest.php
deleted file mode 100644
index c5d3edbca3..0000000000
--- a/tests/sphinxrtTest.php
+++ /dev/null
@@ -1,63 +0,0 @@
-markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testDelete().
- */
- public function testDelete()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testUpdate_status().
- */
- public function testUpdate_status()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testReplace_in_metas().
- */
- public function testReplace_in_metas()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @todo Implement testReplace_in_documents().
- */
- public function testReplace_in_documents()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
-}
diff --git a/tests/system/system_fileTest.php b/tests/system/system_fileTest.php
index df60a67ac7..5ca8d79d5f 100644
--- a/tests/system/system_fileTest.php
+++ b/tests/system/system_fileTest.php
@@ -4,7 +4,6 @@ require_once __DIR__ . '/../PhraseanetPHPUnitAbstract.class.inc';
class system_fileTest extends PhraseanetPHPUnitAbstract
{
-
/**
* @var system_file
*/
@@ -12,6 +11,7 @@ class system_fileTest extends PhraseanetPHPUnitAbstract
public function setUp()
{
+ parent::setUp();
$this->objects['indd'] = new system_file(__DIR__ . '/../../vendor/phpexiftool/exiftool/t/images/InDesign.indd');
$this->objects['wav'] = new system_file(__DIR__ . '/../testfiles/test012.wav');
$this->objects['jpg'] = new system_file(__DIR__ . '/../../vendor/phpexiftool/exiftool/t/images/Casio.jpg');
@@ -65,7 +65,7 @@ class system_fileTest extends PhraseanetPHPUnitAbstract
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
- 'This test has not been implemented yet.'
+ 'This test has not been implemented yet.'
);
}
@@ -76,7 +76,7 @@ class system_fileTest extends PhraseanetPHPUnitAbstract
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
- 'This test has not been implemented yet.'
+ 'This test has not been implemented yet.'
);
}
@@ -87,7 +87,7 @@ class system_fileTest extends PhraseanetPHPUnitAbstract
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
- 'This test has not been implemented yet.'
+ 'This test has not been implemented yet.'
);
}
@@ -98,7 +98,7 @@ class system_fileTest extends PhraseanetPHPUnitAbstract
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
- 'This test has not been implemented yet.'
+ 'This test has not been implemented yet.'
);
}
@@ -109,7 +109,7 @@ class system_fileTest extends PhraseanetPHPUnitAbstract
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
- 'This test has not been implemented yet.'
+ 'This test has not been implemented yet.'
);
}
@@ -120,15 +120,14 @@ class system_fileTest extends PhraseanetPHPUnitAbstract
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
- 'This test has not been implemented yet.'
+ 'This test has not been implemented yet.'
);
}
public function testMkdir()
{
$path = __DIR__ . '/test/dir/to/create/';
- if (is_dir($path))
- {
+ if (is_dir($path)) {
$this->fail('unable to create directory : directory already extists');
}
system_file::mkdir($path);
@@ -146,13 +145,13 @@ class system_fileTest extends PhraseanetPHPUnitAbstract
public function testChmod()
{
$file = __DIR__ . '/../testfiles/cestlafete.jpg';
- $dir = __DIR__ . '/testchmod';
+ $dir = __DIR__ . '/testchmod';
system_file::mkdir($dir);
chmod($file, 0700);
chmod($dir, 0700);
$system_file = new system_file($file);
- $system_dir = new system_file($dir);
+ $system_dir = new system_file($dir);
$system_file->chmod();
$system_dir->chmod();
clearstatcache();
@@ -164,7 +163,7 @@ class system_fileTest extends PhraseanetPHPUnitAbstract
public function testEmpty_directory()
{
$file = __DIR__ . '/../testfiles/cestlafete.jpg';
- $dir = __DIR__ . '/testchmod';
+ $dir = __DIR__ . '/testchmod';
system_file::mkdir($dir);
copy($file, $dir . '/v1.test');
@@ -187,13 +186,10 @@ class system_fileTest extends PhraseanetPHPUnitAbstract
$this->objects['wav']->set_phrasea_tech_field('trois', '3');
$this->objects['wav']->set_phrasea_tech_field('deux', '2');
- try
- {
+ try {
$this->objects['wav']->set_phrasea_tech_field(' ', '2');
$this->fail();
- }
- catch (Exception_InvalidArgument $e)
- {
+ } catch (Exception_InvalidArgument $e) {
}
@@ -209,11 +205,10 @@ class system_fileTest extends PhraseanetPHPUnitAbstract
public function testExtract_metadatas()
{
- $appbox = appbox::get_instance(\bootstrap::getCore());
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$databox = null;
- foreach ($appbox->get_databoxes() as $d)
- {
- $databox = $d;
+ foreach ($appbox->get_databoxes() as $d) {
+ $databox = $d;
break;
}
$this->assertInstanceOf('databox', $databox);
@@ -222,8 +217,7 @@ class system_fileTest extends PhraseanetPHPUnitAbstract
$this->assertTrue(is_array($metadatas));
$this->assertArrayHasKey('metadatas', $metadatas);
$this->assertArrayHasKey('status', $metadatas);
- foreach ($metadatas['metadatas'] as $metadata)
- {
+ foreach ($metadatas['metadatas'] as $metadata) {
$this->assertTrue(is_array($metadata));
$this->assertArrayHasKey('meta_struct_id', $metadata);
$this->assertArrayHasKey('meta_id', $metadata);
@@ -237,16 +231,15 @@ class system_fileTest extends PhraseanetPHPUnitAbstract
public function testExtract_metadatasWithCaption()
{
- $appbox = appbox::get_instance(\bootstrap::getCore());
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$databox = null;
- foreach ($appbox->get_databoxes() as $d)
- {
+ foreach ($appbox->get_databoxes() as $d) {
$databox = $d;
break;
}
$this->assertInstanceOf('databox', $databox);
- $file = new system_file(__DIR__ . '/../testfiles/extractfile.jpg');
+ $file = new system_file(__DIR__ . '/../testfiles/extractfile.jpg');
$caption = new system_file(__DIR__ . '/../testfiles/extractfile.xml');
$metadatas = $file->extract_metadatas($databox->get_meta_structure(), $caption);
@@ -256,8 +249,7 @@ class system_fileTest extends PhraseanetPHPUnitAbstract
$this->assertTrue(is_array($metadatas));
$this->assertArrayHasKey('metadatas', $metadatas);
$this->assertArrayHasKey('status', $metadatas);
- foreach ($metadatas['metadatas'] as $metadata)
- {
+ foreach ($metadatas['metadatas'] as $metadata) {
$this->assertTrue(is_array($metadata));
$this->assertArrayHasKey('meta_struct_id', $metadata);
$this->assertArrayHasKey('meta_id', $metadata);
@@ -269,13 +261,11 @@ class system_fileTest extends PhraseanetPHPUnitAbstract
$databox_field = databox_field::get_instance($databox, $metadata['meta_struct_id']);
- if ( ! $databox_field->is_multi() && isset($meta_id_found[$metadata['meta_struct_id']]))
- {
+ if ( ! $databox_field->is_multi() && isset($meta_id_found[$metadata['meta_struct_id']])) {
$this->fail('There should not be multiple mono values');
}
$meta_id_found[$metadata['meta_struct_id']] = $metadata['meta_struct_id'];
}
}
-
}
diff --git a/tests/system/system_serverTest.php b/tests/system/system_serverTest.php
index f3e4dc21dc..abb15fcb87 100644
--- a/tests/system/system_serverTest.php
+++ b/tests/system/system_serverTest.php
@@ -4,48 +4,46 @@ require_once __DIR__ . '/../PhraseanetPHPUnitAbstract.class.inc';
class system_serverTest extends PhraseanetPHPUnitAbstract
{
+ /**
+ * @var system_server
+ */
+ protected $objects = array();
- /**
- * @var system_server
- */
- protected $objects = array();
+ public function setUp()
+ {
+ parent::setUp();
+ $_SERVER['SERVER_SOFTWARE'] = 'apache';
+ $this->objects['apache'] = new system_server;
+ $_SERVER['SERVER_SOFTWARE'] = 'nginx';
+ $this->objects['nginx'] = new system_server;
+ $_SERVER['SERVER_SOFTWARE'] = 'lighttpd';
+ $this->objects['lighttpd'] = new system_server;
+ }
- public function setUp()
- {
- $_SERVER['SERVER_SOFTWARE'] = 'apache';
- $this->objects['apache'] = new system_server;
- $_SERVER['SERVER_SOFTWARE'] = 'nginx';
- $this->objects['nginx'] = new system_server;
- $_SERVER['SERVER_SOFTWARE'] = 'lighttpd';
- $this->objects['lighttpd'] = new system_server;
- }
+ public function testIs_nginx()
+ {
+ $this->assertFalse($this->objects['apache']->is_nginx());
+ $this->assertTrue($this->objects['nginx']->is_nginx());
+ $this->assertFalse($this->objects['lighttpd']->is_nginx());
+ }
- public function testIs_nginx()
- {
- $this->assertFalse($this->objects['apache']->is_nginx());
- $this->assertTrue($this->objects['nginx']->is_nginx());
- $this->assertFalse($this->objects['lighttpd']->is_nginx());
- }
+ public function testIs_lighttpd()
+ {
+ $this->assertFalse($this->objects['apache']->is_lighttpd());
+ $this->assertFalse($this->objects['nginx']->is_lighttpd());
+ $this->assertTrue($this->objects['lighttpd']->is_lighttpd());
+ }
- public function testIs_lighttpd()
- {
- $this->assertFalse($this->objects['apache']->is_lighttpd());
- $this->assertFalse($this->objects['nginx']->is_lighttpd());
- $this->assertTrue($this->objects['lighttpd']->is_lighttpd());
- }
-
- public function testIs_apache()
- {
- $this->assertTrue($this->objects['apache']->is_apache());
- $this->assertFalse($this->objects['nginx']->is_apache());
- $this->assertFalse($this->objects['lighttpd']->is_apache());
- }
-
- public function testGet_platform()
- {
- $platform = system_server::get_platform();
- $this->assertRegExp('/[A-Z]+/', $platform);
- }
+ public function testIs_apache()
+ {
+ $this->assertTrue($this->objects['apache']->is_apache());
+ $this->assertFalse($this->objects['nginx']->is_apache());
+ $this->assertFalse($this->objects['lighttpd']->is_apache());
+ }
+ public function testGet_platform()
+ {
+ $platform = system_server::get_platform();
+ $this->assertRegExp('/[A-Z]+/', $platform);
+ }
}
-
diff --git a/tests/system/system_urlTest.php b/tests/system/system_urlTest.php
index eed450a197..38d6191c71 100644
--- a/tests/system/system_urlTest.php
+++ b/tests/system/system_urlTest.php
@@ -4,22 +4,20 @@ require_once __DIR__ . '/../PhraseanetPHPUnitAbstract.class.inc';
class system_urlTest extends PhraseanetPHPUnitAbstract
{
+ /**
+ * @var system_url
+ */
+ protected $object;
+ protected $url = "http://test.example.com?action=test&labourer=bien";
- /**
- * @var system_url
- */
- protected $object;
- protected $url = "http://test.example.com?action=test&labourer=bien";
-
- public function setUp()
- {
- $this->object = new system_url($this->url);
- }
-
- public function testGet_url()
- {
- $this->assertEquals($this->url, $this->object->get_url());
- }
+ public function setUp()
+ {
+ parent::setUp();
+ $this->object = new system_url($this->url);
+ }
+ public function testGet_url()
+ {
+ $this->assertEquals($this->url, $this->object->get_url());
+ }
}
-
diff --git a/tests/task/task_abstractTest.php b/tests/task/task_abstractTest.php
index 127fb25ff4..c3de55283e 100644
--- a/tests/task/task_abstractTest.php
+++ b/tests/task/task_abstractTest.php
@@ -5,13 +5,11 @@ require_once __DIR__ . '/../PhraseanetPHPUnitAbstract.class.inc';
class task_abstractTest extends PhraseanetPHPUnitAbstract
{
- public function testCreate()
- {
- $appbox = appbox::get_instance(\bootstrap::getCore());
-
- $task = task_abstract::create($appbox, 'task_period_apibridge');
- $task->delete();
- }
+ public function testCreate()
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $task = task_abstract::create($appbox, 'task_period_apibridge');
+ $task->delete();
+ }
}
-
diff --git a/tests/thesaurusTest.php b/tests/thesaurusTest.php
index b4f0e2daf7..28c9b009cd 100644
--- a/tests/thesaurusTest.php
+++ b/tests/thesaurusTest.php
@@ -12,6 +12,4 @@ class thesaurusTest extends PhraseanetPHPUnitAbstract
$string = '&é"\'(-è_ çà)=ù*!:;,?./§%µ+°0987654321';
$this->assertEquals('&é"'(-è_ çà)=ù*!:;,?./§%µ+°0987654321', thesaurus::xquery_escape($string));
}
-
}
-
diff --git a/tests/unicodeTest.php b/tests/unicodeTest.php
index 80059f59e3..768e670782 100644
--- a/tests/unicodeTest.php
+++ b/tests/unicodeTest.php
@@ -85,8 +85,6 @@ class unicodeTest extends PhraseanetPHPUnitAbstract
*/
public function testparseDate()
{
- $date = '2012';
-
$this->assertEquals('2012/00/00 00:00:00', $this->object->parseDate('2012'));
$this->assertEquals('2012/01/00 00:00:00', $this->object->parseDate('2012-01'));
$this->assertEquals('2012/03/15 00:00:00', $this->object->parseDate('2012-03-15'));
@@ -95,4 +93,3 @@ class unicodeTest extends PhraseanetPHPUnitAbstract
$this->assertEquals('2012/03/15 12:12:12', $this->object->parseDate('2012-03-15 12-12-12'));
}
}
-
diff --git a/tests/unitTestsTest.php b/tests/unitTestsTest.php
index 6b84267d2b..68e8a51126 100644
--- a/tests/unitTestsTest.php
+++ b/tests/unitTestsTest.php
@@ -8,8 +8,7 @@ class unitTestsTest extends PhraseanetPHPUnitAbstract
public function testFiles()
{
$testDir = __DIR__ . '/';
- foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($testDir), RecursiveIteratorIterator::LEAVES_ONLY) as $file)
- {
+ foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($testDir), RecursiveIteratorIterator::LEAVES_ONLY) as $file) {
if (strpos($file, '/.svn/') !== false)
continue;
if (substr($file->getFilename(), 0, 1) === '.')
@@ -24,6 +23,4 @@ class unitTestsTest extends PhraseanetPHPUnitAbstract
$this->assertRegExp('/[a-zA-Z0-9-_\.]+Test.php/', $file->getPathname(), 'Verify that all tests files names');
}
}
-
}
-
diff --git a/tests/userTest.php b/tests/userTest.php
index 51d18d20bd..a6f9ca37a9 100644
--- a/tests/userTest.php
+++ b/tests/userTest.php
@@ -8,8 +8,7 @@ class userTest extends PhraseanetPHPUnitAbstract
public function testMail()
{
$this->assertFalse(User_Adapter::get_usr_id_from_email(null));
- try
- {
+ try {
$appbox = appbox::get_instance(\bootstrap::getCore());
self::$user->set_email(null);
@@ -19,22 +18,16 @@ class userTest extends PhraseanetPHPUnitAbstract
$this->assertFalse(User_Adapter::get_usr_id_from_email(null));
self::$user->set_email('noone@example.com');
$this->assertEquals(self::$user->get_id(), User_Adapter::get_usr_id_from_email('noone@example.com'));
- }
- catch (Exception $e)
- {
+ } catch (Exception $e) {
$this->fail($e->getMessage());
}
- try
- {
+ try {
self::$user->set_email('noonealt1@example.com');
$this->fail('A user already got this address');
- }
- catch (Exception $e)
- {
+ } catch (Exception $e) {
}
$this->assertFalse(User_Adapter::get_usr_id_from_email(null));
}
-
}
diff --git a/tests/uuidTest.php b/tests/uuidTest.php
index 77106623c1..dc082a29e8 100644
--- a/tests/uuidTest.php
+++ b/tests/uuidTest.php
@@ -4,123 +4,115 @@ require_once __DIR__ . '/PhraseanetPHPUnitAbstract.class.inc';
class uuidTest extends PhraseanetPHPUnitAbstract
{
+ /**
+ * @var uuid
+ */
+ protected $object;
- /**
- * @var uuid
- */
- protected $object;
-
- public function setUp()
- {
- parent::setUp();
- $this->object = new uuid();
- }
-
- public function testGenerate_v3()
- {
- $datas = array();
- for ($i = 0; $i < 1000; $i++)
+ public function setUp()
{
- $uuid = uuid::generate_v4();
-
- if (!uuid::is_valid($uuid))
- $this->fail('Generation d\'un uuid v4 invalide');
-
- $uuid = uuid::generate_v3($uuid, random::generatePassword(12));
- if (!uuid::is_valid($uuid))
- $this->fail('Generation d\'un uuid v5 invalide');
-
- $datas[] = $uuid;
+ parent::setUp();
+ $this->object = new uuid();
}
- $datas = array_unique($datas);
-
- if (count($datas) !== 1000)
- $this->fail('Generation de deux uuid identiques en v3' . count($datas));
-
- unset($datas);
- }
-
- public function testGenerate_v4()
- {
- $datas = array();
- for ($i = 0; $i < 1000; $i++)
+ public function testGenerate_v3()
{
- $uuid = uuid::generate_v4();
+ $datas = array();
+ for ($i = 0; $i < 1000; $i ++ ) {
+ $uuid = uuid::generate_v4();
- if (!uuid::is_valid($uuid))
- $this->fail('Generation d\'un uuid v4 invalide');
+ if ( ! uuid::is_valid($uuid))
+ $this->fail('Generation d\'un uuid v4 invalide');
- $datas[] = $uuid;
+ $uuid = uuid::generate_v3($uuid, random::generatePassword(12));
+ if ( ! uuid::is_valid($uuid))
+ $this->fail('Generation d\'un uuid v5 invalide');
+
+ $datas[] = $uuid;
+ }
+
+ $datas = array_unique($datas);
+
+ if (count($datas) !== 1000)
+ $this->fail('Generation de deux uuid identiques en v3' . count($datas));
+
+ unset($datas);
}
- $datas = array_unique($datas);
-
- if (count($datas) !== 1000)
- $this->fail('Generation de deux uuid identiques en v4' . count($datas));
-
- unset($datas);
- }
-
- public function testGenerate_v5()
- {
- $datas = array();
- for ($i = 0; $i < 1000; $i++)
+ public function testGenerate_v4()
{
- $uuid = uuid::generate_v4();
+ $datas = array();
+ for ($i = 0; $i < 1000; $i ++ ) {
+ $uuid = uuid::generate_v4();
- if (!uuid::is_valid($uuid))
- $this->fail('Generation d\'un uuid v4 invalide');
+ if ( ! uuid::is_valid($uuid))
+ $this->fail('Generation d\'un uuid v4 invalide');
- $uuid = uuid::generate_v5($uuid, random::generatePassword(12));
- if (!uuid::is_valid($uuid))
- $this->fail('Generation d\'un uuid v5 invalide');
+ $datas[] = $uuid;
+ }
- $datas[] = $uuid;
+ $datas = array_unique($datas);
+
+ if (count($datas) !== 1000)
+ $this->fail('Generation de deux uuid identiques en v4' . count($datas));
+
+ unset($datas);
}
- $datas = array_unique($datas);
-
- if (count($datas) !== 1000)
- $this->fail('Generation de deux uuid identiques en v5' . count($datas));
-
- unset($datas);
- }
-
- public function testIs_valid()
- {
- for ($i = 0; $i < 1000; $i++)
+ public function testGenerate_v5()
{
- $uuid = uuid::generate_v4();
- if (!uuid::is_valid($uuid))
- $this->fail('Generation d\'un uuid v4 invalide');
+ $datas = array();
+ for ($i = 0; $i < 1000; $i ++ ) {
+ $uuid = uuid::generate_v4();
- $uuid = uuid::generate_v5($uuid, random::generatePassword(12));
- if (!uuid::is_valid($uuid))
- $this->fail('Generation d\'un uuid v5 invalide');
+ if ( ! uuid::is_valid($uuid))
+ $this->fail('Generation d\'un uuid v4 invalide');
- $uuid = uuid::generate_v3($uuid, random::generatePassword(12));
- if (!uuid::is_valid($uuid))
- $this->fail('Generation d\'un uuid v3 invalide');
+ $uuid = uuid::generate_v5($uuid, random::generatePassword(12));
+ if ( ! uuid::is_valid($uuid))
+ $this->fail('Generation d\'un uuid v5 invalide');
- unset($uuid);
+ $datas[] = $uuid;
+ }
+
+ $datas = array_unique($datas);
+
+ if (count($datas) !== 1000)
+ $this->fail('Generation de deux uuid identiques en v5' . count($datas));
+
+ unset($datas);
}
- }
- public function testCompare()
- {
- for ($i = 0; $i < 1000; $i++)
+ public function testIs_valid()
{
- $uuid1 = uuid::generate_v4();
- $uuid2 = uuid::generate_v4();
- $this->assertFalse(uuid::compare($uuid1, $uuid2));
+ for ($i = 0; $i < 1000; $i ++ ) {
+ $uuid = uuid::generate_v4();
+ if ( ! uuid::is_valid($uuid))
+ $this->fail('Generation d\'un uuid v4 invalide');
+
+ $uuid = uuid::generate_v5($uuid, random::generatePassword(12));
+ if ( ! uuid::is_valid($uuid))
+ $this->fail('Generation d\'un uuid v5 invalide');
+
+ $uuid = uuid::generate_v3($uuid, random::generatePassword(12));
+ if ( ! uuid::is_valid($uuid))
+ $this->fail('Generation d\'un uuid v3 invalide');
+
+ unset($uuid);
+ }
}
- }
- public function testIs_null()
- {
- $this->assertTrue(uuid::is_null('00000000-0000-0000-0000-000000000000'));
- }
+ public function testCompare()
+ {
+ for ($i = 0; $i < 1000; $i ++ ) {
+ $uuid1 = uuid::generate_v4();
+ $uuid2 = uuid::generate_v4();
+ $this->assertFalse(uuid::compare($uuid1, $uuid2));
+ }
+ }
+ public function testIs_null()
+ {
+ $this->assertTrue(uuid::is_null('00000000-0000-0000-0000-000000000000'));
+ }
}
-