Update Unit tests

This commit is contained in:
Romain Neutron
2012-05-12 02:22:19 +02:00
parent f74cf339aa
commit 4cf5adcd1e
57 changed files with 689 additions and 1638 deletions

View File

@@ -42,11 +42,11 @@ class system_file extends \SplFileInfo
, 'avi' => 'video/avi'
, 'bmp' => 'image/bmp'
, 'bz2' => 'application/x-bzip'
, 'cr2' => 'image/x-canon-cr2'
, '3fr' => 'image/x-tika-hasselblad'
, 'arw' => 'image/x-tika-sony'
, 'bay' => 'image/x-tika-casio'
, 'cap' => 'image/x-tika-phaseone'
, 'cr2' => 'image/x-tika-canon'
, 'crw' => 'image/x-tika-canon'
, 'dcs' => 'image/x-tika-kodak'
, 'dcr' => 'image/x-tika-kodak'
@@ -335,105 +335,32 @@ class system_file extends \SplFileInfo
*/
public function get_phrasea_type()
{
switch ($this->get_mime()) {
case 'image/png':
case 'image/gif':
case 'image/bmp':
case 'image/x-ms-bmp':
case 'image/jpeg':
case 'image/pjpeg':
case 'image/psd':
case 'image/photoshop':
case 'image/vnd.adobe.photoshop':
case 'image/ai':
case 'image/illustrator':
case 'image/vnd.adobe.illustrator':
case 'image/tiff':
case 'image/x-photoshop':
case 'application/postscript':
case 'image/x-tika-canon':
case 'image/x-canon-cr2':
case 'image/x-tika-casio':
case 'image/x-tika-dng':
case 'image/x-tika-epson':
case 'image/x-tika-fuji':
case 'image/x-tika-hasselblad':
case 'image/x-tika-imacon':
case 'image/x-tika-kodak':
case 'image/x-tika-leaf':
case 'image/x-tika-logitech':
case 'image/x-tika-mamiya':
case 'image/x-tika-minolta':
case 'image/x-tika-nikon':
case 'image/x-tika-olympus':
case 'image/x-tika-panasonic':
case 'image/x-tika-pentax':
case 'image/x-tika-phaseone':
case 'image/x-tika-rawzor':
case 'image/x-tika-red':
case 'image/x-tika-sigma':
case 'image/x-tika-sony':
case 'image/x-portable-pixmap':
switch (true) {
case strpos($this->get_mime(), 'image/') === 0:
case $this->get_mime() == 'application/postscript':
$type = 'image';
break;
case 'video/mpeg':
case 'video/mp4':
case 'video/x-ms-wmv':
case 'video/x-ms-wmx':
case 'video/avi':
case 'video/mp2p':
case 'video/mp4':
case 'video/x-ms-asf':
case 'video/quicktime':
case 'video/matroska':
case 'video/x-msvideo':
case 'video/x-ms-video':
case 'video/x-flv':
case 'video/avi':
case 'video/3gpp':
case 'video/x-m4v':
case 'application/vnd.rn-realmedia':
case strpos($this->get_mime(), 'video/') === 0:
case $this->get_mime() == 'application/vnd.rn-realmedia':
$type = 'video';
break;
case 'audio/aiff':
case 'audio/aiff':
case 'audio/x-mpegurl':
case 'audio/mid':
case 'audio/mid':
case 'audio/mpeg':
case 'audio/ogg':
case 'audio/mp4':
case 'audio/scpls':
case 'audio/vnd.rn-realaudio':
case 'audio/x-pn-realaudio':
case 'audio/wav':
case 'audio/x-wav':
case 'audio/x-ms-wma':
case 'audio/x-flac':
case strpos($this->get_mime(), 'audio/') === 0:
$type = 'audio';
break;
case 'text/plain':
case 'application/msword':
case 'application/access':
case 'application/pdf':
case 'application/excel':
case 'application/vnd.ms-powerpoint':
case 'application/vnd.oasis.opendocument.formula':
case 'application/vnd.oasis.opendocument.text-master':
case 'application/vnd.oasis.opendocument.database':
case 'application/vnd.oasis.opendocument.formula':
case 'application/vnd.oasis.opendocument.chart':
case 'application/vnd.oasis.opendocument.graphics':
case 'application/vnd.oasis.opendocument.presentation':
case 'application/vnd.oasis.opendocument.speadsheet':
case 'application/vnd.oasis.opendocument.text':
case strpos($this->get_mime(), 'application/vnd.oasis.opendocument') === 0:
case strpos($this->get_mime(), 'application/vnd.ms-') === 0:
case $this->get_mime() == 'text/plain':
case $this->get_mime() == 'application/msword':
case $this->get_mime() == 'application/access':
case $this->get_mime() == 'application/pdf':
case $this->get_mime() == 'application/excel':
$type = 'document';
break;
case 'application/x-shockwave-flash':
case $this->get_mime() == 'application/x-shockwave-flash':
$type = 'flash';
break;

View File

@@ -43,8 +43,6 @@ class ApiJsonApplication extends PhraseanetWebTestCaseAbstract
*/
protected static $adminApplication;
protected static $databoxe_ids = array();
protected static $need_records = 1;
protected static $need_subdefs = true;
public function setUp()
{
@@ -357,16 +355,9 @@ class ApiJsonApplication extends PhraseanetWebTestCaseAbstract
*/
public function testDataboxRecordRoute()
{
foreach (static::$databoxe_ids as $databox_id) {
$this->setToken(self::$token);
$databox = databox::get_instance($databox_id);
$collection = array_shift($databox->get_collections());
$system_file = new system_file(__DIR__ . '/../../../testfiles/cestlafete.jpg');
$record = record_adapter::create($collection, $system_file);
$record_id = $record->get_record_id();
$route = '/records/' . $databox_id . '/' . $record_id . '/';
$route = '/records/' . static::$records['record_1']->get_sbas_id() . '/' . static::$records['record_1']->get_record_id() . '/';
$this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE'));
$this->client->request('GET', $route);
$content = json_decode($this->client->getResponse()->getContent());
@@ -375,8 +366,7 @@ class ApiJsonApplication extends PhraseanetWebTestCaseAbstract
$this->evaluateMetaJson200($content);
$this->evaluateGoodRecord($content->response->record);
$record->delete();
}
$route = '/records/1234567890/1/';
$this->evaluateNotFoundRoute($route, array('GET'));
$this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE'));
@@ -629,28 +619,18 @@ class ApiJsonApplication extends PhraseanetWebTestCaseAbstract
public function testRecordsCaptionRoute()
{
$this->setToken(self::$token);
foreach (static::$databoxe_ids as $databox_id) {
$databox = databox::get_instance($databox_id);
$collection = array_shift($databox->get_collections());
$system_file = new system_file(__DIR__ . '/../../../testfiles/cestlafete.jpg');
$record = record_adapter::create($collection, $system_file);
$record_id = $record->get_record_id();
$route = '/records/' . $databox_id . '/' . $record_id . '/caption/';
$route = '/records/' . static::$records['record_1']->get_sbas_id() . '/' . static::$records['record_1']->get_record_id() . '/caption/';
$this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE'));
$crawler = $this->client->request('GET', $route);
$this->client->request('GET', $route);
$content = json_decode($this->client->getResponse()->getContent());
$this->evaluateResponse200($this->client->getResponse());
$this->evaluateMetaJson200($content);
$this->evaluateRecordsCaptionResponse($content);
$record->delete();
}
$route = '/records/24892534/51654651553/metadatas/';
$this->evaluateNotFoundRoute($route, array('GET'));
$this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE'));
@@ -662,17 +642,8 @@ class ApiJsonApplication extends PhraseanetWebTestCaseAbstract
public function testRecordsMetadatasRoute()
{
$this->setToken(self::$token);
foreach (static::$databoxe_ids as $databox_id) {
$databox = databox::get_instance($databox_id);
$collection = array_shift($databox->get_collections());
$system_file = new system_file(__DIR__ . '/../../../testfiles/cestlafete.jpg');
$record = record_adapter::create($collection, $system_file);
$record_id = $record->get_record_id();
$route = '/records/' . $databox_id . '/' . $record_id . '/metadatas/';
$route = '/records/' . static::$records['record_1']->get_sbas_id() . '/' . static::$records['record_1']->get_record_id() . '/metadatas/';
$this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE'));
$this->client->request('GET', $route);
@@ -682,8 +653,7 @@ class ApiJsonApplication extends PhraseanetWebTestCaseAbstract
$this->evaluateMetaJson200($content);
$this->evaluateRecordsMetadataResponse($content);
$record->delete();
}
$route = '/records/24892534/51654651553/metadatas/';
$this->evaluateNotFoundRoute($route, array('GET'));
$this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE'));
@@ -695,27 +665,18 @@ class ApiJsonApplication extends PhraseanetWebTestCaseAbstract
public function testRecordsStatusRoute()
{
$this->setToken(self::$token);
foreach (static::$databoxe_ids as $databox_id) {
$databox = databox::get_instance($databox_id);
$collection = array_shift($databox->get_collections());
$system_file = new system_file(__DIR__ . '/../../../testfiles/cestlafete.jpg');
$record = record_adapter::create($collection, $system_file);
$record_id = $record->get_record_id();
$route = '/records/' . $databox_id . '/' . $record_id . '/status/';
$route = '/records/' . static::$records['record_1']->get_sbas_id() . '/' . static::$records['record_1']->get_record_id() . '/status/';
$this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE'));
$crawler = $this->client->request('GET', $route);
$this->client->request('GET', $route);
$content = json_decode($this->client->getResponse()->getContent());
$this->evaluateResponse200($this->client->getResponse());
$this->evaluateMetaJson200($content);
$this->evaluateRecordsStatusResponse($record, $content);
$record->delete();
}
$this->evaluateRecordsStatusResponse(static::$records['record_1'], $content);
$route = '/records/24892534/51654651553/status/';
$this->evaluateNotFoundRoute($route, array('GET'));
$this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE'));
@@ -728,9 +689,9 @@ class ApiJsonApplication extends PhraseanetWebTestCaseAbstract
{
$this->setToken(self::$token);
$keys = array_keys(self::$record_1->get_subdefs());
$keys = array_keys(static::$records['record_1']->get_subdefs());
$route = '/records/' . self::$record_1->get_sbas_id() . '/' . self::$record_1->get_record_id() . '/embed/';
$route = '/records/' . static::$records['record_1']->get_sbas_id() . '/' . static::$records['record_1']->get_record_id() . '/embed/';
$this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE'));
$this->client->request('GET', $route);
@@ -742,7 +703,7 @@ class ApiJsonApplication extends PhraseanetWebTestCaseAbstract
foreach ($content->response as $embed) {
foreach ($keys as $key) {
$this->assertObjectHasAttribute($key, $embed);
$this->checkEmbed($key, $embed->$key, self::$record_1);
$this->checkEmbed($key, $embed->$key, static::$records['record_1']);
}
}
$route = '/records/24892534/51654651553/embed/';
@@ -757,7 +718,7 @@ class ApiJsonApplication extends PhraseanetWebTestCaseAbstract
{
$this->setToken(self::$token);
$route = '/records/' . self::$record_1->get_sbas_id() . '/' . self::$record_1->get_record_id() . '/embed/';
$route = '/records/' . static::$records['record_1']->get_sbas_id() . '/' . static::$records['record_1']->get_record_id() . '/embed/';
$this->client->request('GET', $route, array('mimes' => array('image/jpg', 'image/jpeg')));
$content = json_decode($this->client->getResponse()->getContent());
@@ -765,7 +726,7 @@ class ApiJsonApplication extends PhraseanetWebTestCaseAbstract
foreach ($content->response as $embed) {
foreach (array('thumbnail', 'preview') as $key) {
$this->assertObjectHasAttribute($key, $embed);
$this->checkEmbed($key, $embed->$key, self::$record_1);
$this->checkEmbed($key, $embed->$key, static::$records['record_1']);
}
}
}
@@ -774,7 +735,7 @@ class ApiJsonApplication extends PhraseanetWebTestCaseAbstract
{
$this->setToken(self::$token);
$route = '/records/' . self::$record_1->get_sbas_id() . '/' . self::$record_1->get_record_id() . '/embed/';
$route = '/records/' . static::$records['record_1']->get_sbas_id() . '/' . static::$records['record_1']->get_record_id() . '/embed/';
$this->client->request('GET', $route, array('devices' => array('nodevice')));
$content = json_decode($this->client->getResponse()->getContent());
@@ -872,19 +833,11 @@ class ApiJsonApplication extends PhraseanetWebTestCaseAbstract
public function testRecordsRelatedRoute()
{
$this->setToken(self::$token);
foreach (static::$databoxe_ids as $databox_id) {
$databox = databox::get_instance($databox_id);
$collection = array_shift($databox->get_collections());
$system_file = new system_file(__DIR__ . '/../../../testfiles/cestlafete.jpg');
$record = record_adapter::create($collection, $system_file);
$record_id = $record->get_record_id();
$route = '/records/' . $databox_id . '/' . $record_id . '/related/';
$route = '/records/' . static::$records['record_1']->get_sbas_id() . '/' . static::$records['record_1']->get_record_id() . '/related/';
$this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE'));
$crawler = $this->client->request('GET', $route);
$this->client->request('GET', $route);
$content = json_decode($this->client->getResponse()->getContent());
$this->evaluateResponse200($this->client->getResponse());
@@ -893,8 +846,7 @@ class ApiJsonApplication extends PhraseanetWebTestCaseAbstract
foreach ($content->response->baskets as $basket) {
$this->evaluateGoodBasket($basket);
}
$record->delete();
}
$route = '/records/24892534/51654651553/related/';
$this->evaluateNotFoundRoute($route, array('GET'));
$this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE'));
@@ -906,16 +858,10 @@ class ApiJsonApplication extends PhraseanetWebTestCaseAbstract
public function testRecordsSetMetadatas()
{
$this->setToken(self::$token);
foreach (static::$databoxe_ids as $databox_id) {
$databox = databox::get_instance($databox_id);
$collection = array_shift($databox->get_collections());
$system_file = new system_file(__DIR__ . '/../../../testfiles/cestlafete.jpg');
$record = record_adapter::create($collection, $system_file);
$record = record_adapter::create(self::$collection, __DIR__ . '/../../../testfiles/test001.CR2');
$record_id = $record->get_record_id();
$route = '/records/' . $databox_id . '/' . $record_id . '/setmetadatas/';
$route = '/records/' . $record->get_sbas_id() . '/' . $record->get_record_id() . '/setmetadatas/';
$caption = $record->get_caption();
$toupdate = array();
@@ -944,7 +890,6 @@ class ApiJsonApplication extends PhraseanetWebTestCaseAbstract
$this->evaluateResponse200($this->client->getResponse());
$this->evaluateMetaJson200($content);
$record = $databox->get_record($record_id);
$caption = $record->get_caption();
$this->assertEquals(count($caption->get_fields()), count(get_object_vars($content->response->metadatas)), 'Retrived metadatas are the same');
@@ -965,29 +910,16 @@ class ApiJsonApplication extends PhraseanetWebTestCaseAbstract
$saved_value = $toupdate[$metadata->meta_structure_id]['value'];
$this->assertEquals($saved_value, $metadata->value);
}
$record->delete();
}
}
public function testRecordsSetStatus()
{
$this->setToken(self::$token);
foreach (static::$databoxe_ids as $databox_id) {
$databox = databox::get_instance($databox_id);
$collection = array_shift($databox->get_collections());
$system_file = new system_file(__DIR__ . '/../../../testfiles/cestlafete.jpg');
if ( ! $collection instanceof \collection)
$this->fail('unable to find a collection');
$route = '/records/' . static::$records['record_1']->get_sbas_id() . '/' . static::$records['record_1']->get_record_id() . '/setstatus/';
$record = record_adapter::create($collection, $system_file);
$record_id = $record->get_record_id();
$route = '/records/' . $databox_id . '/' . $record_id . '/setstatus/';
$record_status = strrev($record->get_status());
$status_bits = $databox->get_statusbits();
$record_status = strrev(static::$records['record_1']->get_status());
$status_bits = static::$records['record_1']->get_databox()->get_statusbits();
$tochange = array();
foreach ($status_bits as $n => $datas) {
@@ -999,13 +931,17 @@ class ApiJsonApplication extends PhraseanetWebTestCaseAbstract
$crawler = $this->client->request('POST', $route, array('status' => $tochange));
$content = json_decode($this->client->getResponse()->getContent());
/**
* Get fresh record_1
*/
static::$records['record_1'] = static::$records['record_1']->get_databox()->get_record(static::$records['record_1']->get_record_id());
$this->evaluateResponse200($this->client->getResponse());
$this->evaluateMetaJson200($content);
$record = $databox->get_record($record_id);
$this->evaluateRecordsStatusResponse($record, $content);
$this->evaluateRecordsStatusResponse(static::$records['record_1'], $content);
$record_status = strrev($record->get_status());
$record_status = strrev(static::$records['record_1']->get_status());
foreach ($status_bits as $n => $datas) {
$this->assertEquals(substr($record_status, ($n - 1), 1), $tochange[$n]);
}
@@ -1018,39 +954,32 @@ class ApiJsonApplication extends PhraseanetWebTestCaseAbstract
$crawler = $this->client->request('POST', $route, array('status' => $tochange));
$content = json_decode($this->client->getResponse()->getContent());
/**
* Get fresh record_1
*/
static::$records['record_1'] = static::$records['record_1']->get_databox()->get_record(static::$records['record_1']->get_record_id());
$this->evaluateResponse200($this->client->getResponse());
$this->evaluateMetaJson200($content);
$record = $databox->get_record($record_id);
$this->evaluateRecordsStatusResponse($record, $content);
$this->evaluateRecordsStatusResponse(static::$records['record_1'], $content);
$record_status = strrev($record->get_status());
$record_status = strrev(static::$records['record_1']->get_status());
foreach ($status_bits as $n => $datas) {
$this->assertEquals(substr($record_status, ($n - 1), 1), $tochange[$n]);
}
$record->delete();
}
}
public function testMoveRecordToColleciton()
public function testMoveRecordToCollection()
{
$record = record_adapter::create(self::$collection, __DIR__ . '/../../../testfiles/test001.CR2');
$this->setToken(self::$token);
foreach (static::$databoxe_ids as $databox_id) {
$databox = databox::get_instance($databox_id);
$collection = array_shift($databox->get_collections());
$system_file = new system_file(__DIR__ . '/../../../testfiles/cestlafete.jpg');
if ( ! $collection instanceof \collection)
$this->fail('unable to find a collection');
$record = record_adapter::create($collection, $system_file);
$record_id = $record->get_record_id();
$route = '/records/' . $databox_id . '/' . $record_id . '/setcollection/';
$route = '/records/' . $record->get_sbas_id() . '/' . $record->get_record_id() . '/setcollection/';
$base_id = false;
foreach ($databox->get_collections() as $collection) {
foreach ($record->get_databox()->get_collections() as $collection) {
if ($collection->get_base_id() != $record->get_base_id()) {
$base_id = $collection->get_base_id();
break;
@@ -1067,9 +996,9 @@ class ApiJsonApplication extends PhraseanetWebTestCaseAbstract
$this->evaluateResponse200($this->client->getResponse());
$this->evaluateMetaJson200($content);
$record->delete();
}
}
public function testSearchBaskets()
{
@@ -1478,7 +1407,6 @@ class ApiJsonApplication extends PhraseanetWebTestCaseAbstract
{
$status = $record->get_databox()->get_statusbits();
$r_status = strrev($record->get_status());
$this->assertObjectHasAttribute('status', $content->response);
$this->assertEquals(count((array) $content->response->status), count($status));

View File

@@ -43,8 +43,6 @@ class ApiYamlApplication extends PhraseanetWebTestCaseAbstract
*/
protected static $adminApplication;
protected static $databoxe_ids = array();
protected static $need_records = 1;
protected static $need_subdefs = true;
/**
*
@@ -360,7 +358,7 @@ class ApiYamlApplication extends PhraseanetWebTestCaseAbstract
{
$this->setToken(self::$token);
$route = '/records/' . self::$record_1->get_sbas_id() . '/' . self::$record_1->get_record_id() . '/';
$route = '/records/' . static::$records['record_1']->get_sbas_id() . '/' . static::$records['record_1']->get_record_id() . '/';
$this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE'));
$this->client->request('GET', $route, array(), array(), array("HTTP_ACCEPT" => "application/yaml"));
$content = self::$yaml->parse($this->client->getResponse()->getContent());
@@ -628,7 +626,7 @@ class ApiYamlApplication extends PhraseanetWebTestCaseAbstract
{
$this->setToken(self::$token);
$route = '/records/' . self::$record_1->get_sbas_id() . '/' . self::$record_1->get_record_id() . '/caption/';
$route = '/records/' . static::$records['record_1']->get_sbas_id() . '/' . static::$records['record_1']->get_record_id() . '/caption/';
$this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE'));
$this->client->request('GET', $route, array(), array(), array("HTTP_ACCEPT" => "application/yaml"));
@@ -651,7 +649,7 @@ class ApiYamlApplication extends PhraseanetWebTestCaseAbstract
{
$this->setToken(self::$token);
$route = '/records/' . self::$record_1->get_sbas_id() . '/' . self::$record_1->get_record_id() . '/metadatas/';
$route = '/records/' . static::$records['record_1']->get_sbas_id() . '/' . static::$records['record_1']->get_record_id() . '/metadatas/';
$this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE'));
$this->client->request('GET', $route, array(), array(), array("HTTP_ACCEPT" => "application/yaml"));
@@ -674,7 +672,7 @@ class ApiYamlApplication extends PhraseanetWebTestCaseAbstract
{
$this->setToken(self::$token);
$route = '/records/' . self::$record_1->get_sbas_id() . '/' . self::$record_1->get_record_id() . '/status/';
$route = '/records/' . static::$records['record_1']->get_sbas_id() . '/' . static::$records['record_1']->get_record_id() . '/status/';
$this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE'));
$this->client->request('GET', $route, array(), array(), array("HTTP_ACCEPT" => "application/yaml"));
@@ -683,7 +681,7 @@ class ApiYamlApplication extends PhraseanetWebTestCaseAbstract
$this->evaluateResponse200($this->client->getResponse());
$this->evaluateMetaYaml200($content);
$this->evaluateRecordsStatusResponse(self::$record_1, $content);
$this->evaluateRecordsStatusResponse(static::$records['record_1'], $content);
$route = '/records/24892534/51654651553/status/';
$this->evaluateNotFoundRoute($route, array('GET'));
@@ -696,9 +694,9 @@ class ApiYamlApplication extends PhraseanetWebTestCaseAbstract
public function testRecordsEmbedRoute()
{
$this->setToken(self::$token);
$keys = array_keys(self::$record_1->get_subdefs());
$keys = array_keys(static::$records['record_1']->get_subdefs());
$route = '/records/' . self::$record_1->get_sbas_id() . '/' . self::$record_1->get_record_id() . '/embed/';
$route = '/records/' . static::$records['record_1']->get_sbas_id() . '/' . static::$records['record_1']->get_record_id() . '/embed/';
$this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE'));
$this->client->request('GET', $route, array(), array(), array("HTTP_ACCEPT" => "application/yaml"));
@@ -710,7 +708,7 @@ class ApiYamlApplication extends PhraseanetWebTestCaseAbstract
foreach ($content["response"] as $embed) {
foreach ($keys as $key) {
$this->assertArrayHasKey($key, $embed);
$this->checkEmbed($key, $embed[$key], self::$record_1);
$this->checkEmbed($key, $embed[$key], static::$records['record_1']);
}
}
$route = '/records/24892534/51654651553/embed/';
@@ -724,7 +722,7 @@ class ApiYamlApplication extends PhraseanetWebTestCaseAbstract
public function testRecordsEmbedRouteMime()
{
$this->setToken(self::$token);
$route = '/records/' . self::$record_1->get_sbas_id() . '/' . self::$record_1->get_record_id() . '/embed/';
$route = '/records/' . static::$records['record_1']->get_sbas_id() . '/' . static::$records['record_1']->get_record_id() . '/embed/';
$this->client->request('GET', $route, array('mimes' => array('image/jpg', 'image/jpeg')), array(), array("HTTP_ACCEPT" => "application/yaml"));
$content = self::$yaml->parse($this->client->getResponse()->getContent());
@@ -732,7 +730,7 @@ class ApiYamlApplication extends PhraseanetWebTestCaseAbstract
foreach ($content["response"] as $embed) {
foreach (array('thumbnail', 'preview') as $key) {
$this->assertArrayHasKey($key, $embed);
$this->checkEmbed($key, $embed[$key], self::$record_1);
$this->checkEmbed($key, $embed[$key], static::$records['record_1']);
}
}
}
@@ -740,7 +738,7 @@ class ApiYamlApplication extends PhraseanetWebTestCaseAbstract
public function testRecordsEmbedRouteDevices()
{
$this->setToken(self::$token);
$route = '/records/' . self::$record_1->get_sbas_id() . '/' . self::$record_1->get_record_id() . '/embed/';
$route = '/records/' . static::$records['record_1']->get_sbas_id() . '/' . static::$records['record_1']->get_record_id() . '/embed/';
$this->client->request('GET', $route, array('devices' => array('nodevice')), array(), array("HTTP_ACCEPT" => "application/yaml"));
$content = self::$yaml->parse($this->client->getResponse()->getContent());
@@ -840,7 +838,7 @@ class ApiYamlApplication extends PhraseanetWebTestCaseAbstract
{
$this->setToken(self::$token);
$route = '/records/' . self::$record_1->get_sbas_id() . '/' . self::$record_1->get_record_id() . '/related/';
$route = '/records/' . static::$records['record_1']->get_sbas_id() . '/' . static::$records['record_1']->get_record_id() . '/related/';
$this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE'));
$this->client->request('GET', $route, array(), array(), array("HTTP_ACCEPT" => "application/yaml"));
@@ -865,8 +863,10 @@ class ApiYamlApplication extends PhraseanetWebTestCaseAbstract
{
$this->setToken(self::$token);
$route = '/records/' . self::$record_1->get_sbas_id() . '/' . self::$record_1->get_record_id() . '/setmetadatas/';
$caption = self::$record_1->get_caption();
$record = record_adapter::create(self::$collection, __DIR__ . '/../../../testfiles/test001.CR2');
$route = '/records/' . $record->get_sbas_id() . '/' . $record->get_record_id() . '/setmetadatas/';
$caption = $record->get_caption();
$old_datas = array();
$toupdate = array();
@@ -878,19 +878,19 @@ class ApiYamlApplication extends PhraseanetWebTestCaseAbstract
foreach ($field->get_values() as $value) {
$old_datas[$value->getId()] = $value->getValue();
if ($field->is_readonly() === false && $field->is_multi() === false) {
$toupdate[$value->getId()] = array(
$toupdate[$field->get_meta_struct_id()] = array(
'meta_struct_id' => $field->get_meta_struct_id(),
'meta_id' => $value->getId(),
'value' => array($value->getValue() . ' test')
'value' => $value->getValue() . ' test'
);
}
}
}
foreach (self::$record_1->get_databox()->get_meta_structure()->get_elements() as $field) {
foreach ($record->get_databox()->get_meta_structure()->get_elements() as $field) {
try {
$values = self::$record_1->get_caption()->get_field($field->get_name())->get_values();
$values = $record->get_caption()->get_field($field->get_name())->get_values();
$value = array_pop($values);
$meta_id = $value->getId();
} catch (\Exception $e) {
@@ -912,7 +912,7 @@ class ApiYamlApplication extends PhraseanetWebTestCaseAbstract
$this->evaluateResponse200($this->client->getResponse());
$this->evaluateMetaYaml200($content);
$caption = self::$record_1->get_caption();
$caption = $record->get_caption();
$this->assertEquals(count($caption->get_fields()), count($content["response"]["metadatas"]));
@@ -932,16 +932,18 @@ class ApiYamlApplication extends PhraseanetWebTestCaseAbstract
$saved_value = $toupdate[$metadata["meta_structure_id"]]['value'];
$this->assertEquals($saved_value, $metadata["value"], "Asserting that " . $this->client->getResponse()->getContent() . " contains values");
}
$record->delete();
}
public function testRecordsSetStatus()
{
$this->setToken(self::$token);
$route = '/records/' . self::$record_1->get_sbas_id() . '/' . self::$record_1->get_record_id() . '/setstatus/';
$route = '/records/' . static::$records['record_1']->get_sbas_id() . '/' . static::$records['record_1']->get_record_id() . '/setstatus/';
$record_status = strrev(self::$record_1->get_status());
$status_bits = self::$record_1->get_databox()->get_statusbits();
$record_status = strrev(static::$records['record_1']->get_status());
$status_bits = static::$records['record_1']->get_databox()->get_statusbits();
$tochange = array();
foreach ($status_bits as $n => $datas) {
@@ -956,9 +958,14 @@ class ApiYamlApplication extends PhraseanetWebTestCaseAbstract
$this->evaluateResponse200($this->client->getResponse());
$this->evaluateMetaYaml200($content);
$this->evaluateRecordsStatusResponse(self::$record_1, $content);
/**
* Get fresh record_1
*/
static::$records['record_1'] = static::$records['record_1']->get_databox()->get_record(static::$records['record_1']->get_record_id());
$record_status = strrev(self::$record_1->get_status());
$this->evaluateRecordsStatusResponse(static::$records['record_1'], $content);
$record_status = strrev(static::$records['record_1']->get_status());
foreach ($status_bits as $n => $datas) {
$this->assertEquals(substr($record_status, ($n - 1), 1), $tochange[$n]);
}
@@ -974,23 +981,30 @@ class ApiYamlApplication extends PhraseanetWebTestCaseAbstract
$this->evaluateResponse200($this->client->getResponse());
$this->evaluateMetaYaml200($content);
$this->evaluateRecordsStatusResponse(self::$record_1, $content);
/**
* Get fresh record_1
*/
static::$records['record_1'] = static::$records['record_1']->get_databox()->get_record(static::$records['record_1']->get_record_id());
$record_status = strrev(self::$record_1->get_status());
$this->evaluateRecordsStatusResponse(static::$records['record_1'], $content);
$record_status = strrev(static::$records['record_1']->get_status());
foreach ($status_bits as $n => $datas) {
$this->assertEquals(substr($record_status, ($n - 1), 1), $tochange[$n]);
}
}
public function testMoveRecordToColleciton()
public function testMoveRecordToCollection()
{
$record = record_adapter::create(self::$collection, __DIR__ . '/../../../testfiles/test001.CR2');
$this->setToken(self::$token);
$route = '/records/' . self::$record_1->get_sbas_id() . '/' . self::$record_1->get_record_id() . '/setcollection/';
$route = '/records/' . $record->get_sbas_id() . '/' . $record->get_record_id() . '/setcollection/';
$base_id = false;
foreach (self::$record_1->get_databox()->get_collections() as $collection) {
if ($collection->get_base_id() != self::$record_1->get_base_id()) {
foreach ($record->get_databox()->get_collections() as $collection) {
if ($collection->get_base_id() != $record->get_base_id()) {
$base_id = $collection->get_base_id();
break;
}
@@ -1007,6 +1021,8 @@ class ApiYamlApplication extends PhraseanetWebTestCaseAbstract
$this->evaluateResponse200($this->client->getResponse());
$this->evaluateMetaYaml200($content);
$record->delete();
}
public function testSearchBaskets()
@@ -1400,12 +1416,12 @@ class ApiYamlApplication extends PhraseanetWebTestCaseAbstract
{
foreach ($content["response"] as $field) {
$this->assertTrue(is_array($field), 'Un bloc field est un objet');
$this->assertArrayHasKey('meta_structure_id', $meta);
$this->assertArrayHasKey('meta_structure_id', $field);
$this->assertTrue(is_int($field["meta_structure_id"]));
$this->assertArrayHasKey('name', $field);
$this->assertTrue(is_string($meta["name"]));
$this->assertTrue(is_string($field["name"]));
$this->assertArrayHasKey('value', $field);
$this->assertTrue(is_string($meta["value"]));
$this->assertTrue(is_string($field["value"]));
}
}

View File

@@ -12,7 +12,6 @@ class ApplicationLightboxTest extends PhraseanetWebTestCaseAuthenticatedAbstract
protected $entry;
protected $item;
protected $validation_basket;
protected static $need_records = 1;
public function setUp()
{
@@ -22,7 +21,7 @@ class ApplicationLightboxTest extends PhraseanetWebTestCaseAuthenticatedAbstract
$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);
$this->item = Feed_Entry_Item::create($appbox, $this->entry, static::$records['record_1']);
}
public function tearDown()

View File

@@ -8,9 +8,6 @@ use Symfony\Component\HttpFoundation\Response;
class ApplicationOverviewTest extends PhraseanetWebTestCaseAuthenticatedAbstract
{
protected static $need_records = 1;
protected static $need_subdefs = true;
public function setUp()
{
parent::setUp();
@@ -25,24 +22,24 @@ class ApplicationOverviewTest extends PhraseanetWebTestCaseAuthenticatedAbstract
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/');
$crawler = $this->client->request('GET', '/datafiles/' . static::$records['record_1']->get_sbas_id() . '/' . static::$records['record_1']->get_record_id() . '/preview/');
$response = $this->client->getResponse();
if (self::$record_1->get_preview()->get_baseurl() !== '') {
if (static::$records['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']);
$this->assertEquals(static::$records['record_1']->get_preview()->get_mime(), $headers['content_type']);
$this->assertEquals(static::$records['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'));
$this->assertEquals(static::$records['record_1']->get_preview()->get_mime(), $response->headers->get('content-type'));
$this->assertEquals(static::$records['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/');
$crawler = $this->client->request('GET', '/datafiles/' . static::$records['record_1']->get_sbas_id() . '/' . static::$records['record_1']->get_record_id() . '/asubdefthatdoesnotexists/');
$response = $this->client->getResponse();
$this->assertEquals(404, $response->getStatusCode());
@@ -52,11 +49,11 @@ class ApplicationOverviewTest extends PhraseanetWebTestCaseAuthenticatedAbstract
{
$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/');
$crawler = $this->client->request('GET', '/datafiles/' . static::$records['record_1']->get_sbas_id() . '/' . static::$records['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/');
$crawler = $this->client->request('GET', '/datafiles/' . static::$records['record_1']->get_sbas_id() . '/' . static::$records['record_1']->get_record_id() . '/notfoundreview/');
$response = $this->client->getResponse();
$this->assertEquals(403, $response->getStatusCode());
}
@@ -78,13 +75,13 @@ class ApplicationOverviewTest extends PhraseanetWebTestCaseAuthenticatedAbstract
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/';
$token = static::$records['record_1']->get_preview()->get_permalink()->get_token();
$url = '/permalink/v1/whateverIwannt/' . static::$records['record_1']->get_sbas_id() . '/' . static::$records['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() !== '') {
if (static::$records['record_1']->get_preview()->get_baseurl() !== '') {
$this->assertEquals(302, $response->getStatusCode());
} else {
$this->assertEquals(200, $response->getStatusCode());

View File

@@ -8,7 +8,6 @@ use Symfony\Component\HttpFoundation\Response;
class ApplicationRootTest extends PhraseanetWebTestCaseAuthenticatedAbstract
{
protected $client;
protected static $need_records = false;
public function createApplication()
{

View File

@@ -6,9 +6,6 @@ require_once __DIR__ . '/../../../../PhraseanetPHPUnitAbstract.class.inc';
class FactoryTest extends \PhraseanetPHPUnitAbstract
{
protected static $need_records = 1;
protected static $need_story = 1;
/**
* @covers Alchemy\Phrasea\Border\Attribute\Factory::getFileAttribute
*/
@@ -38,7 +35,7 @@ class FactoryTest extends \PhraseanetPHPUnitAbstract
*/
public function testGetFileAttributeStory()
{
$attribute = Factory::getFileAttribute(Attribute::NAME_STORY, static::$story_1->get_serialize_key());
$attribute = Factory::getFileAttribute(Attribute::NAME_STORY, static::$records['record_story_1']->get_serialize_key());
$this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Attribute\\Story', $attribute);
}
@@ -49,7 +46,7 @@ class FactoryTest extends \PhraseanetPHPUnitAbstract
*/
public function testGetFileAttributeStoryFailsRecord()
{
Factory::getFileAttribute(Attribute::NAME_STORY, self::$record_1->get_serialize_key());
Factory::getFileAttribute(Attribute::NAME_STORY, static::$records['record_1']->get_serialize_key());
}
/**

View File

@@ -10,8 +10,6 @@ class StoryTest extends \PhraseanetPHPUnitAbstract
* @var Story
*/
protected $object;
protected static $need_story = 1;
protected static $need_records = 1;
/**
* @covers Alchemy\Phrasea\Border\Attribute\Story::__construct
@@ -19,7 +17,7 @@ class StoryTest extends \PhraseanetPHPUnitAbstract
public function setUp()
{
parent::setUp();
$this->object = new Story(self::$story_1);
$this->object = new Story(static::$records['record_story_1']);
}
/**
@@ -45,7 +43,7 @@ class StoryTest extends \PhraseanetPHPUnitAbstract
*/
public function testGetValue()
{
$this->assertSame(self::$story_1, $this->object->getValue());
$this->assertSame(static::$records['record_story_1'], $this->object->getValue());
}
/**
@@ -72,7 +70,7 @@ class StoryTest extends \PhraseanetPHPUnitAbstract
*/
public function testLoadFromStringWrongElement()
{
Story::loadFromString(self::$record_1->get_serialize_key());
Story::loadFromString(static::$records['record_1']->get_serialize_key());
}
/**

View File

@@ -13,7 +13,6 @@ class FilenameTest extends \PhraseanetPHPUnitAbstract
*/
protected $object;
protected $filename;
protected static $need_records = 1;
public function setUp()
{
@@ -61,6 +60,8 @@ class FilenameTest extends \PhraseanetPHPUnitAbstract
$this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Checker\\Response', $response);
$this->assertTrue($response->isOk());
$mock = null;
}
/**

View File

@@ -13,7 +13,6 @@ class Sha256Test extends \PhraseanetPHPUnitAbstract
*/
protected $object;
protected $filename;
protected static $need_records = 1;
public function setUp()
{

View File

@@ -13,12 +13,7 @@ class UUIDTest extends \PhraseanetPHPUnitAbstract
*/
protected $object;
protected $filename;
protected static $need_records = 1;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
public function setUp()
{
parent::setUp();

View File

@@ -5,7 +5,6 @@ require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.
class DescriptionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
protected $client;
protected static $need_records = false;
public function createApplication()
{

View File

@@ -5,7 +5,6 @@ require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.
class ControllerFieldsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
protected $client;
protected static $need_records = false;
public function createApplication()
{

View File

@@ -5,7 +5,6 @@ require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.
class RootTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
protected $client;
protected static $need_records = false;
public function createApplication()
{

View File

@@ -5,7 +5,6 @@ require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.
class ControllerSubdefsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
protected $client;
protected static $need_records = false;
public function createApplication()
{

View File

@@ -5,8 +5,6 @@ require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.
class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
protected $client;
protected static $need_records = false;
protected $usersParameters;
public function createApplication()

View File

@@ -26,17 +26,6 @@ class BoilerPlate extends \PhraseanetWebTestCaseAbstract
*/
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
*/

View File

@@ -8,7 +8,6 @@ use Alchemy\Phrasea\RouteProcessor as routeProcessor;
class ControllerBasketTest extends PhraseanetWebTestCaseAuthenticatedAbstract
{
protected $client;
protected static $need_records = 2;
public function setUp()
{
@@ -23,14 +22,16 @@ class ControllerBasketTest extends PhraseanetWebTestCaseAuthenticatedAbstract
public function testRootPost()
{
static::$records['record_1'];
static::$records['record_2'];
$route = '/baskets/';
$records = array(
self::$record_1->get_serialize_key(),
self::$record_2->get_serialize_key(),
static::$records['record_1']->get_serialize_key(),
static::$records['record_2']->get_serialize_key(),
' ',
'42',
self::$record_no_access->get_serialize_key()
static::$records['record_no_access']->get_serialize_key()
);
$lst = implode(';', $records);
@@ -134,7 +135,7 @@ class ControllerBasketTest extends PhraseanetWebTestCaseAuthenticatedAbstract
$basket = $this->insertOneBasket();
$record = self::$record_1;
$record = static::$records['record_1'];
$basket_element = new \Entities\BasketElement();
$basket_element->setBasket($basket);
@@ -172,7 +173,7 @@ class ControllerBasketTest extends PhraseanetWebTestCaseAuthenticatedAbstract
$basket = $this->insertOneBasket();
$record = self::$record_1;
$record = static::$records['record_1'];
$basket_element = new \Entities\BasketElement();
$basket_element->setBasket($basket);
@@ -421,17 +422,17 @@ class ControllerBasketTest extends PhraseanetWebTestCaseAuthenticatedAbstract
$route = sprintf('/baskets/%s/addElements/', $basket->getId());
$records = array(
self::$record_1->get_serialize_key(),
self::$record_2->get_serialize_key(),
static::$records['record_1']->get_serialize_key(),
static::$records['record_2']->get_serialize_key(),
' ',
'42',
'abhak',
self::$record_no_access->get_serialize_key(),
static::$records['record_no_access']->get_serialize_key(),
);
$lst = implode(';', $records);
$crawler = $this->client->request('POST', $route, array('lst' => $lst));
$this->client->request('POST', $route, array('lst' => $lst));
$response = $this->client->getResponse();
@@ -484,12 +485,12 @@ class ControllerBasketTest extends PhraseanetWebTestCaseAuthenticatedAbstract
$route = sprintf('/baskets/%s/addElements/', $basket->getId());
$records = array(
self::$record_1->get_serialize_key(),
self::$record_2->get_serialize_key(),
static::$records['record_1']->get_serialize_key(),
static::$records['record_2']->get_serialize_key(),
' ',
'42',
'abhak',
self::$record_no_access->get_serialize_key(),
static::$records['record_no_access']->get_serialize_key(),
);
$lst = implode(';', $records);
@@ -518,8 +519,8 @@ class ControllerBasketTest extends PhraseanetWebTestCaseAuthenticatedAbstract
$route = sprintf('/baskets/%s/addElements/', $basket->getId());
$records = array(
self::$record_1->get_serialize_key(),
self::$record_2->get_serialize_key()
static::$records['record_1']->get_serialize_key(),
static::$records['record_2']->get_serialize_key()
);
$lst = implode(';', $records);

View File

@@ -11,7 +11,6 @@ class BridgeApplication extends PhraseanetWebTestCaseAuthenticatedAbstract
public static $account = null;
public static $api = null;
protected $client;
protected static $need_records = 1;
public function setUp()
{
@@ -389,7 +388,7 @@ class BridgeApplication extends PhraseanetWebTestCaseAuthenticatedAbstract
$this->assertTrue($response->isOk());
$records = array(
self::$record_1->get_serialize_key()
static::$records['record_1']->get_serialize_key()
);
Bridge_Api_Apitest::$hasError = true;

View File

@@ -5,7 +5,6 @@ require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.
class ControllerEditTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
protected $client;
protected static $need_records = 1;
public function createApplication()
{
@@ -23,7 +22,7 @@ class ControllerEditTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
*/
public function testRouteSlash()
{
$this->client->request('POST', '/records/edit/', array('lst' => self::$record_1->get_serialize_key()));
$this->client->request('POST', '/records/edit/', array('lst' => static::$records['record_1']->get_serialize_key()));
$response = $this->client->getResponse();
@@ -32,7 +31,7 @@ class ControllerEditTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
public function testApply()
{
$this->client->request('POST', '/records/edit/apply/', array('lst' => self::$record_1->get_serialize_key()));
$this->client->request('POST', '/records/edit/apply/', array('lst' => static::$records['record_1']->get_serialize_key()));
$response = $this->client->getResponse();

View File

@@ -37,8 +37,6 @@ class ControllerFeedApp extends \PhraseanetWebTestCaseAuthenticatedAbstract
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()
{
@@ -76,7 +74,7 @@ class ControllerFeedApp extends \PhraseanetWebTestCaseAuthenticatedAbstract
, $this->entry_authormail
);
$this->item = Feed_Entry_Item::create($appbox, $this->entry, self::$record_1);
$this->item = Feed_Entry_Item::create($appbox, $this->entry, static::$records['record_1']);
}
public function tearDown()
@@ -119,7 +117,7 @@ class ControllerFeedApp extends \PhraseanetWebTestCaseAuthenticatedAbstract
, "subtitle" => "coucou"
, "author_name" => "robert"
, "author_email" => "robert@kikoo.mail"
, 'lst' => self::$record_1->get_serialize_key()
, 'lst' => static::$records['record_1']->get_serialize_key()
);
$crawler = $this->client->request('POST', '/feeds/entry/create/', $params);
@@ -139,7 +137,7 @@ class ControllerFeedApp extends \PhraseanetWebTestCaseAuthenticatedAbstract
, "subtitle" => "coucou"
, "author_name" => "robert"
, "author_email" => "robert@kikoo.mail"
, 'lst' => self::$record_1->get_serialize_key()
, 'lst' => static::$records['record_1']->get_serialize_key()
);
$crawler = $this->client->request('POST', '/feeds/entry/create/', $params);
$this->assertTrue($this->client->getResponse()->isOk());
@@ -210,7 +208,7 @@ class ControllerFeedApp extends \PhraseanetWebTestCaseAuthenticatedAbstract
, "subtitle" => "cat"
, "author_name" => "bird"
, "author_email" => "mouse"
, 'lst' => self::$record_1->get_serialize_key()
, 'lst' => static::$records['record_1']->get_serialize_key()
);
$crawler = $this->client->request('POST', '/feeds/entry/' . $this->entry->get_id() . '/update/', $params);
@@ -234,7 +232,7 @@ class ControllerFeedApp extends \PhraseanetWebTestCaseAuthenticatedAbstract
, "subtitle" => "cat"
, "author_name" => "bird"
, "author_email" => "mouse"
, 'lst' => self::$record_1->get_serialize_key()
, 'lst' => static::$records['record_1']->get_serialize_key()
);
$crawler = $this->client->request('POST', '/feeds/entry/99999999/update/', $params);
@@ -260,7 +258,7 @@ class ControllerFeedApp extends \PhraseanetWebTestCaseAuthenticatedAbstract
, "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"
, 'sorted_lst' => static::$records['record_1']->get_serialize_key() . ";" . static::$records['record_2']->get_serialize_key() . ";12345;" . "unknow_unknow"
);
$crawler = $this->client->request('POST', '/feeds/entry/' . $this->entry->get_id() . '/update/', $params);
@@ -285,7 +283,7 @@ class ControllerFeedApp extends \PhraseanetWebTestCaseAuthenticatedAbstract
$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);
$item = Feed_Entry_Item::create($appbox, $entry, static::$records['record_1']);
$params = array(
"feed_id" => $feed->get_id()
@@ -293,7 +291,7 @@ class ControllerFeedApp extends \PhraseanetWebTestCaseAuthenticatedAbstract
, "subtitle" => "cat"
, "author_name" => "bird"
, "author_email" => "mouse"
, 'lst' => self::$record_1->get_serialize_key()
, 'lst' => static::$records['record_1']->get_serialize_key()
);
$crawler = $this->client->request('POST', '/feeds/entry/' . $entry->get_id() . '/update/', $params);
@@ -361,7 +359,7 @@ class ControllerFeedApp extends \PhraseanetWebTestCaseAuthenticatedAbstract
$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);
$item = Feed_Entry_Item::create($appbox, $entry, static::$records['record_1']);
$crawler = $this->client->request('POST', '/feeds/entry/' . $entry->get_id() . '/delete/');

View File

@@ -5,7 +5,6 @@ require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.
class ControllerMoveCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
protected $client;
protected static $need_records = 1;
public function createApplication()
{
@@ -23,7 +22,7 @@ class ControllerMoveCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAb
*/
public function testRouteSlash()
{
$this->client->request('POST', '/records/movecollection/', array('lst' => self::$record_1->get_serialize_key()));
$this->client->request('POST', '/records/movecollection/', array('lst' => static::$records['record_1']->get_serialize_key()));
$response = $this->client->getResponse();
@@ -33,7 +32,7 @@ class ControllerMoveCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAb
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()));
$this->client->request('POST', '/records/movecollection/apply/', array('lst' => static::$records['record_1']->get_serialize_key(), 'base_id' => self::$collection->get_base_id()));
$response = $this->client->getResponse();

View File

@@ -5,7 +5,6 @@ require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.
class ControllerPrinterTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
protected $client;
protected static $need_records = 4;
public function createApplication()
{
@@ -24,8 +23,8 @@ class ControllerPrinterTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
public function testRouteSlash()
{
$records = array(
self::$record_1->get_serialize_key(),
self::$record_2->get_serialize_key()
static::$records['record_1']->get_serialize_key(),
static::$records['record_2']->get_serialize_key()
);
$lst = implode(';', $records);
@@ -40,10 +39,10 @@ class ControllerPrinterTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
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(),
static::$records['record_1']->get_serialize_key(),
static::$records['record_2']->get_serialize_key(),
static::$records['record_3']->get_serialize_key(),
static::$records['record_4']->get_serialize_key(),
);
$lst = implode(';', $records);

View File

@@ -5,7 +5,6 @@ require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.
class ControllerPushTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
protected $client;
protected static $need_records = 2;
public function createApplication()
{
@@ -50,8 +49,8 @@ class ControllerPushTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$route = '/push/send/';
$records = array(
self::$record_1->get_serialize_key()
, self::$record_2->get_serialize_key()
static::$records['record_1']->get_serialize_key(),
static::$records['record_2']->get_serialize_key(),
);
$receivers = array(
@@ -84,8 +83,8 @@ class ControllerPushTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$route = '/push/validate/';
$records = array(
self::$record_1->get_serialize_key()
, self::$record_2->get_serialize_key()
static::$records['record_1']->get_serialize_key(),
static::$records['record_2']->get_serialize_key(),
);
$participants = array(

View File

@@ -5,7 +5,6 @@ require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.
class ControllerRootTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
protected $client;
protected static $need_records = false;
public function createApplication()
{

View File

@@ -12,13 +12,6 @@ class ControllerStoryTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
protected $client;
/**
*
* @var \record_adapter
*/
protected static $need_story = true;
protected static $need_records = 2;
public function setUp()
{
parent::setUp();
@@ -105,7 +98,7 @@ class ControllerStoryTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
public function testByIds()
{
$story = self::$story_1;
$story = static::$records['record_story_1'];
$route = sprintf("/story/%d/%d/", $story->get_sbas_id(), $story->get_record_id());
@@ -118,13 +111,13 @@ class ControllerStoryTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
public function testAddElementsToStory()
{
$story = self::$story_1;
$story = static::$records['record_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()
static::$records['record_1']->get_serialize_key(),
static::$records['record_2']->get_serialize_key()
);
$lst = implode(';', $records);
@@ -135,18 +128,18 @@ class ControllerStoryTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->assertEquals(302, $response->getStatusCode());
$this->assertEquals(2, self::$story_1->get_children()->get_count());
$this->assertEquals(2, static::$records['record_story_1']->get_children()->get_count());
}
public function testAddElementsToStoryJSON()
{
$story = self::$story_1;
$story = static::$records['record_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()
static::$records['record_1']->get_serialize_key(),
static::$records['record_2']->get_serialize_key()
);
$lst = implode(';', $records);
@@ -159,16 +152,16 @@ class ControllerStoryTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(2, self::$story_1->get_children()->get_count());
$this->assertEquals(2, static::$records['record_story_1']->get_children()->get_count());
}
public function testRemoveElementFromStory()
{
$story = self::$story_1;
$story = static::$records['record_story_1'];
$records = array(
self::$record_1,
self::$record_2
static::$records['record_1'],
static::$records['record_2']
);
$totalRecords = count($records);
@@ -200,7 +193,7 @@ class ControllerStoryTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
}
$n ++;
$this->assertEquals($totalRecords - $n, self::$story_1->get_children()->get_count());
$this->assertEquals($totalRecords - $n, static::$records['record_story_1']->get_children()->get_count());
}
}
}

View File

@@ -10,9 +10,6 @@ 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;
public function setUp()
{
@@ -46,8 +43,8 @@ class ControllerTooltipTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
public function testRoutePreview()
{
$route = '/tooltip/preview/' . self::$record_1->get_sbas_id()
. '/' . self::$record_1->get_record_id() . '/';
$route = '/tooltip/preview/' . static::$records['record_1']->get_sbas_id()
. '/' . static::$records['record_1']->get_record_id() . '/';
$crawler = $this->client->request('POST', $route);
$pageContent = $this->client->getResponse()->getContent();
@@ -57,8 +54,8 @@ class ControllerTooltipTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
public function testRouteCaption()
{
$route_base = '/tooltip/caption/' . self::$record_1->get_sbas_id()
. '/' . self::$record_1->get_record_id() . '/%s/';
$route_base = '/tooltip/caption/' . static::$records['record_1']->get_sbas_id()
. '/' . static::$records['record_1']->get_record_id() . '/%s/';
$routes = array(
sprintf($route_base, 'answer')
@@ -77,8 +74,8 @@ class ControllerTooltipTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
public function testRouteCaptionSearchEngine()
{
$route_base = '/tooltip/caption/' . self::$record_1->get_sbas_id()
. '/' . self::$record_1->get_record_id() . '/%s/';
$route_base = '/tooltip/caption/' . static::$records['record_1']->get_sbas_id()
. '/' . static::$records['record_1']->get_record_id() . '/%s/';
$routes = array(
sprintf($route_base, 'answer')
@@ -98,8 +95,8 @@ class ControllerTooltipTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
public function testRouteTCDatas()
{
$route = '/tooltip/tc_datas/' . self::$record_1->get_sbas_id()
. '/' . self::$record_1->get_record_id() . '/';
$route = '/tooltip/tc_datas/' . static::$records['record_1']->get_sbas_id()
. '/' . static::$records['record_1']->get_record_id() . '/';
$crawler = $this->client->request('POST', $route);
$pageContent = $this->client->getResponse()->getContent();
@@ -108,7 +105,7 @@ class ControllerTooltipTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
public function testRouteMetasFieldInfos()
{
$databox = self::$record_1->get_databox();
$databox = static::$records['record_1']->get_databox();
foreach ($databox->get_meta_structure() as $field) {
$route = '/tooltip/metas/FieldInfos/' . $databox->get_sbas_id()
@@ -122,7 +119,7 @@ class ControllerTooltipTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
public function testRouteMetasDCESInfos()
{
$databox = self::$record_1->get_databox();
$databox = static::$records['record_1']->get_databox();
$dces = array(
databox_field::DCES_CONTRIBUTOR => new databox_Field_DCES_Contributor()
, databox_field::DCES_COVERAGE => new databox_Field_DCES_Coverage()
@@ -151,7 +148,7 @@ class ControllerTooltipTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
public function testRouteMetaRestrictions()
{
$databox = self::$record_1->get_databox();
$databox = static::$records['record_1']->get_databox();
foreach ($databox->get_meta_structure() as $field) {
@@ -166,11 +163,11 @@ class ControllerTooltipTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
public function testRouteStory()
{
$databox = self::$story_1->get_databox();
$databox = static::$records['record_story_1']->get_databox();
$route = '/tooltip/Story/' . $databox->get_sbas_id()
. '/' . self::$story_1->get_record_id() . '/';
. '/' . static::$records['record_story_1']->get_record_id() . '/';
$this->client->request('POST', $route);
$this->assertTrue($this->client->getResponse()->isOk());

View File

@@ -5,7 +5,6 @@ require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.
class ControllerUsrListsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
protected $client;
protected static $need_records = false;
public function createApplication()
{

View File

@@ -8,8 +8,6 @@ use Alchemy\Phrasea\RouteProcessor as routeProcessor;
class ControllerWorkZoneTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
protected $client;
protected static $need_records = 1;
protected static $need_story = true;
public function setUp()
{
@@ -39,7 +37,7 @@ class ControllerWorkZoneTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
public function testAttachStoryToWZ()
{
$story = self::$story_1;
$story = static::$records['record_story_1'];
/* @var $story \Record_Adapter */
$route = sprintf("/WorkZone/attachStories/");
@@ -64,7 +62,7 @@ class ControllerWorkZoneTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->assertEquals(1, $count);
$story2 = self::$story_2;
$story2 = static::$records['record_story_2'];
$stories = array($story->get_serialize_key(), $story2->get_serialize_key());
@@ -116,7 +114,7 @@ class ControllerWorkZoneTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
public function testDetachStoryFromWZ()
{
$story = self::$story_1;
$story = static::$records['record_story_1'];
$route = sprintf("/WorkZone/detachStory/%s/%s/", $story->get_sbas_id(), $story->get_record_id());
//story not yet Attched
@@ -188,7 +186,7 @@ class ControllerWorkZoneTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
public function testDetachStoryFromWZNotFound()
{
$story = self::$story_1;
$story = static::$records['record_story_1'];
$route = sprintf("/WorkZone/detachStory/%s/%s/", $story->get_sbas_id(), 'unknow');
//story not yet Attched

View File

@@ -71,8 +71,6 @@ class ControllerRssFeedTest extends \PhraseanetWebTestCaseAbstract
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()
@@ -82,8 +80,8 @@ class ControllerRssFeedTest extends \PhraseanetWebTestCaseAbstract
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);
Feed_Entry_Item::create(appbox::get_instance(\bootstrap::getCore()), self::$entry, static::$records['record_1']);
Feed_Entry_Item::create(appbox::get_instance(\bootstrap::getCore()), self::$entry, static::$records['record_2']);
self::$feed->set_public(true);
}
@@ -127,47 +125,32 @@ class ControllerRssFeedTest extends \PhraseanetWebTestCaseAbstract
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);
$item = Feed_Entry_Item::create($appbox, $entry, static::$records['record_1']);
$item = Feed_Entry_Item::create($appbox, $entry, static::$records['record_6']);
$item = Feed_Entry_Item::create($appbox, $entry, static::$records['record_7']);
$item = Feed_Entry_Item::create($appbox, $entry, static::$records['record_8']);
$item = Feed_Entry_Item::create($appbox, $entry, static::$records['record_9']);
$item = Feed_Entry_Item::create($appbox, $entry, static::$records['record_10']);
$item = Feed_Entry_Item::create($appbox, $entry, static::$records['record_1']);
$item = Feed_Entry_Item::create($appbox, $entry, static::$records['record_13']);
$item = Feed_Entry_Item::create($appbox, $entry, static::$records['record_15']);
$item = Feed_Entry_Item::create($appbox, $entry, static::$records['record_16']);
$item = Feed_Entry_Item::create($appbox, $entry, static::$records['record_19']);
$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);
$item = Feed_Entry_Item::create($appbox, $entry, static::$records['record_1']);
$item = Feed_Entry_Item::create($appbox, $entry, static::$records['record_6']);
$item = Feed_Entry_Item::create($appbox, $entry, static::$records['record_7']);
$item = Feed_Entry_Item::create($appbox, $entry, static::$records['record_8']);
$item = Feed_Entry_Item::create($appbox, $entry, static::$records['record_9']);
$item = Feed_Entry_Item::create($appbox, $entry, static::$records['record_10']);
$item = Feed_Entry_Item::create($appbox, $entry, static::$records['record_1']);
$item = Feed_Entry_Item::create($appbox, $entry, static::$records['record_13']);
$item = Feed_Entry_Item::create($appbox, $entry, static::$records['record_15']);
$item = Feed_Entry_Item::create($appbox, $entry, static::$records['record_16']);
$item = Feed_Entry_Item::create($appbox, $entry, static::$records['record_19']);
self::$feed_4_entries[] = $entry;
}

View File

@@ -9,17 +9,6 @@ class ControllerInstallerTest extends \PhraseanetWebTestCaseAbstract
*/
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
*/

View File

@@ -9,20 +9,6 @@ class ControllerUpgraderTest extends \PhraseanetWebTestCaseAbstract
*/
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__ . '/FakeUpgradeApplication.inc';

View File

@@ -9,17 +9,6 @@ class ControllerConnectionTestTest extends \PhraseanetWebTestCaseAbstract
*/
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
*/

View File

@@ -9,17 +9,6 @@ class ControllerPathFileTestTest extends \PhraseanetWebTestCaseAbstract
*/
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
*/

View File

@@ -42,29 +42,32 @@ class ConfigurationTest extends \PhraseanetPHPUnitAbstract
* @var \Alchemy\Phrasea\Core\Configuration
*/
protected $object;
protected $stubNotInstalled;
protected $stubExperience;
protected $stubConfTest;
public function setUp()
{
$this->markTestSkipped('To rewrite');
parent::setUp();
$specNotInstalled = $this->getMock(
$this->stubNotInstalled = $this->getMock(
'\Alchemy\Phrasea\Core\Configuration\Application'
, array('getConfigurationsFile')
);
$specNotInstalled->expects($this->any())
$this->stubNotInstalled->expects($this->any())
->method('getConfigurationsFile')
->will(
$this->throwException(new Exception)
);
$specExperience = $this->getMock(
$this->stubExperience = $this->getMock(
'\Alchemy\Phrasea\Core\Configuration\Application'
, array('getConfigurationsFile')
);
$specExperience->expects($this->any())
$this->stubExperience->expects($this->any())
->method('getConfigurationsFile')
->will(
$this->returnValue(
@@ -72,12 +75,28 @@ class ConfigurationTest extends \PhraseanetPHPUnitAbstract
)
);
$handler = new Configuration\Handler($specNotInstalled);
$handler = new Configuration\Handler($this->stubNotInstalled);
$this->confNotInstalled = new PhraseaCore\Configuration($handler);
$handler = new Configuration\Handler($specExperience);
$handler = new Configuration\Handler($this->stubExperience);
$this->object = new PhraseaCore\Configuration($handler);
touch(__DIR__ . "/confTestFiles/yamlWriteTest.yml");
$this->stubConfTest = $this->getMock(
'\Alchemy\Phrasea\Core\Configuration\Application'
, array('getConfigurationPathName')
);
$file = new \SplFileObject(__DIR__ . "/confTestFiles/yamlWriteTest.yml");
$this->stubConfTest->expects($this->any())
->method('getConfigurationPathName')
->will(
$this->returnValue($file->getPathname())
);
}
public function testGetEnvironment()
@@ -244,22 +263,7 @@ class ConfigurationTest extends \PhraseanetPHPUnitAbstract
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);
$handler = new Configuration\Handler($this->stubConfTest);
$configuration = new PhraseaCore\Configuration($handler);
@@ -282,22 +286,7 @@ class ConfigurationTest extends \PhraseanetPHPUnitAbstract
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);
$handler = new Configuration\Handler($this->stubConfTest);
$configuration = new PhraseaCore\Configuration($handler);
@@ -319,22 +308,7 @@ class ConfigurationTest extends \PhraseanetPHPUnitAbstract
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);
$handler = new Configuration\Handler($this->stubConfTest);
$configuration = new PhraseaCore\Configuration($handler);
@@ -345,22 +319,7 @@ class ConfigurationTest extends \PhraseanetPHPUnitAbstract
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);
$handler = new Configuration\Handler($this->stubConfTest);
$configuration = new PhraseaCore\Configuration($handler);
@@ -412,22 +371,7 @@ class ConfigurationTest extends \PhraseanetPHPUnitAbstract
$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);
$handler = new Configuration\Handler($this->stubConfTest);
$configuration = new PhraseaCore\Configuration($handler);

View File

@@ -13,15 +13,14 @@ class ServiceAbstractTest extends PhraseanetPHPUnitAbstract
public function setUp()
{
parent::setUp();
$stub = $this->getMockForAbstractClass(
$this->object = $this->getMockForAbstractClass(
"\Alchemy\Phrasea\Core\Service\ServiceAbstract"
, array(
self::$core
, array('option' => 'my_options')
)
);
$this->object = $stub;
}
public function testGetOptions()

View File

@@ -8,7 +8,7 @@ class AbstractBuilderTest extends PhraseanetPHPUnitAbstract
public function testConstructExceptionNameEmpty()
{
try {
$stub = $this->getMock(
$this->getMock(
"\Alchemy\Phrasea\Core\Service\Builder"
, array()
, array(
@@ -26,7 +26,7 @@ class AbstractBuilderTest extends PhraseanetPHPUnitAbstract
public function testConstructExceptionCreate()
{
try {
$stub = $this->getMock(
$this->getMock(
"\\Alchemy\\Phrasea\\Core\\Service\\Builder"
, array()
, array(

View File

@@ -73,7 +73,7 @@ class Bridge_Api_Auth_FlickrTest extends PHPUnit_Framework_TestCase
$this->setExpectedException("Bridge_Exception_ApiConnectorAccessTokenFailed");
$return = $stub->connect("123");
$stub->connect("123");
}
public function testReconnect()

View File

@@ -10,6 +10,7 @@ class Bridge_Api_Auth_OAuth2Test extends PHPUnit_Framework_TestCase
*/
protected $object;
protected $parameters;
protected $mockSettings;
public function setUp()
{
@@ -24,6 +25,8 @@ class Bridge_Api_Auth_OAuth2Test extends PHPUnit_Framework_TestCase
, 'token_endpoint' => "one_token_endpoint"
, 'auth_endpoint' => "one_auth_endpoint"
);
$this->mockSettings = $this->getMock("Bridge_AccountSettings", array("get", "set"), array(), "", false);
}
public function testParse_request_token()
@@ -46,14 +49,12 @@ class Bridge_Api_Auth_OAuth2Test extends PHPUnit_Framework_TestCase
public function testReconnect()
{
$setting = $this->getMock("Bridge_AccountSettings", array("get"), array(), "", false);
$setting->expects($this->once())
$this->mockSettings->expects($this->once())
->method("get")
->with($this->equalTo("refresh_token"))
->will($this->returnValue("123"));
$this->object->set_settings($setting);
$this->object->set_settings($this->mockSettings);
$this->setExpectedException("Bridge_Exception_ApiConnectorAccessTokenFailed");
@@ -62,13 +63,11 @@ class Bridge_Api_Auth_OAuth2Test extends PHPUnit_Framework_TestCase
public function testDisconnect()
{
$setting = $this->getMock("Bridge_AccountSettings", array("set"), array(), "", false);
$setting->expects($this->once())
$this->mockSettings->expects($this->once())
->method("set")
->with($this->equalTo("auth_token"), $this->isNull());
$this->object->set_settings($setting);
$this->object->set_settings($this->mockSettings);
$return = $this->object->disconnect();
@@ -77,14 +76,12 @@ class Bridge_Api_Auth_OAuth2Test extends PHPUnit_Framework_TestCase
public function testIs_connected()
{
$setting = $this->getMock("Bridge_AccountSettings", array("get"), array(), "", false);
$setting->expects($this->any())
$this->mockSettings->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($this->mockSettings);
$this->assertTrue($this->object->is_connected());
$this->assertTrue($this->object->is_connected());
@@ -93,14 +90,12 @@ class Bridge_Api_Auth_OAuth2Test extends PHPUnit_Framework_TestCase
public function testGet_auth_signatures()
{
$setting = $this->getMock("Bridge_AccountSettings", array("get"), array(), "", false);
$setting->expects($this->once())
$this->mockSettings->expects($this->once())
->method("get")
->with($this->equalTo("auth_token"))
->will($this->returnValue("123"));
$this->object->set_settings($setting);
$this->object->set_settings($this->mockSettings);
$return = $this->object->get_auth_signatures();

View File

@@ -9,119 +9,114 @@ class Bridge_Api_AbstractCollectionTest extends PHPUnit_Framework_TestCase
* @var Bridge_Api_AbstractCollection
*/
protected $object;
protected $stub;
public function setUp()
{
parent::setUp();
$this->stub = $this->getMockForAbstractClass('Bridge_Api_AbstractCollection');
}
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());
$this->assertNull($this->stub->get_total_items());
$this->stub->set_total_items("3");
$this->assertEquals(3, $this->stub->get_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);
$return = $this->stub->set_total_items("3");
$this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_INT, $this->stub->get_total_items());
$this->assertEquals(3, $this->stub->get_total_items());
$this->assertEquals($return, $this->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());
$this->assertNull($this->stub->get_items_per_page());
$this->stub->set_items_per_page("3");
$this->assertEquals(3, $this->stub->get_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);
$return = $this->stub->set_items_per_page("3");
$this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_INT, $this->stub->get_items_per_page());
$this->assertEquals(3, $this->stub->get_items_per_page());
$this->assertEquals($return, $this->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());
$this->assertEquals(1, $this->stub->get_current_page());
$this->stub->set_current_page("3");
$this->assertEquals(3, $this->stub->get_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());
$return = $this->stub->set_current_page("3");
$this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_INT, $this->stub->get_current_page());
$this->assertEquals(3, $this->stub->get_current_page());
$this->assertEquals($return, $this->stub);
$return = $this->stub->set_current_page(-4);
$this->assertEquals(3, $this->stub->get_current_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());
$this->assertEquals(1, $this->stub->get_total_page());
$this->stub->set_total_page("3");
$this->assertEquals(3, $this->stub->get_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());
$return = $this->stub->set_total_page("3");
$this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_INT, $this->stub->get_total_page());
$this->assertEquals(3, $this->stub->get_total_page());
$this->assertEquals($return, $this->stub);
$return = $this->stub->set_total_page(-4);
$this->assertEquals(3, $this->stub->get_total_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());
$this->stub->set_current_page(2);
$this->stub->set_total_page(2);
$this->assertFalse($this->stub->has_next_page());
$this->stub->set_current_page(1);
$this->stub->set_total_page(2);
$this->assertTrue($this->stub->has_next_page());
$this->stub->set_current_page(3);
$this->stub->set_total_page(2);
$this->assertFalse($this->stub->has_next_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());
$this->stub->set_current_page(2);
$this->assertTrue($this->stub->has_previous_page());
$this->stub->set_current_page(1);
$this->assertFalse($this->stub->has_previous_page());
$this->stub->set_current_page(0);
$this->assertFalse($this->stub->has_previous_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());
$this->stub->set_total_page(2);
$this->assertTrue($this->stub->has_more_than_one_page());
$this->stub->set_total_page(1);
$this->assertFalse($this->stub->has_more_than_one_page());
$this->stub->set_total_page(0);
$this->assertFalse($this->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());
$this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $this->stub->get_elements());
$this->assertEquals(array(), $this->stub->get_elements());
}
}

View File

@@ -7,6 +7,7 @@ class Bridge_Api_AbstractTest extends PhraseanetWebTestCaseAuthenticatedAbstract
{
public static $account = null;
public static $api = null;
protected $bridgeApi;
/**
* @var Bridge_Api_Abstract
@@ -17,6 +18,7 @@ class Bridge_Api_AbstractTest extends PhraseanetWebTestCaseAuthenticatedAbstract
{
parent::setUp();
$this->auth = $this->getMock("Bridge_Api_Auth_Interface");
$this->bridgeApi = $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 static function setUpBeforeClass()
@@ -46,23 +48,19 @@ class Bridge_Api_AbstractTest extends PhraseanetWebTestCaseAuthenticatedAbstract
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();
$stub->expects($this->once())
$this->bridgeApi->expects($this->once())
->method('set_transport_authentication_params');
$return = $stub->set_auth_settings($settings);
$return = $this->bridgeApi->set_auth_settings($settings);
$this->assertEquals($stub, $return);
$this->assertEquals($this->bridgeApi, $return);
}
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())
$this->bridgeApi->expects($this->once())
->method('is_configured')
->will($this->returnValue(TRUE));
@@ -73,134 +71,115 @@ class Bridge_Api_AbstractTest extends PhraseanetWebTestCaseAuthenticatedAbstract
->method('connect')
->will($this->returnValue(array("coucou")));
$return = $stub->connect();
$return = $this->bridgeApi->connect();
$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"));
$stub->expects($this->once())
$this->bridgeApi->expects($this->once())
->method('is_configured')
->will($this->returnValue(FALSE));
$this->setExpectedException("Bridge_Exception_ApiConnectorNotConfigured");
$stub->connect();
$this->bridgeApi->connect();
}
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())
$this->bridgeApi->expects($this->once())
->method('is_configured')
->will($this->returnValue(TRUE));
$this->auth->expects($this->once())
->method('reconnect');
$return = $stub->reconnect();
$return = $this->bridgeApi->reconnect();
$this->assertEquals($stub, $return);
$this->assertEquals($this->bridgeApi, $return);
}
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())
$this->bridgeApi->expects($this->once())
->method('is_configured')
->will($this->returnValue(FALSE));
$this->setExpectedException("Bridge_Exception_ApiConnectorNotConfigured");
$stub->reconnect();
$this->bridgeApi->reconnect();
}
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())
$this->bridgeApi->expects($this->once())
->method('is_configured')
->will($this->returnValue(TRUE));
$this->auth->expects($this->once())
->method('disconnect');
$return = $stub->disconnect();
$return = $this->bridgeApi->disconnect();
$this->assertEquals($stub, $return);
$this->assertEquals($this->bridgeApi, $return);
}
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())
$this->bridgeApi->expects($this->once())
->method('is_configured')
->will($this->returnValue(FALSE));
$this->setExpectedException("Bridge_Exception_ApiConnectorNotConfigured");
$stub->disconnect();
$this->bridgeApi->disconnect();
}
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())
->method('is_connected')
->will($this->returnValue(TRUE));
$return = $stub->is_connected();
$return = $this->bridgeApi->is_connected();
$this->assertEquals(TRUE, $return);
$this->assertEquals(true, $return);
}
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())
->method('get_auth_url')
->with($this->isType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY))
->will($this->returnValue("une url"));
$return = $stub->get_auth_url();
$return = $this->bridgeApi->get_auth_url();
$this->assertEquals("une url", $return);
}
public function testSet_locale()
{
$stub = $this->getMockForAbstractClass('Bridge_Api_Abstract', array(registry::get_instance(), $this->auth, "Mock_Bridge_Api_Abstract"));
$this->bridgeApi->set_locale("fr");
$stub->set_locale("fr");
$this->assertEquals("fr", $stub->get_locale());
$this->assertEquals("fr", $this->bridgeApi->get_locale());
}
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));
$this->assertTrue($this->bridgeApi->is_valid_object_id("abc"));
$this->assertTrue($this->bridgeApi->is_valid_object_id(123));
$this->assertTrue($this->bridgeApi->is_valid_object_id(12.25));
$this->assertFalse($this->bridgeApi->is_valid_object_id(array()));
$this->assertFalse($this->bridgeApi->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);
$void = $this->bridgeApi->handle_exception($e);
$this->assertNull($void);
}
}

View File

@@ -8,10 +8,11 @@ class Bridge_Api_ElementCollectionTest extends PHPUnit_Framework_TestCase
public function testAdd_element()
{
$elements = array();
$collection = new Bridge_Api_ElementCollection();
$i = 0;
while ($i < 5) {
$element = $this->getMock("Bridge_Api_ElementInterface");
$elements[] = $element = $this->getMock("Bridge_Api_ElementInterface");
$collection->add_element(new $element);
$i ++;
}

View File

@@ -16,7 +16,6 @@ class Bridge_ElementTest extends PhraseanetPHPUnitAuthenticatedAbstract
protected $id;
protected $title;
protected $status;
protected static $need_records = 1;
public function setUp()
{
@@ -36,7 +35,7 @@ class Bridge_ElementTest extends PhraseanetPHPUnitAuthenticatedAbstract
$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());
$element = Bridge_Element::create($appbox, $this->account, static::$records['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);
}
@@ -73,8 +72,8 @@ class Bridge_ElementTest extends PhraseanetPHPUnitAuthenticatedAbstract
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());
$this->assertEquals(static::$records['record_1']->get_sbas_id(), $this->object->get_record()->get_sbas_id());
$this->assertEquals(static::$records['record_1']->get_record_id(), $this->object->get_record()->get_record_id());
}
public function testGet_dist_id()

View File

@@ -4,8 +4,6 @@ require_once __DIR__ . '/../../PhraseanetPHPUnitAuthenticatedAbstract.class.inc'
class EntityBasketTest extends PhraseanetPHPUnitAuthenticatedAbstract
{
protected static $need_records = 1;
/**
*
* @var \Entities\Basket
@@ -98,7 +96,7 @@ class EntityBasketTest extends PhraseanetPHPUnitAuthenticatedAbstract
$basketElement = new \Entities\BasketElement();
$basketElement->setRecord(self::$record_1);
$basketElement->setRecord(static::$records['record_1']);
$basketElement->setBasket($this->basket);

View File

@@ -32,7 +32,6 @@ class Feed_Entry_CollectionTest extends PhraseanetPHPUnitAuthenticatedAbstract
protected static $subtitle = 'subtitle lalalala';
protected static $author_name = 'Jean Bonno';
protected static $author_email = 'Jean@bonno.fr';
protected static $need_records = true;
public static function setUpBeforeClass()
{
@@ -45,7 +44,7 @@ class Feed_Entry_CollectionTest extends PhraseanetPHPUnitAuthenticatedAbstract
$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);
self::$item = Feed_Entry_Item::create($appbox, self::$entry, self::$record_1);
self::$item = Feed_Entry_Item::create($appbox, self::$entry, static::$records['record_1']);
self::$object = new Feed_Entry_Collection();
}

View File

@@ -27,7 +27,6 @@ class Feed_Entry_ItemTest extends PhraseanetPHPUnitAuthenticatedAbstract
protected static $subtitle = 'subtitle lalalala';
protected static $author_name = 'Jean Bonno';
protected static $author_email = 'Jean@bonno.fr';
protected static $need_records = true;
public static function setUpBeforeClass()
{
@@ -40,7 +39,7 @@ class Feed_Entry_ItemTest extends PhraseanetPHPUnitAuthenticatedAbstract
$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);
self::$object = Feed_Entry_Item::create($appbox, self::$entry, self::$record_1);
self::$object = Feed_Entry_Item::create($appbox, self::$entry, static::$records['record_1']);
}
public static function tearDownAfterClass()
@@ -57,9 +56,9 @@ class Feed_Entry_ItemTest extends PhraseanetPHPUnitAuthenticatedAbstract
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());
$this->assertEquals(static::$records['record_1']->get_record_id(), self::$object->get_record()->get_record_id());
$this->assertEquals(static::$records['record_1']->get_sbas_id(), self::$object->get_record()->get_sbas_id());
$this->assertEquals(static::$records['record_1']->get_base_id(), self::$object->get_record()->get_base_id());
}
public function testGet_ord()

View File

@@ -21,300 +21,8 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
* @var Symfony\Component\HttpKernel\Client
*/
protected $client;
/**
*
* @var record_adapter
*/
protected static $story_1;
/**
*
* @var record_adapter
*/
protected static $story_2;
/**
*
* @var record_adapter
*/
protected static $record_1;
/**
*
* @var record_adapter
*/
protected static $record_2;
/**
*
* @var record_adapter
*/
protected static $record_3;
/**
*
* @var record_adapter
*/
protected static $record_4;
/**
*
* @var record_adapter
*/
protected static $record_5;
/**
*
* @var record_adapter
*/
protected static $record_6;
/**
*
* @var record_adapter
*/
protected static $record_7;
/**
*
* @var record_adapter
*/
protected static $record_8;
/**
*
* @var record_adapter
*/
protected static $record_9;
/**
*
* @var record_adapter
*/
protected static $record_10;
/**
*
* @var record_adapter
*/
protected static $record_11;
/**
*
* @var record_adapter
*/
protected static $record_12;
/**
*
* @var record_adapter
*/
protected static $record_13;
/**
*
* @var record_adapter
*/
protected static $record_14;
/**
*
* @var record_adapter
*/
protected static $record_15;
/**
*
* @var record_adapter
*/
protected static $record_16;
/**
*
* @var record_adapter
*/
protected static $record_17;
/**
*
* @var record_adapter
*/
protected static $record_18;
/**
*
* @var record_adapter
*/
protected static $record_19;
/**
*
* @var record_adapter
*/
protected static $record_20;
/**
*
* @var record_adapter
*/
protected static $record_21;
/**
*
* @var record_adapter
*/
protected static $record_22;
/**
*
* @var record_adapter
*/
protected static $record_23;
/**
*
* @var record_adapter
*/
protected static $record_no_access;
/**
*
* @var system_file
*/
protected static $record_sf_1;
/**
*
* @var system_file
*/
protected static $record_sf_2;
/**
*
* @var system_file
*/
protected static $record_sf_3;
/**
*
* @var system_file
*/
protected static $record_sf_4;
/**
*
* @var system_file
*/
protected static $record_sf_5;
/**
*
* @var system_file
*/
protected static $record_sf_6;
/**
*
* @var system_file
*/
protected static $record_sf_7;
/**
*
* @var system_file
*/
protected static $record_sf_8;
/**
*
* @var system_file
*/
protected static $record_sf_9;
/**
*
* @var system_file
*/
protected static $record_sf_10;
/**
*
* @var system_file
*/
protected static $record_sf_11;
/**
*
* @var system_file
*/
protected static $record_sf_12;
/**
*
* @var system_file
*/
protected static $record_sf_13;
/**
*
* @var system_file
*/
protected static $record_sf_14;
/**
*
* @var system_file
*/
protected static $record_sf_15;
/**
*
* @var system_file
*/
protected static $record_sf_16;
/**
*
* @var system_file
*/
protected static $record_sf_17;
/**
*
* @var system_file
*/
protected static $record_sf_18;
/**
*
* @var system_file
*/
protected static $record_sf_19;
/**
*
* @var system_file
*/
protected static $record_sf_20;
/**
*
* @var system_file
*/
protected static $record_sf_21;
/**
*
* @var system_file
*/
protected static $record_sf_22;
/**
*
* @var system_file
*/
protected static $record_sf_23;
protected static $records;
public static $recordsInitialized = false;
/**
*
@@ -340,18 +48,6 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
*/
protected static $updated;
/**
* if yo need record for your test
* just tell how many
* example = $need_records = 2
* will create 2 records self::$record_1 & self::$record_2
* You can use the same mechanism for subdef and stories
* @var mixed int|boolean
*/
protected static $need_records = false;
protected static $need_subdefs = false;
protected static $need_story = false;
/**
*
* @var collection
@@ -370,12 +66,6 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
*/
protected static $time_start;
/**
*
* @var Array
*/
protected static $generated_subdefs = array();
/**
*
* @var \Alchemy\Phrasea\Core
@@ -402,11 +92,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
self::setCollection();
self::generateStories();
self::generateRecords();
self::generateSubdefs();
}
/**
@@ -480,6 +166,20 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
{
//unset static::$core
self::$core = null;
/**
* Kris Wallsmith pro-tip
* @see http://kriswallsmith.net/post/18029585104/faster-phpunit
*/
$refl = new ReflectionObject($this);
foreach ($refl->getProperties() as $prop) {
if ( ! $prop->isStatic() && 0 !== strpos($prop->getDeclaringClass()->getName(), 'PHPUnit_') && 0 !== strpos($prop->getDeclaringClass()->getName(), 'Phraseanet')) {
$prop->setAccessible(true);
$prop->setValue($this, null);
}
}
$refl = null;
parent::tearDown();
}
@@ -586,7 +286,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
$loader->addFixture($UsrList);
$UsrEntry = new PhraseaFixture\UsrLists\UsrListEntry();
// $UsrEntry->setList($UsrList);
$UsrEntry->setUser($user);
$loader->addFixture($UsrEntry);
@@ -632,7 +332,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
$basket = $this->insertOneBasket();
$basketElement = new \Entities\BasketElement();
$basketElement->setRecord(self::$record_1);
$basketElement->setRecord(static::$records['record_1']);
$basketElement->setBasket($basket);
$basket->addBasketElement($basketElement);
@@ -714,8 +414,8 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
$basketFixture->addParticipant(self::$user_alt1);
$basketFixture->addParticipant(self::$user_alt2);
$basketFixture->addBasketElement(self::$record_1);
$basketFixture->addBasketElement(self::$record_2);
$basketFixture->addBasketElement(static::$records['record_1']);
$basketFixture->addBasketElement(static::$records['record_2']);
$loader = new Loader();
$loader->addFixture($basketFixture);
@@ -746,7 +446,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
//add one story
$story = new PhraseaFixture\Story\LoadOneStory();
$story->setUser($currentUser);
$story->setRecord(self::$record_1);
$story->setRecord(static::$records['record_1']);
//add a validation session initiated by alt user
$validationSession = new PhraseaFixture\ValidationSession\LoadOneValidationSession();
$validationSession->setUser($altUser);
@@ -975,7 +675,6 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
}
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;
@@ -985,242 +684,61 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
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) {
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;
}
/**
* Generate a set subdef according to the records previously created
*
* @return void
*/
private static function generateSubdefs()
{
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;
}
/**
* 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 (self::$recordsInitialized === false) {
self::$recordsInitialized = array();
static::$records = new Pimple();
$collection = self::$collection;
$resolvePathfile = function($i) {
$finder = new Symfony\Component\Finder\Finder();
$name = $i < 10 ? 'test00' . $i . '.*' : 'test0' . $i . '.*';
$finder->name($name)->in(__DIR__ . '/testfiles/');
foreach ($finder as $file) {
return $file->getRealPath();
}
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);
throw new Exception(sprintf('File %d not found', $i));
};
foreach (range(1, 24) as $i) {
static::$records['record_' . $i] = static::$records->share(function() use ($collection, $resolvePathfile, $i) {
PhraseanetPHPUnitAbstract::$recordsInitialized[] = $i;
$record = record_adapter::create($collection, $resolvePathfile($i));
$record->generate_subdefs($record->get_databox());
return $record;
});
}
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);
foreach (range(1, 2) as $i) {
static::$records['record_story_' . $i] = static::$records->share(function() use ($collection, $i) {
PhraseanetPHPUnitAbstract::$recordsInitialized[] = 'story_' . $i;
return record_adapter::create($collection, __DIR__ . '/testfiles/test001.CR2', false, true);
});
}
$collection_no_access = self::$collection_no_access;
static::$records['record_no_access'] = static::$records->share(function()use($collection_no_access) {
PhraseanetPHPUnitAbstract::$recordsInitialized[] = 'no_access';
return record_adapter::create($collection_no_access, __DIR__ . '/testfiles/test001.CR2');
});
}
return;
@@ -1245,107 +763,12 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
\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;
foreach (self::$recordsInitialized as $i) {
static::$records['record_' . $i]->delete();
}
self::$recordsInitialized = array();
return;
}
}

View File

@@ -10,8 +10,6 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
* @var API_V1_adapter
*/
protected $object;
protected static $need_records = 1;
protected static $need_subdefs = true;
public function setUp()
{
@@ -119,11 +117,11 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
$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");
$result = $this->object->get_record($request, static::$records['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());
$result = $this->object->get_record($request, static::$records['record_1']->get_sbas_id(), static::$records['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())));
@@ -179,7 +177,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
$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());
$result = $this->object->get_record_related($request, static::$records['record_1']->get_sbas_id(), static::$records['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())));
@@ -190,7 +188,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
$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());
$result = $this->object->get_record_metadatas($request, static::$records['record_1']->get_sbas_id(), static::$records['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())));
@@ -202,7 +200,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
$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());
$result = $this->object->get_record_status($request, static::$records['record_1']->get_sbas_id(), static::$records['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())));
@@ -213,7 +211,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
$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());
$result = $this->object->get_record_embed($request, static::$records['record_1']->get_sbas_id(), static::$records['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())));
@@ -222,25 +220,25 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
public function testSet_record_metadatas()
{
$appbox = appbox::get_instance(\bootstrap::getCore());
$databox = self::$record_1->get_databox();
$databox = static::$records['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());
$result = $this->object->set_record_metadatas($request, static::$records['record_1']->get_sbas_id(), static::$records['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->object->set_record_metadatas($request, static::$records['record_1']->get_sbas_id(), static::$records['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');
if (sizeof(static::$records['record_1']->get_caption()->get_fields()) == 0) {
$caption_field_value = caption_Field_Value::create(databox_field::get_instance($databox, 1), static::$records['record_1'], 'my value');
}
//valide metas
$metadatas = array();
foreach (self::$record_1->get_databox()->get_meta_structure()->get_elements() as $field) {
foreach (static::$records['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();
$values = static::$records['record_1']->get_caption()->get_field($field->get_name())->get_values();
$value = array_pop($values);
$meta_id = $value->getId();
} catch (\Exception $e) {
@@ -256,7 +254,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
$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());
$result = $this->object->set_record_metadatas($request, static::$records['record_1']->get_sbas_id(), static::$records['record_1']->get_record_id());
$response = json_decode($result->format());
@@ -270,7 +268,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
$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();
$databox = static::$records['record_1']->get_databox();
$statusbit = null;
foreach ($databox->get_statusbits() as $key => $value) {
@@ -279,11 +277,11 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
}
$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());
$result = $stub->set_record_status($request, static::$records['record_1']->get_sbas_id(), static::$records['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());
$stub->set_record_status($request, static::$records['record_1']->get_sbas_id(), static::$records['record_1']->get_record_id());
$this->assertEquals(400, $result->get_http_code());
$status = array($statusbit => '1');
@@ -294,7 +292,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
->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());
$result = $stub->set_record_status($request, static::$records['record_1']->get_sbas_id(), static::$records['record_1']->get_record_id());
$this->checkResponseField($result, "status", PHPUnit_Framework_Constraint_IsType::TYPE_OBJECT);
}
@@ -302,10 +300,10 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
{
$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();
$databox = static::$records['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());
$result = $stub->set_record_collection($request, static::$records['record_1']->get_sbas_id(), static::$records['record_1']->get_record_id());
$this->assertEquals(400, $result->get_http_code());
foreach ($appbox->get_databoxes() as $databox) {
@@ -321,7 +319,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
->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());
$result = $stub->set_record_collection($request, static::$records['record_1']->get_sbas_id(), static::$records['record_1']->get_record_id());
$this->checkResponseField($result, "record", PHPUnit_Framework_Constraint_IsType::TYPE_OBJECT);
}
@@ -464,7 +462,6 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
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);
@@ -489,7 +486,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
$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);
$feed_entry_item = Feed_Entry_Item::create($appbox, $feed_entry, static::$records['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);

View File

@@ -8,12 +8,11 @@ class caption_recordTest extends PhraseanetPHPUnitAbstract
* @var caption_record
*/
protected $object;
protected static $need_records = 1;
public function setUp()
{
parent::setUp();
$this->object = new caption_record(self::$record_1, self::$record_1->get_databox());
$this->object = new caption_record(static::$records['record_1'], static::$records['record_1']->get_databox());
}
/**
@@ -22,11 +21,11 @@ class caption_recordTest extends PhraseanetPHPUnitAbstract
public function testSerializeXML()
{
foreach (self::$record_1->get_databox()->get_meta_structure() as $databox_field) {
foreach (static::$records['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());
\caption_Field_Value::create($databox_field, static::$records['record_1'], \random::generatePassword());
}
}
@@ -35,7 +34,7 @@ class caption_recordTest extends PhraseanetPHPUnitAbstract
$sxe = simplexml_load_string($xml);
$this->assertInstanceOf('SimpleXMLElement', $sxe);
foreach (self::$record_1->get_caption()->get_fields() as $field) {
foreach (static::$records['record_1']->get_caption()->get_fields() as $field) {
if ($field->get_databox_field()->is_multi()) {
$tagname = $field->get_name();
$retrieved = array();

View File

@@ -81,7 +81,7 @@ class collectionTest extends PhraseanetPHPUnitAuthenticatedAbstract
public function testEmpty_collection()
{
$record = record_adapter::create(self::$object, new system_file(__DIR__ . '/testfiles/cestlafete.jpg'));
$record = record_adapter::create(self::$object, __DIR__ . '/testfiles/cestlafete.jpg');
$this->assertTrue(self::$object->get_record_amount() > 0);
self::$object->empty_collection();
$this->assertTrue(self::$object->get_record_amount() === 0);
@@ -128,7 +128,7 @@ class collectionTest extends PhraseanetPHPUnitAuthenticatedAbstract
public function testGet_record_amount()
{
self::$object->empty_collection();
$record = record_adapter::create(self::$object, new system_file(__DIR__ . '/testfiles/cestlafete.jpg'));
$record = record_adapter::create(self::$object, __DIR__ . '/testfiles/cestlafete.jpg');
$this->assertTrue(self::$object->get_record_amount() === 1);
self::$object->empty_collection();
$this->assertTrue(self::$object->get_record_amount() === 0);
@@ -136,7 +136,7 @@ class collectionTest extends PhraseanetPHPUnitAuthenticatedAbstract
public function testGet_record_details()
{
$record = record_adapter::create(self::$object, new system_file(__DIR__ . '/testfiles/cestlafete.jpg'));
$record = record_adapter::create(self::$object, __DIR__ . '/testfiles/cestlafete.jpg');
$details = self::$object->get_record_details();
$this->assertTrue(is_array($details));

View File

@@ -12,12 +12,11 @@ class databox_fieldTest extends PhraseanetPHPUnitAbstract
protected $databox;
protected $name_mono;
protected $name_multi;
protected static $need_records = 1;
public function setUp()
{
parent::setUp();
$this->databox = self::$record_1->get_databox();
$this->databox = static::$records['record_1']->get_databox();
$this->name_mono = 'Field Test Mono';
$this->name_multi = 'Field Test Multi';
@@ -78,9 +77,9 @@ class databox_fieldTest extends PhraseanetPHPUnitAbstract
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->assertEquals(static::$records['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(static::$records['record_1']->get_databox()->get_sbas_id(), $this->object_multi->get_databox()->get_sbas_id());
}
/**
@@ -395,7 +394,7 @@ class databox_fieldTest extends PhraseanetPHPUnitAbstract
{
$AddedValue = 'scalar value';
self::$record_1->set_metadatas(array(
static::$records['record_1']->set_metadatas(array(
array(
'meta_id' => null,
'meta_struct_id' => $this->object_mono->get_id(),
@@ -405,7 +404,7 @@ class databox_fieldTest extends PhraseanetPHPUnitAbstract
$this->object_mono->set_name('Bonobo yoyo')->save();
$value = array_pop(self::$record_1->get_caption()->get_field('Bonoboyoyo')->get_values());
$value = array_pop(static::$records['record_1']->get_caption()->get_field('Bonoboyoyo')->get_values());
$this->assertEquals($value->getValue(), $AddedValue);
}
@@ -414,7 +413,7 @@ class databox_fieldTest extends PhraseanetPHPUnitAbstract
$AddedValue_1 = 'scalar value 1';
$AddedValue_2 = 'scalar value 2';
self::$record_1->set_metadatas(array(
static::$records['record_1']->set_metadatas(array(
array(
'meta_id' => null,
'meta_struct_id' => $this->object_multi->get_id(),
@@ -427,11 +426,11 @@ class databox_fieldTest extends PhraseanetPHPUnitAbstract
)
));
$this->assertEquals(2, count(self::$record_1->get_caption()->get_field(str_replace(' ', '', $this->name_multi))->get_values()));
$this->assertEquals(2, count(static::$records['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()));
$this->assertEquals(1, count(static::$records['record_1']->get_caption()->get_field(str_replace(' ', '', $this->name_multi))->get_values()));
}
/**

View File

@@ -9,12 +9,11 @@ class databox_statusTest extends PhraseanetPHPUnitAbstract
*/
protected $object;
protected $databox;
protected static $need_records = 1;
public function setUp()
{
parent::setUp();
$this->databox = self::$record_1->get_databox();
$this->databox = static::$records['record_1']->get_databox();
$this->object = $this->databox->get_statusbits();
}

View File

@@ -8,13 +8,12 @@ class media_Permalink_AdapterTest extends PhraseanetPHPUnitAbstract
* @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'));
$databox = static::$records['record_1']->get_databox();
static::$object = media_Permalink_Adapter::getPermalink($databox, static::$records['record_1']->get_subdef('document'));
}
public function testGetPermalink()
@@ -45,7 +44,7 @@ class media_Permalink_AdapterTest extends PhraseanetPHPUnitAbstract
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() . '/' .
$url = $registry->get('GV_ServerName') . 'permalink/v1/' . static::$object->get_label() . '/' . static::$records['record_1']->get_sbas_id() . '/' . static::$records['record_1']->get_record_id() . '/' .
static::$object->get_token() . '/document/';
$this->assertEquals($url, static::$object->get_url($registry));

View File

@@ -27,7 +27,7 @@ class media_subdefTest extends \PhraseanetPHPUnitAbstract
{
parent::setUpBeforeClass();
self::$recordonbleu = record_adapter::create(self::$collection, new system_file(__DIR__ . "/../testfiles/iphone_pic.jpg"));
self::$recordonbleu = record_adapter::create(self::$collection, __DIR__ . "/../testfiles/iphone_pic.jpg");
self::$recordonbleu->generate_subdefs(self::$recordonbleu->get_databox());
foreach (self::$recordonbleu->get_subdefs() as $subdef) {

View File

@@ -8,35 +8,29 @@ 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();
$system_file = static::$records['record_1']->get_hd_file();
$databox = static::$records['record_1']->get_databox();
$metadatas = $system_file->extract_metadatas($databox->get_meta_structure());
static::$record_1->set_metadatas($metadatas['metadatas']);
static::$records['record_1']->set_metadatas($metadatas['metadatas']);
$databox = self::$record_23->get_databox();
$system_file = self::$record_23->get_hd_file();
$databox = static::$records['record_23']->get_databox();
$system_file = static::$records['record_23']->get_hd_file();
$metadatas = $system_file->extract_metadatas($databox->get_meta_structure());
static::$record_23->set_metadatas($metadatas['metadatas']);
static::$records['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) {
foreach (static::$records['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');
}
/**
@@ -46,9 +40,6 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
*/
public function testSetExport()
{
$recordsf = new system_file(__DIR__ . '/../testfiles/test001.CR2');
$record = record_adapter::create(self::$collection, $recordsf);
$basket = new \Entities\Basket();
$basket->setName('hello');
@@ -59,7 +50,7 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
$basketElement = new \Entities\BasketElement();
$basketElement->setRecord($record);
$basketElement->setRecord(static::$records['record_1']);
$basketElement->setBasket($basket);
$em->persist($basketElement);
@@ -69,24 +60,18 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
$em->persist($basket);
$em->flush();
$export = new set_exportorder(self::$record_1->get_serialize_key(), $basket->getId());
$export = new set_exportorder(static::$records['record_1']->get_serialize_key(), $basket->getId());
$orderId = $export->order_available_elements(self::$user->get_id(), 'ahaha', '+2 hours');
$record->delete();
try {
$order = new set_order($orderId);
} catch (\Exception $e) {
$this->fail('should not raise an exception' . $e->getMessage() . ' ' . $e->getLine() . ' ' . $e->getFile() . ' ' . $e->getTraceAsString());
}
new set_order($orderId);
}
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));
$this->assertTrue((static::$records['record_1']->get_creation_date() instanceof DateTime));
$this->assertTrue((static::$records['record_1']->get_creation_date() <= $date_obj));
}
protected function assertDateAtom($date)
@@ -96,26 +81,26 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
public function testGet_uuid()
{
$this->assertTrue(uuid::is_valid(static::$record_1->get_uuid()));
$this->assertTrue(uuid::is_valid(static::$records['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));
$this->assertTrue((static::$records['record_1']->get_creation_date() instanceof DateTime));
$this->assertTrue((static::$records['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());
static::$records['record_1']->set_number(24);
$this->assertEquals(24, static::$records['record_1']->get_number());
static::$records['record_1']->set_number(42);
$this->assertEquals(42, static::$records['record_1']->get_number());
static::$records['record_1']->set_number(0);
$this->assertEquals(0, static::$records['record_1']->get_number());
static::$records['record_1']->set_number(null);
$this->assertEquals(0, static::$records['record_1']->get_number());
}
public function testSet_number()
@@ -126,46 +111,46 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
public function testSet_type()
{
try {
self::$record_1->set_type('jambon');
static::$records['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());
$old_type = static::$records['record_1']->get_type();
static::$records['record_1']->set_type('video');
$this->assertEquals('video', static::$records['record_1']->get_type());
static::$records['record_1']->set_type($old_type);
$this->assertEquals($old_type, static::$records['record_1']->get_type());
}
public function testIs_grouping()
{
$this->assertFalse(self::$record_1->is_grouping());
$this->assertTrue(self::$story_1->is_grouping());
$this->assertFalse(static::$records['record_1']->is_grouping());
$this->assertTrue(static::$records['record_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());
$this->assertTrue(is_int(static::$records['record_1']->get_base_id()));
$this->assertEquals(self::$collection->get_base_id(), static::$records['record_1']->get_base_id());
$this->assertTrue(is_int(static::$records['record_story_1']->get_base_id()));
$this->assertEquals(self::$collection->get_base_id(), static::$records['record_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()));
$this->assertTrue(is_int(static::$records['record_1']->get_record_id()));
$this->assertTrue(is_int(static::$records['record_story_1']->get_record_id()));
}
public function testGet_thumbnail()
{
$this->assertTrue((static::$record_1->get_thumbnail() instanceof media_subdef));
$this->assertTrue((static::$records['record_1']->get_thumbnail() instanceof media_subdef));
}
public function testGet_embedable_medias()
{
$embeddables = self::$record_1->get_embedable_medias();
$embeddables = static::$records['record_1']->get_embedable_medias();
$this->assertTrue(is_array($embeddables));
foreach ($embeddables as $subdef) {
$this->assertInstanceOf('media_subdef', $subdef);
@@ -182,25 +167,25 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
public function testGet_type()
{
$this->assertTrue(in_array(static::$record_1->get_type(), array('video', 'audio', 'image', 'document', 'flash', 'unknown')));
$this->assertTrue(in_array(static::$records['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());
$this->assertTrue(strpos(static::$records['record_23']->get_formated_duration(), '00:17') === 0);
$this->assertEquals('', static::$records['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());
$this->assertEquals(17, round(static::$records['record_23']->get_duration()));
$this->assertEquals(false, static::$records['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());
$this->assertInstanceOf('media_subdef', static::$records['record_23']->get_rollover_thumbnail());
$this->assertNull(static::$records['record_1']->get_rollover_thumbnail());
}
public function testGenerate_subdefs()
@@ -210,52 +195,35 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
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());
$this->assertNotNull(static::$records['record_1']->get_sha256());
$this->assertRegExp('/[a-zA-Z0-9]{64}/', static::$records['record_1']->get_sha256());
$this->assertNull(static::$records['record_story_1']->get_sha256());
}
public function testGet_mime()
{
$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();
$this->assertEquals('image/x-canon-cr2', static::$records['record_1']->get_mime());
}
public function testGet_status()
{
$this->assertRegExp('/[01]{64}/', static::$record_1->get_status());
$this->assertRegExp('/[01]{64}/', static::$records['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'));
$this->assertInstanceOf('media_subdef', static::$records['record_1']->get_subdef('document'));
$this->assertInstanceOf('media_subdef', static::$records['record_1']->get_subdef('preview'));
$this->assertInstanceOf('media_subdef', static::$records['record_1']->get_subdef('thumbnail'));
$this->assertInstanceOf('media_subdef', static::$records['record_23']->get_subdef('document'));
$this->assertInstanceOf('media_subdef', static::$records['record_23']->get_subdef('preview'));
$this->assertInstanceOf('media_subdef', static::$records['record_23']->get_subdef('thumbnail'));
$this->assertInstanceOf('media_subdef', static::$records['record_23']->get_subdef('thumbnailGIF'));
}
public function testGet_subdefs()
{
$subdefs = static::$record_1->get_subdefs();
$subdefs = static::$records['record_1']->get_subdefs();
$this->assertTrue(is_array($subdefs));
foreach ($subdefs as $subdef) {
$this->assertInstanceOf('media_subdef', $subdef);
@@ -275,43 +243,43 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
public function testGet_technical_infos()
{
$this->assertTrue(is_array(static::$record_1->get_technical_infos()));
$this->assertTrue(is_array(static::$records['record_1']->get_technical_infos()));
}
public function testGet_caption()
{
$this->assertTrue((static::$record_1->get_caption() instanceof caption_record));
$this->assertTrue((static::$records['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());
$this->assertEquals('test001.CR2', static::$records['record_1']->get_original_name());
}
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());
$this->assertEquals('test001.CR2', static::$records['record_1']->get_title());
$this->assertEquals('test023.mp4', static::$records['record_23']->get_title());
}
public function testGet_preview()
{
$this->assertTrue((static::$record_1->get_preview() instanceof media_subdef));
$this->assertTrue((static::$records['record_1']->get_preview() instanceof media_subdef));
}
public function testHas_preview()
{
$this->assertTrue(self::$record_1->has_preview());
$this->assertTrue(static::$records['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());
$this->assertTrue(static::$records['record_1']->get_serialize_key() == static::$records['record_1']->get_sbas_id() . '_' . static::$records['record_1']->get_record_id());
}
public function testGet_sbas_id()
{
$this->assertTrue(is_int(static::$record_1->get_sbas_id()));
$this->assertTrue(is_int(static::$records['record_1']->get_sbas_id()));
}
public function testSubstitute_subdef()
@@ -327,7 +295,7 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
$meta_structure_el = self::$collection->get_databox()->get_meta_structure()->get_elements();
$current_caption = self::$record_1->get_caption();
$current_caption = static::$records['record_1']->get_caption();
$metadatas = array();
@@ -392,9 +360,9 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
}
}
self::$record_1->set_metadatas($metadatas, true);
static::$records['record_1']->set_metadatas($metadatas, true);
$caption = self::$record_1->get_caption();
$caption = static::$records['record_1']->get_caption();
@@ -430,56 +398,56 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
public function testReindex()
{
self::$record_1->reindex();
static::$records['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 = static::$records['record_1']->get_databox()->get_connection()->prepare($sql);
$stmt->execute(array(':record_id' => self::$record_1->get_record_id()));
$stmt->execute(array(':record_id' => static::$records['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())
if ($row['record_id'] != static::$records['record_1']->get_record_id())
$this->fail();
}
public function testRebuild_subdefs()
{
self::$record_1->rebuild_subdefs();
static::$records['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 = static::$records['record_1']->get_databox()->get_connection()->prepare($sql);
$stmt->execute(array(':record_id' => self::$record_1->get_record_id()));
$stmt->execute(array(':record_id' => static::$records['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())
if ($row['record_id'] != static::$records['record_1']->get_record_id())
$this->fail();
}
public function testWrite_metas()
{
self::$record_1->write_metas();
static::$records['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 = static::$records['record_1']->get_databox()->get_connection()->prepare($sql);
$stmt->execute(array(':record_id' => self::$record_1->get_record_id()));
$stmt->execute(array(':record_id' => static::$records['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())
if ($row['record_id'] != static::$records['record_1']->get_record_id())
$this->fail();
}
@@ -496,28 +464,28 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
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());
$tmp_records = record_adapter::get_record_by_sha(static::$records['record_1']->get_sbas_id(), static::$records['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());
$this->assertEquals(static::$records['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());
$tmp_records = record_adapter::get_record_by_sha(static::$records['record_1']->get_sbas_id(), static::$records['record_1']->get_sha256(), static::$records['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());
$this->assertEquals(static::$records['record_1']->get_sha256(), $tmp_record->get_sha256());
$this->assertEquals(static::$records['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());
$this->assertInstanceOf('system_file', static::$records['record_1']->get_hd_file());
}
/**
@@ -548,7 +516,7 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
/* @var $basket \Entities\Basket */
$basket_element = new \Entities\BasketElement();
$basket_element->setRecord(self::$record_1);
$basket_element->setRecord(static::$records['record_1']);
$basket_element->setBasket($basket);
$em->persist($basket_element);
@@ -560,10 +528,10 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
$found = $sselcont_id = false;
$sbas_id = self::$record_1->get_sbas_id();
$record_id = self::$record_1->get_record_id();
$sbas_id = static::$records['record_1']->get_sbas_id();
$record_id = static::$records['record_1']->get_record_id();
foreach (self::$record_1->get_container_baskets() as $c_basket) {
foreach (static::$records['record_1']->get_container_baskets() as $c_basket) {
if ($c_basket->getId() == $basket->getId()) {
$found = true;
foreach ($c_basket->getElements() as $b_el) {

View File

@@ -172,7 +172,7 @@ class reportTest extends PhraseanetPHPUnitAbstract
$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());
}
}
}

View File

@@ -5,11 +5,15 @@ require_once __DIR__ . '/../PhraseanetPHPUnitAbstract.class.inc';
class sqlActionTest extends PhraseanetPHPUnitAbstract
{
protected $action;
protected $mock;
public function setUp()
{
parent::setUp();
$this->action = new module_report_sqlaction($this->getMock('module_report', array(), array(), '', false));
$this->mock = $this->getMock('module_report', array(), array(), '', false);
$this->action = new module_report_sqlaction($this->mock);
}
public function testGetAction()