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);
break;
case \registry::TYPE_INTEGER:
$val = (int) $val;
break;
case \registry::TYPE_BOOLEAN:
$val = $val ? '1' : '0';
break;
case \registry::TYPE_STRING:
$val = (int) $val;
default:
$val = (string) $val;
$type = \registry::TYPE_STRING;

View File

@@ -665,8 +665,9 @@ class ACL implements cache_cacheableInterface
foreach ($databox->get_collections() as $collection) {
$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;
}
$base_id = $collection->get_base_id();
$datas = $this->_rights_bas[$base_id];
@@ -677,12 +678,13 @@ class ACL implements cache_cacheableInterface
break;
}
}
if ($continue || $this->is_limited($base_id))
if ($continue || $this->is_limited($base_id)) {
continue;
}
try {
$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';
$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);
$stmt->closeCursor();
unset($stmt);

View File

@@ -322,6 +322,21 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
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

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());
}
} catch (Exception $e) {
} catch (\Exception $e) {
unset($e);
}

View File

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

View File

@@ -24,12 +24,17 @@ class sphinxrt
protected function __construct(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 {
$dsn = sprintf('mysql:host=%s;port=%s;', $registry->get('GV_sphinx_rt_host'), $registry->get('GV_sphinx_rt_port'));
$this->connection = @new PDO($dsn);
} catch (Exception $e) {
} catch (\Exception $e) {
self::$_failure = true;
throw new Exception('Unable to connect to sphinx rt');
throw new \Exception('Unable to connect to sphinx rt');
}
return $this;

View File

@@ -27,7 +27,10 @@ class InstallerTest extends \PHPUnit_Framework_TestCase
public static function tearDownAfterClass()
{
$app = new Application('test');
\connection::close_connections();
\phrasea::reset_sbasDatas($app['phraseanet.appbox']);
\phrasea::reset_baseDatas($app['phraseanet.appbox']);
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->install();
\User_Adapter::unsetInstances();
$this->assertTrue($specifications->isSetup());
$this->assertTrue($app['phraseanet.configuration-tester']->isUpToDate());
}