Fix tests

This commit is contained in:
Romain Neutron
2012-10-03 20:30:05 +02:00
parent 1b2d004098
commit 004216bfc6
8 changed files with 36 additions and 14 deletions

View File

@@ -103,12 +103,12 @@ class Migration31 implements MigrationInterface
$val = serialize($val); $val = serialize($val);
break; break;
case \registry::TYPE_INTEGER: case \registry::TYPE_INTEGER:
$val = (int) $val;
break; break;
case \registry::TYPE_BOOLEAN: case \registry::TYPE_BOOLEAN:
$val = $val ? '1' : '0'; $val = $val ? '1' : '0';
break; break;
case \registry::TYPE_STRING: case \registry::TYPE_STRING:
$val = (int) $val;
default: default:
$val = (string) $val; $val = (string) $val;
$type = \registry::TYPE_STRING; $type = \registry::TYPE_STRING;

View File

@@ -665,8 +665,9 @@ class ACL implements cache_cacheableInterface
foreach ($databox->get_collections() as $collection) { foreach ($databox->get_collections() as $collection) {
$continue = false; $continue = false;
if (!array_key_exists($collection->get_base_id(), $this->_rights_bas)) if (!array_key_exists($collection->get_base_id(), $this->_rights_bas)) {
continue; continue;
}
$base_id = $collection->get_base_id(); $base_id = $collection->get_base_id();
$datas = $this->_rights_bas[$base_id]; $datas = $this->_rights_bas[$base_id];
@@ -677,12 +678,13 @@ class ACL implements cache_cacheableInterface
break; break;
} }
} }
if ($continue || $this->is_limited($base_id)) if ($continue || $this->is_limited($base_id)) {
continue; continue;
}
try { try {
$ret[$base_id] = collection::get_from_base_id($this->app, $base_id); $ret[$base_id] = collection::get_from_base_id($this->app, $base_id);
} catch (Exception $e) { } catch (\Exception $e) {
} }
} }
@@ -823,7 +825,7 @@ class ACL implements cache_cacheableInterface
FROM usr WHERE usr_id = :usr_id'; FROM usr WHERE usr_id = :usr_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute(array(':usr_id' => $this->user->get_id())); $stmt->execute(array(':usr_id' => $this->user->get_id()));
$row = $stmt->fetch(PDO::FETCH_ASSOC); $row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor(); $stmt->closeCursor();
unset($stmt); unset($stmt);

View File

@@ -322,6 +322,21 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
return $this; return $this;
} }
public static function unsetInstances()
{
foreach (self::$_instance as $id => $user) {
self::unsetInstance($id);
}
}
public static function unsetInstance($id)
{
if (isset(self::$_instance[$id])) {
self::$_instance[$id] = null;
unset(self::$_instance[$id]);
}
}
/** /**
* *
* @param type $id * @param type $id

View File

@@ -542,7 +542,7 @@ class User_Query implements User_QueryInterface
$sql_count = 'SELECT COUNT(DISTINCT usr.usr_id) as total ' $sql_count = 'SELECT COUNT(DISTINCT usr.usr_id) as total '
. $this->generate_sql_constraints(); . $this->generate_sql_constraints();
$stmt = $conn->prepare($sql_count); $stmt = $conn->prepare($sql_count);
$stmt->execute($this->sql_params); $stmt->execute($this->sql_params);
$row = $stmt->fetch(PDO::FETCH_ASSOC); $row = $stmt->fetch(PDO::FETCH_ASSOC);

View File

@@ -1617,7 +1617,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
} }
$sphinx_rt->delete(array("documents" . $sbas_crc, "documents" . $sbas_crc . "_stemmed_fr", "documents" . $sbas_crc . "_stemmed_en"), "docs_realtime" . $sbas_crc, $this->get_record_id()); $sphinx_rt->delete(array("documents" . $sbas_crc, "documents" . $sbas_crc . "_stemmed_fr", "documents" . $sbas_crc . "_stemmed_en"), "docs_realtime" . $sbas_crc, $this->get_record_id());
} }
} catch (Exception $e) { } catch (\Exception $e) {
unset($e); unset($e);
} }

View File

@@ -25,11 +25,6 @@ class registry implements registryInterface
*/ */
protected $cache; protected $cache;
/**
*
* @var registry
*/
protected static $_instance;
protected $app; protected $app;
const TYPE_BOOLEAN = 'boolean'; const TYPE_BOOLEAN = 'boolean';

View File

@@ -24,12 +24,17 @@ class sphinxrt
protected function __construct(registry $registry) protected function __construct(registry $registry)
{ {
$this->registry = $registry; $this->registry = $registry;
if(!$registry->get('GV_sphinx') || !$registry->get('GV_sphinx_rt_host') || !$registry->get('GV_sphinx_rt_port')) {
throw new \Exception('Sphinx not configured');
}
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);
} catch (Exception $e) { } catch (\Exception $e) {
self::$_failure = true; self::$_failure = true;
throw new Exception('Unable to connect to sphinx rt'); throw new \Exception('Unable to connect to sphinx rt');
} }
return $this; return $this;

View File

@@ -27,7 +27,10 @@ class InstallerTest extends \PHPUnit_Framework_TestCase
public static function tearDownAfterClass() public static function tearDownAfterClass()
{ {
$app = new Application('test');
\connection::close_connections(); \connection::close_connections();
\phrasea::reset_sbasDatas($app['phraseanet.appbox']);
\phrasea::reset_baseDatas($app['phraseanet.appbox']);
parent::tearDownAfterClass(); parent::tearDownAfterClass();
} }
@@ -54,6 +57,8 @@ class InstallerTest extends \PHPUnit_Framework_TestCase
$installer = new Installer($app, 'admin@example.com', 'sdfsdsd', $abConn, 'http://local.phrasea.test.installer/', $dataPath, $dbConn, $template); $installer = new Installer($app, 'admin@example.com', 'sdfsdsd', $abConn, 'http://local.phrasea.test.installer/', $dataPath, $dbConn, $template);
$installer->install(); $installer->install();
\User_Adapter::unsetInstances();
$this->assertTrue($specifications->isSetup()); $this->assertTrue($specifications->isSetup());
$this->assertTrue($app['phraseanet.configuration-tester']->isUpToDate()); $this->assertTrue($app['phraseanet.configuration-tester']->isUpToDate());
} }