Fix failing tests

- SQL query error
- Reload updated collections in tests (error in test logic)
This commit is contained in:
Thibaud Fabre
2016-01-07 18:57:19 +01:00
parent bf524dac0c
commit 74366feac3
4 changed files with 25 additions and 6 deletions

View File

@@ -333,7 +333,7 @@ class RegistrationService
return;
}
$collection = \collection::get_from_base_id($this->app, $baseId);
$collection = \collection::getByBaseId($this->app, $baseId);
$registrationManipulator->createRegistration($user, $collection);
$successfulRegistrations[$baseId] = $collection;
});

View File

@@ -66,14 +66,22 @@ class DbalCollectionRepository implements CollectionRepository
public function findAll()
{
$references = $this->referenceRepository->findAllByDatabox($this->databoxId);
$params = [];
foreach ($references as $reference) {
$params[':id_' . $reference->getCollectionId()] = $reference->getCollectionId();
if (empty($references)) {
return [];
}
$query = self::$selectQuery . sprintf(' WHERE coll_id IN (%s)', implode(', ', array_keys($params)));
$rows = $this->connection->fetchAll($query, $params);
$parameters = [];
foreach ($references as $reference) {
$parameters[] = $reference->getCollectionId();
}
$query = self::$selectQuery . ' WHERE coll_id IN (:collectionIds)';
$parameters = [ 'collectionIds' => $parameters ];
$parameterTypes = [ 'collectionIds' => Connection::PARAM_INT_ARRAY ];
$rows = $this->connection->fetchAll($query, $parameters, $parameterTypes);
return $this->collectionFactory->createMany($this->databoxId, $references, $rows);
}

View File

@@ -439,7 +439,13 @@ class AdminCollectionTest extends \PhraseanetAuthenticatedWebTestCase
$json = $this->getJson(self::$DI['client']->getResponse());
$this->assertTrue($json->success);
// Collection has to be reloaded since it was modified outside of the current process
$databox = $this->getApplication()->findDataboxById($collection->get_sbas_id());
$collection = \collection::getByCollectionId($this->getApplication(), $databox, $collection->get_coll_id());
$this->assertEquals($collection->get_name(), 'test_rename_coll');
$collection->unmount();
$collection->delete();
}
@@ -465,6 +471,10 @@ class AdminCollectionTest extends \PhraseanetAuthenticatedWebTestCase
$json = $this->getJson(self::$DI['client']->getResponse());
$this->assertTrue($json->success);
$databox = $this->getApplication()->findDataboxById($collection->get_sbas_id());
$collection = \collection::getByCollectionId($this->getApplication(), $databox, $collection->get_coll_id());
$this->assertEquals($collection->get_label('de'), 'german label');
$this->assertEquals($collection->get_label('nl'), 'netherlands label');
$this->assertEquals($collection->get_label('fr'), 'label français');

View File

@@ -173,6 +173,7 @@ class UploadTest extends \PhraseanetAuthenticatedWebTestCase
)
]
];
self::$DI['app']['border-manager']->registerChecker(new Sha256(self::$DI['app']));
self::$DI['client']->request('POST', '/prod/upload/', $params, $files, ['HTTP_Accept' => 'application/json']);