Fix tests

This commit is contained in:
Romain Neutron
2012-10-02 15:49:18 +02:00
parent d0ca10448f
commit 24b5793702
5 changed files with 42 additions and 61 deletions

View File

@@ -615,7 +615,7 @@ class API_V1_adapter extends API_V1_Abstract
$record = $this->app['phraseanet.appbox']->get_databox($databox_id)->get_record($record_id); $record = $this->app['phraseanet.appbox']->get_databox($databox_id)->get_record($record_id);
$fields = $record->get_caption()->get_fields(); $fields = $record->get_caption()->get_fields();
$ret = array(); $ret = array('caption_metadatas' => array());
foreach ($fields as $field) { foreach ($fields as $field) {
$ret['caption_metadatas'][] = array( $ret['caption_metadatas'][] = array(

View File

@@ -798,7 +798,7 @@ class databox extends base
return $this; return $this;
} }
protected function feed_meta_fields() public function feed_meta_fields()
{ {
$sxe = $this->get_sxml_structure(); $sxe = $this->get_sxml_structure();
@@ -832,21 +832,20 @@ class databox extends base
$meta_struct_field = databox_field::create($this->app, $this, $fname, $multi); $meta_struct_field = databox_field::create($this->app, $this, $fname, $multi);
$meta_struct_field $meta_struct_field
->set_readonly(isset($field['readonly']) ? $field['readonly'] : 0) ->set_readonly(isset($field['readonly']) ? (string) $field['readonly'] : 0)
->set_indexable(isset($field['index']) ? $field['index'] : '1') ->set_indexable(isset($field['index']) ? (string) $field['index'] : '1')
->set_separator(isset($field['separator']) ? $field['separator'] : '') ->set_separator(isset($field['separator']) ? (string) $field['separator'] : '')
->set_required((isset($field['required']) && $field['required'] == 1)) ->set_required((isset($field['required']) && (string) $field['required'] == 1))
->set_business((isset($field['business']) && $field['business'] == 1)) ->set_business((isset($field['business']) && (string) $field['business'] == 1))
->set_type($type) ->set_type($type)
->set_tbranch(isset($field['tbranch']) ? $field['tbranch'] : '') ->set_tbranch(isset($field['tbranch']) ? (string) $field['tbranch'] : '')
->set_thumbtitle(isset($field['thumbtitle']) ? $field['thumbtitle'] : (isset($field['thumbTitle']) ? $field['thumbTitle'] : '0')) ->set_thumbtitle(isset($field['thumbtitle']) ? (string) $field['thumbtitle'] : (isset($field['thumbTitle']) ? $field['thumbTitle'] : '0'))
->set_report(isset($field['report']) ? $field['report'] : '1') ->set_report(isset($field['report']) ? (string) $field['report'] : '1')
->save(); ->save();
try { try {
$meta_struct_field->set_tag(\databox_field::loadClassFromTagName($src))->save(); $meta_struct_field->set_tag(\databox_field::loadClassFromTagName($src))->save();
} catch (Exception $e) { } catch (Exception $e) {
} }
} }

View File

@@ -96,8 +96,8 @@ class patch_320c implements patchInterface
$xp_struct = $databox->get_xpath_structure(); $xp_struct = $databox->get_xpath_structure();
foreach ($sxe->description->children() as $fname => $field) { foreach ($sxe->description->children() as $fname => $field) {
$src = trim(isset($field['src']) ? $field['src'] : '');
$src = trim(isset($field['src']) ? $field['src'] : '');
if (array_key_exists($src, $phrasea_maps)) { if (array_key_exists($src, $phrasea_maps)) {
$src = $phrasea_maps[$src]; $src = $phrasea_maps[$src];
} }
@@ -111,9 +111,7 @@ class patch_320c implements patchInterface
} }
$databox->saveStructure($dom_struct); $databox->saveStructure($dom_struct);
$databox->feed_meta_fields();
$ext_databox = new extended_databox($databox->get_sbas_id());
$ext_databox->migrate_fields();
$databox->delete_data_from_cache(databox::CACHE_STRUCTURE); $databox->delete_data_from_cache(databox::CACHE_STRUCTURE);
$databox->delete_data_from_cache(databox::CACHE_META_STRUCT); $databox->delete_data_from_cache(databox::CACHE_META_STRUCT);
@@ -129,19 +127,3 @@ class patch_320c implements patchInterface
return true; return true;
} }
} }
class extended_databox extends databox
{
public function __construct($sbas_id)
{
parent::__construct($sbas_id);
}
public function migrate_fields()
{
$this->feed_meta_fields();
return $this;
}
}

View File

@@ -174,8 +174,6 @@ class patch_320f implements patchInterface
} }
if ( ! ($collection instanceof collection)) { if ( ! ($collection instanceof collection)) {
echo "unable to find a collection to protect feeds";
return false; return false;
} }
$feed->set_collection($collection); $feed->set_collection($collection);

View File

@@ -19,9 +19,11 @@ class sphinxrt
protected static $_instance; protected static $_instance;
protected static $_failure = false; protected static $_failure = false;
protected $connection; protected $connection;
protected $registry;
protected function __construct(registry $registry) protected function __construct(registry $registry)
{ {
$this->registry = $registry;
try { try {
$dsn = sprintf('mysql:host=%s;port=%s;', $registry->get('GV_sphinx_rt_host'), $registry->get('GV_sphinx_rt_port')); $dsn = sprintf('mysql:host=%s;port=%s;', $registry->get('GV_sphinx_rt_host'), $registry->get('GV_sphinx_rt_port'));
$this->connection = @new PDO($dsn); $this->connection = @new PDO($dsn);
@@ -64,7 +66,7 @@ class sphinxrt
$cl = new SphinxClient(); $cl = new SphinxClient();
$cl->SetServer($registry->get('GV_sphinx_host'), (int) $registry->get('GV_sphinx_port')); $cl->SetServer($this->registry->get('GV_sphinx_host'), (int) $this->registry->get('GV_sphinx_port'));
$cl->SetConnectTimeout(1); $cl->SetConnectTimeout(1);
foreach ($index_ids as $index_id) foreach ($index_ids as $index_id)
@@ -92,7 +94,7 @@ class sphinxrt
return $this; return $this;
} }
$cl->SetServer($registry->get('GV_sphinx_host'), (int) $registry->get('GV_sphinx_port')); $cl->SetServer($this->registry->get('GV_sphinx_host'), (int) $this->registry->get('GV_sphinx_port'));
$cl->SetConnectTimeout(1); $cl->SetConnectTimeout(1);
$status = strrev($status); $status = strrev($status);