summaryrefslogtreecommitdiffstats
path: root/tests/lib/AppFramework/Db
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lib/AppFramework/Db')
-rw-r--r--tests/lib/AppFramework/Db/EntityTest.php30
-rw-r--r--tests/lib/AppFramework/Db/MapperTest.php46
-rw-r--r--tests/lib/AppFramework/Db/MapperTestUtility.php10
3 files changed, 43 insertions, 43 deletions
diff --git a/tests/lib/AppFramework/Db/EntityTest.php b/tests/lib/AppFramework/Db/EntityTest.php
index b2113789810..faff2649bc6 100644
--- a/tests/lib/AppFramework/Db/EntityTest.php
+++ b/tests/lib/AppFramework/Db/EntityTest.php
@@ -71,7 +71,7 @@ class EntityTest extends \Test\TestCase {
}
- public function testResetUpdatedFields(){
+ public function testResetUpdatedFields() {
$entity = new TestEntity();
$entity->setId(3);
$entity->resetUpdatedFields();
@@ -80,7 +80,7 @@ class EntityTest extends \Test\TestCase {
}
- public function testFromRow(){
+ public function testFromRow() {
$row = [
'pre_name' => 'john',
'email' => 'john@something.com'
@@ -92,7 +92,7 @@ class EntityTest extends \Test\TestCase {
}
- public function testGetSetId(){
+ public function testGetSetId() {
$id = 3;
$this->entity->setId(3);
@@ -100,28 +100,28 @@ class EntityTest extends \Test\TestCase {
}
- public function testColumnToPropertyNoReplacement(){
+ public function testColumnToPropertyNoReplacement() {
$column = 'my';
$this->assertEquals('my',
$this->entity->columnToProperty($column));
}
- public function testColumnToProperty(){
+ public function testColumnToProperty() {
$column = 'my_attribute';
$this->assertEquals('myAttribute',
$this->entity->columnToProperty($column));
}
- public function testPropertyToColumnNoReplacement(){
+ public function testPropertyToColumnNoReplacement() {
$property = 'my';
$this->assertEquals('my',
$this->entity->propertyToColumn($property));
}
- public function testSetterMarksFieldUpdated(){
+ public function testSetterMarksFieldUpdated() {
$this->entity->setId(3);
$this->assertContains('id', $this->entity->getUpdatedFields());
@@ -129,7 +129,7 @@ class EntityTest extends \Test\TestCase {
- public function testCallShouldOnlyWorkForGetterSetter(){
+ public function testCallShouldOnlyWorkForGetterSetter() {
$this->expectException(\BadFunctionCallException::class);
$this->entity->something();
@@ -137,21 +137,21 @@ class EntityTest extends \Test\TestCase {
- public function testGetterShouldFailIfAttributeNotDefined(){
+ public function testGetterShouldFailIfAttributeNotDefined() {
$this->expectException(\BadFunctionCallException::class);
$this->entity->getTest();
}
- public function testSetterShouldFailIfAttributeNotDefined(){
+ public function testSetterShouldFailIfAttributeNotDefined() {
$this->expectException(\BadFunctionCallException::class);
$this->entity->setTest();
}
- public function testFromRowShouldNotAssignEmptyArray(){
+ public function testFromRowShouldNotAssignEmptyArray() {
$row = [];
$entity2 = new TestEntity();
@@ -160,7 +160,7 @@ class EntityTest extends \Test\TestCase {
}
- public function testIdGetsConvertedToInt(){
+ public function testIdGetsConvertedToInt() {
$row = ['id' => '4'];
$this->entity = TestEntity::fromRow($row);
@@ -168,7 +168,7 @@ class EntityTest extends \Test\TestCase {
}
- public function testSetType(){
+ public function testSetType() {
$row = ['testId' => '4'];
$this->entity = TestEntity::fromRow($row);
@@ -176,7 +176,7 @@ class EntityTest extends \Test\TestCase {
}
- public function testFromParams(){
+ public function testFromParams() {
$params = [
'testId' => 4,
'email' => 'john@doe'
@@ -189,7 +189,7 @@ class EntityTest extends \Test\TestCase {
$this->assertTrue($entity instanceof TestEntity);
}
- public function testSlugify(){
+ public function testSlugify() {
$entity = new TestEntity();
$entity->setName('Slugify this!');
$this->assertEquals('slugify-this', $entity->slugify('name'));
diff --git a/tests/lib/AppFramework/Db/MapperTest.php b/tests/lib/AppFramework/Db/MapperTest.php
index 79a9a1884e0..4509b1b80c7 100644
--- a/tests/lib/AppFramework/Db/MapperTest.php
+++ b/tests/lib/AppFramework/Db/MapperTest.php
@@ -44,12 +44,12 @@ class Example extends Entity {
class ExampleMapper extends Mapper {
- public function __construct(IDBConnection $db){ parent::__construct($db, 'table'); }
- public function find($table, $id){ return $this->findOneQuery($table, $id); }
- public function findOneEntity($table, $id){ return $this->findEntity($table, $id); }
- public function findAllEntities($table){ return $this->findEntities($table); }
- public function mapRow($row){ return $this->mapRowToEntity($row); }
- public function execSql($sql, $params){ return $this->execute($sql, $params); }
+ public function __construct(IDBConnection $db) { parent::__construct($db, 'table'); }
+ public function find($table, $id) { return $this->findOneQuery($table, $id); }
+ public function findOneEntity($table, $id) { return $this->findEntity($table, $id); }
+ public function findAllEntities($table) { return $this->findEntities($table); }
+ public function mapRow($row) { return $this->mapRowToEntity($row); }
+ public function execSql($sql, $params) { return $this->execute($sql, $params); }
}
@@ -66,12 +66,12 @@ class MapperTest extends MapperTestUtility {
}
- public function testMapperShouldSetTableName(){
+ public function testMapperShouldSetTableName() {
$this->assertEquals('*PREFIX*table', $this->mapper->getTableName());
}
- public function testFindQuery(){
+ public function testFindQuery() {
$sql = 'hi';
$params = ['jo'];
$rows = [
@@ -81,7 +81,7 @@ class MapperTest extends MapperTestUtility {
$this->mapper->find($sql, $params);
}
- public function testFindEntity(){
+ public function testFindEntity() {
$sql = 'hi';
$params = ['jo'];
$rows = [
@@ -91,7 +91,7 @@ class MapperTest extends MapperTestUtility {
$this->mapper->findOneEntity($sql, $params);
}
- public function testFindNotFound(){
+ public function testFindNotFound() {
$sql = 'hi';
$params = ['jo'];
$rows = [];
@@ -100,7 +100,7 @@ class MapperTest extends MapperTestUtility {
$this->mapper->find($sql, $params);
}
- public function testFindEntityNotFound(){
+ public function testFindEntityNotFound() {
$sql = 'hi';
$params = ['jo'];
$rows = [];
@@ -109,7 +109,7 @@ class MapperTest extends MapperTestUtility {
$this->mapper->findOneEntity($sql, $params);
}
- public function testFindMultiple(){
+ public function testFindMultiple() {
$sql = 'hi';
$params = ['jo'];
$rows = [
@@ -120,7 +120,7 @@ class MapperTest extends MapperTestUtility {
$this->mapper->find($sql, $params);
}
- public function testFindEntityMultiple(){
+ public function testFindEntityMultiple() {
$sql = 'hi';
$params = ['jo'];
$rows = [
@@ -132,7 +132,7 @@ class MapperTest extends MapperTestUtility {
}
- public function testDelete(){
+ public function testDelete() {
$sql = 'DELETE FROM `*PREFIX*table` WHERE `id` = ?';
$params = [2];
@@ -144,7 +144,7 @@ class MapperTest extends MapperTestUtility {
}
- public function testCreate(){
+ public function testCreate() {
$this->db->expects($this->once())
->method('lastInsertId')
->with($this->equalTo('*PREFIX*table'))
@@ -164,7 +164,7 @@ class MapperTest extends MapperTestUtility {
}
- public function testCreateShouldReturnItemWithCorrectInsertId(){
+ public function testCreateShouldReturnItemWithCorrectInsertId() {
$this->db->expects($this->once())
->method('lastInsertId')
->with($this->equalTo('*PREFIX*table'))
@@ -195,7 +195,7 @@ class MapperTest extends MapperTestUtility {
}
- public function testUpdate(){
+ public function testUpdate() {
$sql = 'UPDATE `*PREFIX*table` ' .
'SET ' .
'`pre_name` = ?,'.
@@ -214,7 +214,7 @@ class MapperTest extends MapperTestUtility {
}
- public function testUpdateNoId(){
+ public function testUpdateNoId() {
$params = ['john', 'my@email'];
$entity = new Example();
$entity->setPreName($params[0]);
@@ -226,7 +226,7 @@ class MapperTest extends MapperTestUtility {
}
- public function testUpdateNothingChangedNoQuery(){
+ public function testUpdateNothingChangedNoQuery() {
$params = ['john', 'my@email'];
$entity = new Example();
$entity->setId(3);
@@ -240,7 +240,7 @@ class MapperTest extends MapperTestUtility {
}
- public function testMapRowToEntity(){
+ public function testMapRowToEntity() {
$entity1 = $this->mapper->mapRow(['pre_name' => 'test1', 'email' => 'test2']);
$entity2 = new Example();
$entity2->setPreName('test1');
@@ -249,7 +249,7 @@ class MapperTest extends MapperTestUtility {
$this->assertEquals($entity2, $entity1);
}
- public function testFindEntities(){
+ public function testFindEntities() {
$sql = 'hi';
$rows = [
['pre_name' => 'hi']
@@ -262,7 +262,7 @@ class MapperTest extends MapperTestUtility {
$this->assertEquals([$entity], $result);
}
- public function testFindEntitiesNotFound(){
+ public function testFindEntitiesNotFound() {
$sql = 'hi';
$rows = [];
$this->setMapperResult($sql, [], $rows);
@@ -270,7 +270,7 @@ class MapperTest extends MapperTestUtility {
$this->assertEquals([], $result);
}
- public function testFindEntitiesMultiple(){
+ public function testFindEntitiesMultiple() {
$sql = 'hi';
$rows = [
['pre_name' => 'jo'], ['email' => 'ho']
diff --git a/tests/lib/AppFramework/Db/MapperTestUtility.php b/tests/lib/AppFramework/Db/MapperTestUtility.php
index ebcc4a11e26..9ee83e5a161 100644
--- a/tests/lib/AppFramework/Db/MapperTestUtility.php
+++ b/tests/lib/AppFramework/Db/MapperTestUtility.php
@@ -89,7 +89,7 @@ abstract class MapperTestUtility extends \Test\TestCase {
* will be called on the result
*/
protected function setMapperResult($sql, $arguments=[], $returnRows=[],
- $limit=null, $offset=null, $expectClose=false){
+ $limit=null, $offset=null, $expectClose=false) {
if($limit === null && $offset === null) {
$this->db->expects($this->at($this->prepareAt))
->method('prepare')
@@ -124,7 +124,7 @@ abstract class MapperTestUtility extends \Test\TestCase {
$this->query->expects($this->any())
->method('fetch')
->willReturnCallback(
- function() use ($iterators, $fetchAt){
+ function () use ($iterators, $fetchAt) {
$iterator = $iterators[$fetchAt];
$result = $iterator->next();
@@ -164,7 +164,7 @@ abstract class MapperTestUtility extends \Test\TestCase {
$this->query->expects($this->at($this->queryAt))
->method('execute')
- ->willReturnCallback(function($sql, $p=null, $o=null, $s=null) {
+ ->willReturnCallback(function ($sql, $p=null, $o=null, $s=null) {
});
$this->queryAt++;
@@ -191,11 +191,11 @@ class ArgumentIterator {
private $arguments;
- public function __construct($arguments){
+ public function __construct($arguments) {
$this->arguments = $arguments;
}
- public function next(){
+ public function next() {
$result = array_shift($this->arguments);
if($result === null){
return false;