diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 41480ac..6014301 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -4,9 +4,6 @@
src
-
- src/TestHelpers
-
diff --git a/psalm-baseline.xml b/psalm-baseline.xml
index 9c1fb5d..1fa8ead 100644
--- a/psalm-baseline.xml
+++ b/psalm-baseline.xml
@@ -1,5 +1,5 @@
-
+
bool[]
@@ -23,4 +23,31 @@
$select['offset'] ?? null
+
+
+ \Mockery::mock(DBPassToLowerLayerTrait::class)->makePartial()
+
+
+ $this->dbLowerLayerObject
+ \Mockery::mock(DBPassToLowerLayerTrait::class)
+
+
+ setLowerLayer
+
+
+
+
+ $accountData['balance']
+ $accountData['balance']
+
+
+ fetchOne
+ insert
+
+
+
+
+ \is_resource($obj->getStream())
+
+
diff --git a/psalm.xml b/psalm.xml
index e85162d..7e74beb 100644
--- a/psalm.xml
+++ b/psalm.xml
@@ -8,8 +8,46 @@
>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/TestHelpers/DBInterfaceForTests.php b/src/TestHelpers/DBInterfaceForTests.php
deleted file mode 100644
index a7c65c9..0000000
--- a/src/TestHelpers/DBInterfaceForTests.php
+++ /dev/null
@@ -1,27 +0,0 @@
-db = \Mockery::mock(DBInterface::class);
}
- public function testNoDataGetEntries()
+ public function testNoDataGetEntries(): void
{
$countBuilder = new CountEntries($this->db);
@@ -41,7 +40,7 @@ public function testNoDataGetEntries()
$this->assertSame($expectedResult[0], $results);
}
- public function testGetEntries()
+ public function testGetEntries(): void
{
$countBuilder = new CountEntries($this->db);
@@ -79,7 +78,7 @@ public function testGetEntries()
$this->assertSame($expectedResult[0], $results);
}
- public function testGetEntriesSingular()
+ public function testGetEntriesSingular(): void
{
$countBuilder = new CountEntries($this->db);
diff --git a/tests/Builder/DeleteEntriesTest.php b/tests/Builder/DeleteEntriesTest.php
index 5e5eba0..f02907c 100644
--- a/tests/Builder/DeleteEntriesTest.php
+++ b/tests/Builder/DeleteEntriesTest.php
@@ -2,23 +2,22 @@
namespace Squirrel\Queries\Tests\Builder;
+use Mockery\MockInterface;
use Squirrel\Queries\Builder\DeleteEntries;
use Squirrel\Queries\DBInterface;
use Squirrel\Queries\Exception\DBInvalidOptionException;
class DeleteEntriesTest extends \PHPUnit\Framework\TestCase
{
- /**
- * @var DBInterface
- */
- private $db;
+ /** @var DBInterface&MockInterface */
+ private DBInterface $db;
protected function setUp(): void
{
$this->db = \Mockery::mock(DBInterface::class);
}
- public function testNoDataGetEntries()
+ public function testNoDataGetEntries(): void
{
$deleteBuilder = new DeleteEntries($this->db);
@@ -37,7 +36,7 @@ public function testNoDataGetEntries()
$this->assertTrue(true);
}
- public function testNoDataGetEntriesWithAffected()
+ public function testNoDataGetEntriesWithAffected(): void
{
$deleteBuilder = new DeleteEntries($this->db);
@@ -56,7 +55,7 @@ public function testNoDataGetEntriesWithAffected()
$this->assertSame($expectedResult, $results);
}
- public function testGetEntries()
+ public function testGetEntries(): void
{
$deleteBuilder = new DeleteEntries($this->db);
@@ -82,7 +81,7 @@ public function testGetEntries()
$this->assertSame($expectedResult, $results);
}
- public function testNoWhereNoConfirmation()
+ public function testNoWhereNoConfirmation(): void
{
$this->expectException(DBInvalidOptionException::class);
diff --git a/tests/Builder/InsertEntryTest.php b/tests/Builder/InsertEntryTest.php
index 7aba672..484acec 100644
--- a/tests/Builder/InsertEntryTest.php
+++ b/tests/Builder/InsertEntryTest.php
@@ -2,22 +2,21 @@
namespace Squirrel\Queries\Tests\Builder;
+use Mockery\MockInterface;
use Squirrel\Queries\Builder\InsertEntry;
use Squirrel\Queries\DBInterface;
class InsertEntryTest extends \PHPUnit\Framework\TestCase
{
- /**
- * @var DBInterface
- */
- private $db;
+ /** @var DBInterface&MockInterface */
+ private DBInterface $db;
protected function setUp(): void
{
$this->db = \Mockery::mock(DBInterface::class);
}
- public function testNoDataInsert()
+ public function testNoDataInsert(): void
{
$insertBuilder = new InsertEntry($this->db);
@@ -33,7 +32,7 @@ public function testNoDataInsert()
$this->assertTrue(true);
}
- public function testInsert()
+ public function testInsert(): void
{
$insertBuilder = new InsertEntry($this->db);
@@ -58,7 +57,7 @@ public function testInsert()
$this->assertTrue(true);
}
- public function testInsertWithNewId()
+ public function testInsertWithNewId(): void
{
$insertBuilder = new InsertEntry($this->db);
diff --git a/tests/Builder/InsertOrUpdateEntryTest.php b/tests/Builder/InsertOrUpdateEntryTest.php
index 2405cf2..40d65d3 100644
--- a/tests/Builder/InsertOrUpdateEntryTest.php
+++ b/tests/Builder/InsertOrUpdateEntryTest.php
@@ -2,22 +2,21 @@
namespace Squirrel\Queries\Tests\Builder;
+use Mockery\MockInterface;
use Squirrel\Queries\Builder\InsertOrUpdateEntry;
use Squirrel\Queries\DBInterface;
class InsertOrUpdateEntryTest extends \PHPUnit\Framework\TestCase
{
- /**
- * @var DBInterface
- */
- private $db;
+ /** @var DBInterface&MockInterface */
+ private DBInterface $db;
protected function setUp(): void
{
$this->db = \Mockery::mock(DBInterface::class);
}
- public function testNoDataInsert()
+ public function testNoDataInsert(): void
{
$insertBuilder = new InsertOrUpdateEntry($this->db);
@@ -33,7 +32,7 @@ public function testNoDataInsert()
$this->assertTrue(true);
}
- public function testInsert()
+ public function testInsert(): void
{
$insertBuilder = new InsertOrUpdateEntry($this->db);
@@ -68,7 +67,7 @@ public function testInsert()
$this->assertTrue(true);
}
- public function testInsertWithReturn()
+ public function testInsertWithReturn(): void
{
$insertBuilder = new InsertOrUpdateEntry($this->db);
@@ -103,7 +102,7 @@ public function testInsertWithReturn()
$this->assertTrue(true);
}
- public function testUpdateWithReturn()
+ public function testUpdateWithReturn(): void
{
$insertBuilder = new InsertOrUpdateEntry($this->db);
@@ -134,7 +133,7 @@ public function testUpdateWithReturn()
$this->assertTrue(true);
}
- public function testNoChangeWithReturn()
+ public function testNoChangeWithReturn(): void
{
$insertBuilder = new InsertOrUpdateEntry($this->db);
diff --git a/tests/Builder/SelectEntriesTest.php b/tests/Builder/SelectEntriesTest.php
index 094d613..468f551 100644
--- a/tests/Builder/SelectEntriesTest.php
+++ b/tests/Builder/SelectEntriesTest.php
@@ -2,6 +2,7 @@
namespace Squirrel\Queries\Tests\Builder;
+use Mockery\MockInterface;
use Squirrel\Queries\Builder\SelectEntries;
use Squirrel\Queries\Builder\SelectIterator;
use Squirrel\Queries\DBInterface;
@@ -9,17 +10,15 @@
class SelectEntriesTest extends \PHPUnit\Framework\TestCase
{
- /**
- * @var DBInterface
- */
- private $db;
+ /** @var DBInterface&MockInterface */
+ private DBInterface $db;
protected function setUp(): void
{
$this->db = \Mockery::mock(DBInterface::class);
}
- public function testNoDataGetEntries()
+ public function testNoDataGetEntries(): void
{
$selectBuilder = new SelectEntries($this->db);
@@ -45,7 +44,7 @@ public function testNoDataGetEntries()
$this->assertSame($expectedResult, $results);
}
- public function testGetEntries()
+ public function testGetEntries(): void
{
$selectBuilder = new SelectEntries($this->db);
@@ -104,7 +103,7 @@ public function testGetEntries()
$this->assertSame($expectedResult, $results);
}
- public function testGetEntriesSingular()
+ public function testGetEntriesSingular(): void
{
$selectBuilder = new SelectEntries($this->db);
@@ -151,7 +150,7 @@ public function testGetEntriesSingular()
$this->assertSame($expectedResult, $results);
}
- public function testOneEntry()
+ public function testOneEntry(): void
{
$selectBuilder = new SelectEntries($this->db);
@@ -209,7 +208,7 @@ public function testOneEntry()
$this->assertSame($expectedResult, $results);
}
- public function testIterator()
+ public function testIterator(): void
{
$selectBuilder = new SelectEntries($this->db);
@@ -264,7 +263,7 @@ public function testIterator()
$this->assertEquals($expectedResult, $results);
}
- public function testGetFlattenedFields()
+ public function testGetFlattenedFields(): void
{
$selectBuilder = new SelectEntries($this->db);
@@ -323,7 +322,7 @@ public function testGetFlattenedFields()
$this->assertSame($expectedResult, $results);
}
- public function testGetFlattenedIntegerFields()
+ public function testGetFlattenedIntegerFields(): void
{
$selectBuilder = new SelectEntries($this->db);
@@ -380,7 +379,7 @@ public function testGetFlattenedIntegerFields()
$this->assertSame([4, 5, 1, 9], $selectBuilder->getFlattenedIntegerFields());
}
- public function testGetFlattenedFloatFields()
+ public function testGetFlattenedFloatFields(): void
{
$selectBuilder = new SelectEntries($this->db);
@@ -437,7 +436,7 @@ public function testGetFlattenedFloatFields()
$this->assertSame([1.3, 5.0, 5.3, 5.3], $selectBuilder->getFlattenedFloatFields());
}
- public function testGetFlattenedStringFields()
+ public function testGetFlattenedStringFields(): void
{
$selectBuilder = new SelectEntries($this->db);
@@ -494,7 +493,7 @@ public function testGetFlattenedStringFields()
$this->assertSame(['one', '5', '5.3', 'true'], $selectBuilder->getFlattenedStringFields());
}
- public function testGetFlattenedBooleanFields()
+ public function testGetFlattenedBooleanFields(): void
{
$selectBuilder = new SelectEntries($this->db);
@@ -551,7 +550,7 @@ public function testGetFlattenedBooleanFields()
$this->assertSame([true, false, true, false, true, false], $selectBuilder->getFlattenedBooleanFields());
}
- public function testGetFlattenedIntegerFieldsWrongScalarType()
+ public function testGetFlattenedIntegerFieldsWrongScalarType(): void
{
$this->expectException(DBInvalidOptionException::class);
@@ -610,7 +609,7 @@ public function testGetFlattenedIntegerFieldsWrongScalarType()
$selectBuilder->getFlattenedIntegerFields();
}
- public function testGetFlattenedIntegerFieldsWrongNonNumberType()
+ public function testGetFlattenedIntegerFieldsWrongNonNumberType(): void
{
$this->expectException(DBInvalidOptionException::class);
@@ -669,7 +668,7 @@ public function testGetFlattenedIntegerFieldsWrongNonNumberType()
$selectBuilder->getFlattenedIntegerFields();
}
- public function testGetFlattenedFloatFieldsWrongScalarType()
+ public function testGetFlattenedFloatFieldsWrongScalarType(): void
{
$this->expectException(DBInvalidOptionException::class);
@@ -728,7 +727,7 @@ public function testGetFlattenedFloatFieldsWrongScalarType()
$selectBuilder->getFlattenedFloatFields();
}
- public function testGetFlattenedFloatFieldsWrongNonNumberType()
+ public function testGetFlattenedFloatFieldsWrongNonNumberType(): void
{
$this->expectException(DBInvalidOptionException::class);
@@ -787,7 +786,7 @@ public function testGetFlattenedFloatFieldsWrongNonNumberType()
$selectBuilder->getFlattenedFloatFields();
}
- public function testGetFlattenedBooleanFieldsWrongType()
+ public function testGetFlattenedBooleanFieldsWrongType(): void
{
$this->expectException(DBInvalidOptionException::class);
@@ -846,7 +845,7 @@ public function testGetFlattenedBooleanFieldsWrongType()
$selectBuilder->getFlattenedBooleanFields();
}
- public function testGetFlattenedStringFieldsWrongType()
+ public function testGetFlattenedStringFieldsWrongType(): void
{
$this->expectException(DBInvalidOptionException::class);
diff --git a/tests/Builder/SelectIteratorTest.php b/tests/Builder/SelectIteratorTest.php
index 11007d6..6bfca84 100644
--- a/tests/Builder/SelectIteratorTest.php
+++ b/tests/Builder/SelectIteratorTest.php
@@ -2,21 +2,17 @@
namespace Squirrel\Queries\Tests\Builder;
+use Mockery\MockInterface;
use Squirrel\Queries\Builder\SelectIterator;
use Squirrel\Queries\DBInterface;
use Squirrel\Queries\DBSelectQueryInterface;
class SelectIteratorTest extends \PHPUnit\Framework\TestCase
{
- /**
- * @var DBInterface
- */
- private $db;
+ /** @var DBInterface&MockInterface */
+ private DBInterface $db;
- /**
- * @var array
- */
- private $query;
+ private array $query = [];
protected function setUp(): void
{
@@ -45,7 +41,7 @@ protected function setUp(): void
];
}
- public function testLoop()
+ public function testLoop(): void
{
$selectQuery = \Mockery::mock(DBSelectQueryInterface::class);
diff --git a/tests/Builder/UpdateEntriesTest.php b/tests/Builder/UpdateEntriesTest.php
index da2b8b4..1217f30 100644
--- a/tests/Builder/UpdateEntriesTest.php
+++ b/tests/Builder/UpdateEntriesTest.php
@@ -2,23 +2,22 @@
namespace Squirrel\Queries\Tests\Builder;
+use Mockery\MockInterface;
use Squirrel\Queries\Builder\UpdateEntries;
use Squirrel\Queries\DBInterface;
use Squirrel\Queries\Exception\DBInvalidOptionException;
class UpdateEntriesTest extends \PHPUnit\Framework\TestCase
{
- /**
- * @var DBInterface
- */
- private $db;
+ /** @var DBInterface&MockInterface */
+ private DBInterface $db;
protected function setUp(): void
{
$this->db = \Mockery::mock(DBInterface::class);
}
- public function testNoDataGetEntries()
+ public function testNoDataGetEntries(): void
{
$updateBuilder = new UpdateEntries($this->db);
@@ -37,7 +36,7 @@ public function testNoDataGetEntries()
$this->assertTrue(true);
}
- public function testNoDataGetEntriesWithAffected()
+ public function testNoDataGetEntriesWithAffected(): void
{
$updateBuilder = new UpdateEntries($this->db);
@@ -56,7 +55,7 @@ public function testNoDataGetEntriesWithAffected()
$this->assertSame($expectedResult, $results);
}
- public function testGetEntries()
+ public function testGetEntries(): void
{
$updateBuilder = new UpdateEntries($this->db);
@@ -89,7 +88,7 @@ public function testGetEntries()
$this->assertSame($expectedResult, $results);
}
- public function testNoWhereNoConfirmation()
+ public function testNoWhereNoConfirmation(): void
{
$this->expectException(DBInvalidOptionException::class);
diff --git a/tests/DBBuilderTest.php b/tests/DBBuilderTest.php
index 69c924d..e8c593a 100644
--- a/tests/DBBuilderTest.php
+++ b/tests/DBBuilderTest.php
@@ -2,6 +2,8 @@
namespace Squirrel\Queries\Tests;
+use Hamcrest\Core\IsEqual;
+use Mockery\MockInterface;
use Squirrel\Queries\Builder\CountEntries;
use Squirrel\Queries\Builder\DeleteEntries;
use Squirrel\Queries\Builder\InsertEntry;
@@ -13,15 +15,9 @@
class DBBuilderTest extends \PHPUnit\Framework\TestCase
{
- /**
- * @var DBInterface
- */
- private $db;
-
- /**
- * @var DBBuilder
- */
- private $builder;
+ /** @var DBInterface&MockInterface */
+ private DBInterface $db;
+ private DBBuilder $builder;
protected function setUp(): void
{
@@ -29,42 +25,42 @@ protected function setUp(): void
$this->builder = new DBBuilder($this->db);
}
- public function testCount()
+ public function testCount(): void
{
$this->assertEquals(new CountEntries($this->db), $this->builder->count());
}
- public function testSelect()
+ public function testSelect(): void
{
$this->assertEquals(new SelectEntries($this->db), $this->builder->select());
}
- public function testInsert()
+ public function testInsert(): void
{
$this->assertEquals(new InsertEntry($this->db), $this->builder->insert());
}
- public function testInsertOrUpdate()
+ public function testInsertOrUpdate(): void
{
$this->assertEquals(new InsertOrUpdateEntry($this->db), $this->builder->insertOrUpdate());
}
- public function testUpdate()
+ public function testUpdate(): void
{
$this->assertEquals(new UpdateEntries($this->db), $this->builder->update());
}
- public function testDelete()
+ public function testDelete(): void
{
$this->assertEquals(new DeleteEntries($this->db), $this->builder->delete());
}
- public function testGetDBInterface()
+ public function testGetDBInterface(): void
{
$this->assertSame($this->db, $this->builder->getDBInterface());
}
- public function testTransaction()
+ public function testTransaction(): void
{
// The three arguments used
$a = 2;
@@ -72,15 +68,15 @@ public function testTransaction()
$c = 37;
// Transaction function to execute
- $function = function ($a, $b, $c) {
+ $function = function (int $a, int $b, int $c): int {
return $a + $b + $c;
};
$this->db
->shouldReceive('transaction')
->once()
- ->with(\Mockery::mustBe($function), \Mockery::mustBe($a), \Mockery::mustBe($b), \Mockery::mustBe($c))
- ->andReturnUsing(function ($function, $a, $b, $c) {
+ ->with(IsEqual::equalTo($function), IsEqual::equalTo($a), IsEqual::equalTo($b), IsEqual::equalTo($c))
+ ->andReturnUsing(function (callable $function, int $a, int $b, int $c): int {
return $function($a, $b, $c);
});
diff --git a/tests/DBPassToLowerLayerTest.php b/tests/DBPassToLowerLayerTest.php
index 053e012..e171a1a 100644
--- a/tests/DBPassToLowerLayerTest.php
+++ b/tests/DBPassToLowerLayerTest.php
@@ -2,24 +2,22 @@
namespace Squirrel\Queries\Tests;
+use Hamcrest\Core\IsEqual;
+use Mockery\MockInterface;
use Squirrel\Queries\DBPassToLowerLayerTrait;
use Squirrel\Queries\DBRawInterface;
-use Squirrel\Queries\TestHelpers\DBSelectQueryForTests;
+use Squirrel\Queries\DBSelectQueryInterface;
/**
* Make sure all function calls are passed to the lower layer with the trait, by default
*/
class DBPassToLowerLayerTest extends \PHPUnit\Framework\TestCase
{
- /**
- * @var DBRawInterface
- */
- private $dbRawObject;
-
- /**
- * @var DBPassToLowerLayerTrait
- */
+ /** @var DBRawInterface&MockInterface */
+ private DBRawInterface $dbRawObject;
+ /** @var DBRawInterface&MockInterface */
private $dbLowerLayerObject;
+ private DBSelectQueryInterface $dbSelectQuery;
/**
* Initialize for every test in this class
@@ -32,12 +30,15 @@ protected function setUp(): void
// Lower layer mock, where we check the function calls
$this->dbLowerLayerObject = \Mockery::mock(DBPassToLowerLayerTrait::class)->makePartial();
$this->dbLowerLayerObject->setLowerLayer($this->dbRawObject);
+
+ $this->dbSelectQuery = new class implements DBSelectQueryInterface {
+ };
}
- public function testTransaction()
+ public function testTransaction(): void
{
// Variables to pass to the function
- $func = function ($a, $b, $c) {
+ $func = function (int $a, int $b, int $c): int {
return $a + $b + $c;
};
$a = 3;
@@ -47,7 +48,7 @@ public function testTransaction()
// What we expect to be called with the lower layer
$this->dbRawObject
->shouldReceive('transaction')
- ->with(\Mockery::mustBe($func), \Mockery::mustBe($a), \Mockery::mustBe($b), \Mockery::mustBe($c))
+ ->with(IsEqual::equalTo($func), IsEqual::equalTo($a), IsEqual::equalTo($b), IsEqual::equalTo($c))
->andReturn(120);
// Make the trait function call
@@ -57,7 +58,7 @@ public function testTransaction()
$this->assertSame(120, $return);
}
- public function testInTransaction()
+ public function testInTransaction(): void
{
// What we expect to be called with the lower layer
$this->dbRawObject
@@ -71,67 +72,58 @@ public function testInTransaction()
$this->assertSame(true, $return);
}
- public function testSelect()
+ public function testSelect(): void
{
// Variables to pass to the function
$query = 'SELECT';
$vars = [0, 3, 9];
- // Select query result
- $select = new DBSelectQueryForTests();
-
// What we expect to be called with the lower layer
$this->dbRawObject
->shouldReceive('select')
- ->with(\Mockery::mustBe($query), \Mockery::mustBe($vars))
- ->andReturn($select);
+ ->with(IsEqual::equalTo($query), IsEqual::equalTo($vars))
+ ->andReturn($this->dbSelectQuery);
// Make the trait function call
$return = $this->dbLowerLayerObject->select($query, $vars);
// Check the result
- $this->assertSame($select, $return);
+ $this->assertSame($this->dbSelectQuery, $return);
}
- public function testFetch()
+ public function testFetch(): void
{
- // Select query result
- $select = new DBSelectQueryForTests();
-
// Expected return value
$expected = ['dada' => 5];
// What we expect to be called with the lower layer
$this->dbRawObject
->shouldReceive('fetch')
- ->with(\Mockery::mustBe($select))
+ ->with(IsEqual::equalTo($this->dbSelectQuery))
->andReturn($expected);
// Make the trait function call
- $return = $this->dbLowerLayerObject->fetch($select);
+ $return = $this->dbLowerLayerObject->fetch($this->dbSelectQuery);
// Check the result
$this->assertSame($expected, $return);
}
- public function testClear()
+ public function testClear(): void
{
- // Select query result
- $select = new DBSelectQueryForTests();
-
// What we expect to be called with the lower layer
$this->dbRawObject
->shouldReceive('clear')
- ->with(\Mockery::mustBe($select));
+ ->with(IsEqual::equalTo($this->dbSelectQuery));
// Make the trait function call
- $this->dbLowerLayerObject->clear($select);
+ $this->dbLowerLayerObject->clear($this->dbSelectQuery);
// Check the result
$this->assertTrue(true);
}
- public function testFetchOne()
+ public function testFetchOne(): void
{
// Variables to pass to the function
$query = 'SELECT';
@@ -143,7 +135,7 @@ public function testFetchOne()
// What we expect to be called with the lower layer
$this->dbRawObject
->shouldReceive('fetchOne')
- ->with(\Mockery::mustBe($query), \Mockery::mustBe($vars))
+ ->with(IsEqual::equalTo($query), IsEqual::equalTo($vars))
->andReturn($expected);
// Make the trait function call
@@ -153,7 +145,7 @@ public function testFetchOne()
$this->assertSame($expected, $return);
}
- public function testFetchAll()
+ public function testFetchAll(): void
{
// Variables to pass to the function
$query = 'SELECT';
@@ -165,7 +157,7 @@ public function testFetchAll()
// What we expect to be called with the lower layer
$this->dbRawObject
->shouldReceive('fetchAll')
- ->with(\Mockery::mustBe($query), \Mockery::mustBe($vars))
+ ->with(IsEqual::equalTo($query), IsEqual::equalTo($vars))
->andReturn($expected);
// Make the trait function call
@@ -175,7 +167,7 @@ public function testFetchAll()
$this->assertSame($expected, $return);
}
- public function testFetchAllAndFlatten()
+ public function testFetchAllAndFlatten(): void
{
// Variables to pass to the function
$query = 'SELECT';
@@ -187,7 +179,7 @@ public function testFetchAllAndFlatten()
// What we expect to be called with the lower layer
$this->dbRawObject
->shouldReceive('fetchAllAndFlatten')
- ->with(\Mockery::mustBe($query), \Mockery::mustBe($vars))
+ ->with(IsEqual::equalTo($query), IsEqual::equalTo($vars))
->andReturn($expected);
// Make the trait function call
@@ -197,7 +189,7 @@ public function testFetchAllAndFlatten()
$this->assertSame($expected, $return);
}
- public function testInsert()
+ public function testInsert(): void
{
// Variables to pass to the function
$tableName = 'users';
@@ -210,7 +202,7 @@ public function testInsert()
// What we expect to be called with the lower layer
$this->dbRawObject
->shouldReceive('insert')
- ->with(\Mockery::mustBe($tableName), \Mockery::mustBe($row), '');
+ ->with(IsEqual::equalTo($tableName), IsEqual::equalTo($row), '');
// Make the trait function call
$this->dbLowerLayerObject->insert($tableName, $row);
@@ -218,7 +210,7 @@ public function testInsert()
$this->assertTrue(true);
}
- public function testUpsert()
+ public function testUpsert(): void
{
// Variables to pass to the function
$tableName = 'users';
@@ -238,10 +230,10 @@ public function testUpsert()
$this->dbRawObject
->shouldReceive('insertOrUpdate')
->with(
- \Mockery::mustBe($tableName),
- \Mockery::mustBe($row),
- \Mockery::mustBe($indexColumns),
- \Mockery::mustBe($rowUpdates),
+ IsEqual::equalTo($tableName),
+ IsEqual::equalTo($row),
+ IsEqual::equalTo($indexColumns),
+ IsEqual::equalTo($rowUpdates),
);
// Make the trait function call
@@ -250,7 +242,7 @@ public function testUpsert()
$this->assertTrue(true);
}
- public function testUpdate()
+ public function testUpdate(): void
{
// What we expect to be called with the lower layer
$this->dbRawObject
@@ -265,7 +257,7 @@ public function testUpdate()
$this->assertSame(7, $return);
}
- public function testDelete()
+ public function testDelete(): void
{
// Variables to pass to the function
$tableName = 'dadaism';
@@ -276,7 +268,7 @@ public function testDelete()
// What we expect to be called with the lower layer
$this->dbRawObject
->shouldReceive('delete')
- ->with(\Mockery::mustBe($tableName), \Mockery::mustBe($query))
+ ->with(IsEqual::equalTo($tableName), IsEqual::equalTo($query))
->andReturn(7);
// Make the trait function call
@@ -286,7 +278,7 @@ public function testDelete()
$this->assertSame(7, $return);
}
- public function testLastInsertId()
+ public function testLastInsertId(): void
{
// Variables to pass to the function
$tableName = 'users';
@@ -299,7 +291,7 @@ public function testLastInsertId()
// What we expect to be called with the lower layer
$this->dbRawObject
->shouldReceive('insert')
- ->with(\Mockery::mustBe($tableName), \Mockery::mustBe($row), 'userId')
+ ->with(IsEqual::equalTo($tableName), IsEqual::equalTo($row), 'userId')
->andReturn(7);
// Make the trait function call
@@ -309,7 +301,7 @@ public function testLastInsertId()
$this->assertSame('7', $return);
}
- public function testChange()
+ public function testChange(): void
{
// Variables to pass to the function
$query = 'SELECT';
@@ -318,7 +310,7 @@ public function testChange()
// What we expect to be called with the lower layer
$this->dbRawObject
->shouldReceive('change')
- ->with(\Mockery::mustBe($query), \Mockery::mustBe($vars))
+ ->with(IsEqual::equalTo($query), IsEqual::equalTo($vars))
->andReturn(7);
// Make the trait function call
@@ -328,12 +320,12 @@ public function testChange()
$this->assertSame(7, $return);
}
- public function testQuoteIdentifier()
+ public function testQuoteIdentifier(): void
{
// What we expect to be called with the lower layer
$this->dbRawObject
->shouldReceive('quoteIdentifier')
- ->with(\Mockery::mustBe('dada'))
+ ->with(IsEqual::equalTo('dada'))
->andReturn('"dada"');
// Make the trait function call
@@ -343,12 +335,12 @@ public function testQuoteIdentifier()
$this->assertSame('"dada"', $return);
}
- public function testQuoteExpression()
+ public function testQuoteExpression(): void
{
// What we expect to be called with the lower layer
$this->dbRawObject
->shouldReceive('quoteExpression')
- ->with(\Mockery::mustBe('WHERE :dada:'))
+ ->with(IsEqual::equalTo('WHERE :dada:'))
->andReturn('WHERE "dada"');
// Make the trait function call
@@ -358,12 +350,12 @@ public function testQuoteExpression()
$this->assertSame('WHERE "dada"', $return);
}
- public function testChangeTransaction()
+ public function testChangeTransaction(): void
{
// What we expect to be called with the lower layer
$this->dbRawObject
->shouldReceive('setTransaction')
- ->with(\Mockery::mustBe(true));
+ ->with(IsEqual::equalTo(true));
// Make the trait function call
$this->dbLowerLayerObject->setTransaction(true);
@@ -372,7 +364,7 @@ public function testChangeTransaction()
$this->assertTrue(true);
}
- public function testGetConnection()
+ public function testGetConnection(): void
{
// Connection dummy class
$connection = new \stdClass();
diff --git a/tests/DoctrineErrorHandlerTest.php b/tests/DoctrineErrorHandlerTest.php
index 6f01f64..0e60a28 100644
--- a/tests/DoctrineErrorHandlerTest.php
+++ b/tests/DoctrineErrorHandlerTest.php
@@ -7,12 +7,13 @@
use Doctrine\DBAL\Exception\ConnectionException;
use Doctrine\DBAL\Exception\DeadlockException;
use Doctrine\DBAL\Exception\DriverException;
+use Hamcrest\Core\IsEqual;
use Squirrel\Queries\DBRawInterface;
+use Squirrel\Queries\DBSelectQueryInterface;
use Squirrel\Queries\Doctrine\DBErrorHandler;
use Squirrel\Queries\Exception\DBConnectionException;
use Squirrel\Queries\Exception\DBDriverException;
use Squirrel\Queries\Exception\DBLockException;
-use Squirrel\Queries\TestHelpers\DBSelectQueryForTests;
/**
* Test our error handler based on the Doctrine library
@@ -22,13 +23,13 @@ class DoctrineErrorHandlerTest extends \PHPUnit\Framework\TestCase
/**
* Test that a new transaction is correctly forwarded to the lower layer
*/
- public function testNewTransaction()
+ public function testNewTransaction(): void
{
// Lower layer mock
$lowerLayer = \Mockery::mock(DBRawInterface::class);
// Example function to pass along
- $func = function ($a, $b, $c) {
+ $func = function (int $a, int $b, int $c): int {
return $a + $b + $c;
};
@@ -41,7 +42,7 @@ public function testNewTransaction()
$lowerLayer
->shouldReceive('transaction')
->once()
- ->with(\Mockery::mustBe($func), \Mockery::mustBe($a), \Mockery::mustBe($b), \Mockery::mustBe($c))
+ ->with(IsEqual::equalTo($func), IsEqual::equalTo($a), IsEqual::equalTo($b), IsEqual::equalTo($c))
->andReturn(173);
// We only get the forwarding to lower layer if there is no transaction active
@@ -63,13 +64,13 @@ public function testNewTransaction()
/**
* Test that the transaction is not forwarded to lower layer if a transaction is already active
*/
- public function testTransactionWhenActiveTransactionExists()
+ public function testTransactionWhenActiveTransactionExists(): void
{
// Lower layer mock
$lowerLayer = \Mockery::mock(DBRawInterface::class);
// Example function to pass along
- $func = function ($a, $b, $c) {
+ $func = function (int $a, int $b, int $c): int {
return $a + $b + $c;
};
@@ -94,12 +95,13 @@ public function testTransactionWhenActiveTransactionExists()
$this->assertEquals(173, $result);
}
- public function testSelectPassToLowerLayer()
+ public function testSelectPassToLowerLayer(): void
{
// Lower layer mock
$lowerLayer = \Mockery::mock(DBRawInterface::class);
- $selectQueryResult = new DBSelectQueryForTests();
+ $selectQueryResult = new class implements DBSelectQueryInterface {
+ };
$lowerLayer
->shouldReceive('select')
@@ -115,12 +117,13 @@ public function testSelectPassToLowerLayer()
$this->assertSame($selectQueryResult, $result);
}
- public function testFetchPassToLowerLayer()
+ public function testFetchPassToLowerLayer(): void
{
// Lower layer mock
$lowerLayer = \Mockery::mock(DBRawInterface::class);
- $selectQueryResult = new DBSelectQueryForTests();
+ $selectQueryResult = new class implements DBSelectQueryInterface {
+ };
$lowerLayer
->shouldReceive('fetch')
@@ -136,12 +139,13 @@ public function testFetchPassToLowerLayer()
$this->assertSame(['dada' => '55'], $result);
}
- public function testClearPassToLowerLayer()
+ public function testClearPassToLowerLayer(): void
{
// Lower layer mock
$lowerLayer = \Mockery::mock(DBRawInterface::class);
- $selectQueryResult = new DBSelectQueryForTests();
+ $selectQueryResult = new class implements DBSelectQueryInterface {
+ };
$lowerLayer
->shouldReceive('clear')
@@ -156,7 +160,7 @@ public function testClearPassToLowerLayer()
$this->assertTrue(true);
}
- public function testFetchOnePassToLowerLayer()
+ public function testFetchOnePassToLowerLayer(): void
{
// Lower layer mock
$lowerLayer = \Mockery::mock(DBRawInterface::class);
@@ -175,7 +179,7 @@ public function testFetchOnePassToLowerLayer()
$this->assertSame(['dada' => '55'], $result);
}
- public function testFetchAllPassToLowerLayer()
+ public function testFetchAllPassToLowerLayer(): void
{
// Lower layer mock
$lowerLayer = \Mockery::mock(DBRawInterface::class);
@@ -194,7 +198,7 @@ public function testFetchAllPassToLowerLayer()
$this->assertSame([['dada' => '55'], ['dada' => 33]], $result);
}
- public function testFetchAllAndFlattenPassToLowerLayer()
+ public function testFetchAllAndFlattenPassToLowerLayer(): void
{
// Lower layer mock
$lowerLayer = \Mockery::mock(DBRawInterface::class);
@@ -215,7 +219,7 @@ public function testFetchAllAndFlattenPassToLowerLayer()
$this->assertSame($expected, $result);
}
- public function testInsertPassToLowerLayer()
+ public function testInsertPassToLowerLayer(): void
{
// Lower layer mock
$lowerLayer = \Mockery::mock(DBRawInterface::class);
@@ -240,7 +244,7 @@ public function testInsertPassToLowerLayer()
$this->assertSame('33', $result);
}
- public function testUpsertPassToLowerLayer()
+ public function testUpsertPassToLowerLayer(): void
{
// Lower layer mock
$lowerLayer = \Mockery::mock(DBRawInterface::class);
@@ -264,7 +268,7 @@ public function testUpsertPassToLowerLayer()
$this->assertTrue(true);
}
- public function testUpdatePassToLowerLayer()
+ public function testUpdatePassToLowerLayer(): void
{
// Lower layer mock
$lowerLayer = \Mockery::mock(DBRawInterface::class);
@@ -291,7 +295,7 @@ public function testUpdatePassToLowerLayer()
$this->assertSame(7, $result);
}
- public function testDeletePassToLowerLayer()
+ public function testDeletePassToLowerLayer(): void
{
// Lower layer mock
$lowerLayer = \Mockery::mock(DBRawInterface::class);
@@ -316,7 +320,7 @@ public function testDeletePassToLowerLayer()
$this->assertSame(6, $result);
}
- public function testChangePassToLowerLayer()
+ public function testChangePassToLowerLayer(): void
{
// Lower layer mock
$lowerLayer = \Mockery::mock(DBRawInterface::class);
@@ -341,13 +345,13 @@ public function testChangePassToLowerLayer()
$this->assertSame(9, $result);
}
- public function testRedoTransactionAfterDeadlock()
+ public function testRedoTransactionAfterDeadlock(): void
{
// Lower layer mock
$lowerLayer = \Mockery::mock(DBRawInterface::class);
// Example function to pass along
- $func = function ($a, $b, $c) {
+ $func = function (int $a, int $b, int $c): int {
return $a + $b + $c;
};
@@ -366,7 +370,7 @@ public function testRedoTransactionAfterDeadlock()
$lowerLayer
->shouldReceive('transaction')
->once()
- ->with(\Mockery::mustBe($func), \Mockery::mustBe($a), \Mockery::mustBe($b), \Mockery::mustBe($c))
+ ->with(IsEqual::equalTo($func), IsEqual::equalTo($a), IsEqual::equalTo($b), IsEqual::equalTo($c))
->andThrow(
new DeadlockException(
PDOException::new(new \PDOException('pdo deadlock exception')),
@@ -377,7 +381,7 @@ public function testRedoTransactionAfterDeadlock()
$lowerLayer
->shouldReceive('transaction')
->once()
- ->with(\Mockery::mustBe($func), \Mockery::mustBe($a), \Mockery::mustBe($b), \Mockery::mustBe($c))
+ ->with(IsEqual::equalTo($func), IsEqual::equalTo($a), IsEqual::equalTo($b), IsEqual::equalTo($c))
->andReturn(173);
$connection = \Mockery::mock(Connection::class);
@@ -410,13 +414,13 @@ public function testRedoTransactionAfterDeadlock()
$this->assertEquals(173, $result);
}
- public function testRedoTransactionAfterConnectionProblem()
+ public function testRedoTransactionAfterConnectionProblem(): void
{
// Lower layer mock
$lowerLayer = \Mockery::mock(DBRawInterface::class);
// Example function to pass along
- $func = function ($a, $b, $c) {
+ $func = function (int $a, int $b, int $c): int {
return $a + $b + $c;
};
@@ -435,7 +439,7 @@ public function testRedoTransactionAfterConnectionProblem()
$lowerLayer
->shouldReceive('transaction')
->once()
- ->with(\Mockery::mustBe($func), \Mockery::mustBe($a), \Mockery::mustBe($b), \Mockery::mustBe($c))
+ ->with(IsEqual::equalTo($func), IsEqual::equalTo($a), IsEqual::equalTo($b), IsEqual::equalTo($c))
->andThrow(
new ConnectionException(
PDOException::new(new \PDOException('MySQL server has gone away')),
@@ -446,7 +450,7 @@ public function testRedoTransactionAfterConnectionProblem()
$lowerLayer
->shouldReceive('transaction')
->once()
- ->with(\Mockery::mustBe($func), \Mockery::mustBe($a), \Mockery::mustBe($b), \Mockery::mustBe($c))
+ ->with(IsEqual::equalTo($func), IsEqual::equalTo($a), IsEqual::equalTo($b), IsEqual::equalTo($c))
->andReturn(173);
$connection = \Mockery::mock(Connection::class);
@@ -489,13 +493,13 @@ public function testRedoTransactionAfterConnectionProblem()
$this->assertEquals(173, $result);
}
- public function testRedoTransactionAfterConnectionProblemMultipleAttempts()
+ public function testRedoTransactionAfterConnectionProblemMultipleAttempts(): void
{
// Lower layer mock
$lowerLayer = \Mockery::mock(DBRawInterface::class);
// Example function to pass along
- $func = function ($a, $b, $c) {
+ $func = function (int $a, int $b, int $c): int {
return $a + $b + $c;
};
@@ -514,7 +518,7 @@ public function testRedoTransactionAfterConnectionProblemMultipleAttempts()
$lowerLayer
->shouldReceive('transaction')
->once()
- ->with(\Mockery::mustBe($func), \Mockery::mustBe($a), \Mockery::mustBe($b), \Mockery::mustBe($c))
+ ->with(IsEqual::equalTo($func), IsEqual::equalTo($a), IsEqual::equalTo($b), IsEqual::equalTo($c))
->andThrow(
new ConnectionException(
PDOException::new(new \PDOException('MySQL server has gone away')),
@@ -525,7 +529,7 @@ public function testRedoTransactionAfterConnectionProblemMultipleAttempts()
$lowerLayer
->shouldReceive('transaction')
->once()
- ->with(\Mockery::mustBe($func), \Mockery::mustBe($a), \Mockery::mustBe($b), \Mockery::mustBe($c))
+ ->with(IsEqual::equalTo($func), IsEqual::equalTo($a), IsEqual::equalTo($b), IsEqual::equalTo($c))
->andReturn(173);
$connection = \Mockery::mock(Connection::class);
@@ -579,7 +583,7 @@ public function testRedoTransactionAfterConnectionProblemMultipleAttempts()
$this->assertEquals(173, $result);
}
- public function testExceptionNoRetriesTransactionAfterDeadlock()
+ public function testExceptionNoRetriesTransactionAfterDeadlock(): void
{
$this->expectException(DBLockException::class);
@@ -587,7 +591,7 @@ public function testExceptionNoRetriesTransactionAfterDeadlock()
$lowerLayer = \Mockery::mock(DBRawInterface::class);
// Example function to pass along
- $func = function ($a, $b, $c) {
+ $func = function (int $a, int $b, int $c): int {
return $a + $b + $c;
};
@@ -606,7 +610,7 @@ public function testExceptionNoRetriesTransactionAfterDeadlock()
$lowerLayer
->shouldReceive('transaction')
->once()
- ->with(\Mockery::mustBe($func), \Mockery::mustBe($a), \Mockery::mustBe($b), \Mockery::mustBe($c))
+ ->with(IsEqual::equalTo($func), IsEqual::equalTo($a), IsEqual::equalTo($b), IsEqual::equalTo($c))
->andThrow(
new DeadlockException(
PDOException::new(new \PDOException('pdo deadlock exception')),
@@ -641,7 +645,7 @@ public function testExceptionNoRetriesTransactionAfterDeadlock()
$errorHandler->transaction($func, $a, $b, $c);
}
- public function testExceptionNoRetriesTransactionAfterConnectionProblem()
+ public function testExceptionNoRetriesTransactionAfterConnectionProblem(): void
{
$this->expectException(DBConnectionException::class);
@@ -649,7 +653,7 @@ public function testExceptionNoRetriesTransactionAfterConnectionProblem()
$lowerLayer = \Mockery::mock(DBRawInterface::class);
// Example function to pass along
- $func = function ($a, $b, $c) {
+ $func = function (int $a, int $b, int $c): int {
return $a + $b + $c;
};
@@ -668,7 +672,7 @@ public function testExceptionNoRetriesTransactionAfterConnectionProblem()
$lowerLayer
->shouldReceive('transaction')
->once()
- ->with(\Mockery::mustBe($func), \Mockery::mustBe($a), \Mockery::mustBe($b), \Mockery::mustBe($c))
+ ->with(IsEqual::equalTo($func), IsEqual::equalTo($a), IsEqual::equalTo($b), IsEqual::equalTo($c))
->andThrow(
new ConnectionException(
PDOException::new(new \PDOException('MySQL server has gone away')),
@@ -679,7 +683,7 @@ public function testExceptionNoRetriesTransactionAfterConnectionProblem()
$lowerLayer
->shouldReceive('transaction')
->once()
- ->with(\Mockery::mustBe($func), \Mockery::mustBe($a), \Mockery::mustBe($b), \Mockery::mustBe($c))
+ ->with(IsEqual::equalTo($func), IsEqual::equalTo($a), IsEqual::equalTo($b), IsEqual::equalTo($c))
->andReturn(173);
$connection = \Mockery::mock(Connection::class);
@@ -709,7 +713,7 @@ public function testExceptionNoRetriesTransactionAfterConnectionProblem()
$errorHandler->transaction($func, $a, $b, $c);
}
- public function testExceptionFromDriverLikeBadSQL()
+ public function testExceptionFromDriverLikeBadSQL(): void
{
$this->expectException(DBDriverException::class);
@@ -717,7 +721,7 @@ public function testExceptionFromDriverLikeBadSQL()
$lowerLayer = \Mockery::mock(DBRawInterface::class);
// Example function to pass along
- $func = function ($a, $b, $c) {
+ $func = function (int $a, int $b, int $c): int {
return $a + $b + $c;
};
@@ -736,7 +740,7 @@ public function testExceptionFromDriverLikeBadSQL()
$lowerLayer
->shouldReceive('transaction')
->once()
- ->with(\Mockery::mustBe($func), \Mockery::mustBe($a), \Mockery::mustBe($b), \Mockery::mustBe($c))
+ ->with(IsEqual::equalTo($func), IsEqual::equalTo($a), IsEqual::equalTo($b), IsEqual::equalTo($c))
->andThrow(
new DriverException(
PDOException::new(new \PDOException('MySQL server has gone away')),
@@ -771,7 +775,7 @@ public function testExceptionFromDriverLikeBadSQL()
$errorHandler->transaction($func, $a, $b, $c);
}
- public function testUnhandledException()
+ public function testUnhandledException(): void
{
$this->expectException(\InvalidArgumentException::class);
@@ -779,7 +783,7 @@ public function testUnhandledException()
$lowerLayer = \Mockery::mock(DBRawInterface::class);
// Example function to pass along
- $func = function ($a, $b, $c) {
+ $func = function (int $a, int $b, int $c): int {
return $a + $b + $c;
};
@@ -798,7 +802,7 @@ public function testUnhandledException()
$lowerLayer
->shouldReceive('transaction')
->once()
- ->with(\Mockery::mustBe($func), \Mockery::mustBe($a), \Mockery::mustBe($b), \Mockery::mustBe($c))
+ ->with(IsEqual::equalTo($func), IsEqual::equalTo($a), IsEqual::equalTo($b), IsEqual::equalTo($c))
->andThrow(
new \InvalidArgumentException('some weird exception'),
);
@@ -830,7 +834,7 @@ public function testUnhandledException()
$errorHandler->transaction($func, $a, $b, $c);
}
- public function testExceptionSelectWithinTransactionDeadlock()
+ public function testExceptionSelectWithinTransactionDeadlock(): void
{
$this->expectException(DeadlockException::class);
@@ -864,7 +868,7 @@ public function testExceptionSelectWithinTransactionDeadlock()
$errorHandler->select('SELECT * FROM table');
}
- public function testExceptionNoRetriesSelectAfterDeadlock()
+ public function testExceptionNoRetriesSelectAfterDeadlock(): void
{
$this->expectException(DBLockException::class);
@@ -898,7 +902,7 @@ public function testExceptionNoRetriesSelectAfterDeadlock()
$errorHandler->select('SELECT * FROM table');
}
- public function testExceptionSelectWithinTransactionConnectionProblem()
+ public function testExceptionSelectWithinTransactionConnectionProblem(): void
{
$this->expectException(ConnectionException::class);
@@ -932,7 +936,7 @@ public function testExceptionSelectWithinTransactionConnectionProblem()
$errorHandler->select('SELECT * FROM table');
}
- public function testExceptionNoRetriesSelectAfterConnectionProblem()
+ public function testExceptionNoRetriesSelectAfterConnectionProblem(): void
{
$this->expectException(DBConnectionException::class);
@@ -990,7 +994,7 @@ public function testExceptionNoRetriesSelectAfterConnectionProblem()
$errorHandler->select('SELECT * FROM table');
}
- public function testExceptionSelectFromDriver()
+ public function testExceptionSelectFromDriver(): void
{
$this->expectException(DBDriverException::class);
diff --git a/tests/DoctrineImplementationTest.php b/tests/DoctrineImplementationTest.php
index dba9426..755b4fb 100644
--- a/tests/DoctrineImplementationTest.php
+++ b/tests/DoctrineImplementationTest.php
@@ -6,6 +6,8 @@
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Result;
use Doctrine\DBAL\Statement;
+use Hamcrest\Core\IsEqual;
+use Mockery\MockInterface;
use Squirrel\Queries\DBSelectQueryInterface;
use Squirrel\Queries\Doctrine\DBAbstractImplementation;
use Squirrel\Queries\Doctrine\DBSelectQuery;
@@ -16,15 +18,10 @@
*/
class DoctrineImplementationTest extends \PHPUnit\Framework\TestCase
{
- /**
- * @var DBAbstractImplementation
- */
- private $db;
-
- /**
- * @var Connection
- */
- private $connection;
+ /** @var DBAbstractImplementation&MockInterface */
+ private DBAbstractImplementation $db;
+ /** @var Connection&MockInterface */
+ private Connection $connection;
/**
* Prepare common aspects of all tests
@@ -41,7 +38,7 @@ protected function setUp(): void
// Make sure quoteIdentifier works as expected
$this->connection
->shouldReceive('quoteIdentifier')
- ->andReturnUsing(function ($identifier) {
+ ->andReturnUsing(function (string $identifier): string {
if (strpos($identifier, ".") !== false) {
$parts = array_map(
function ($p) {
@@ -60,7 +57,7 @@ function ($p) {
/**
* Check that we correctly return the connection object
*/
- public function testConnection()
+ public function testConnection(): void
{
$this->assertSame($this->connection, $this->db->getConnection());
}
@@ -68,7 +65,7 @@ public function testConnection()
/**
* Check correct return values for transaction bool
*/
- public function testInTransaction()
+ public function testInTransaction(): void
{
$this->assertSame(false, $this->db->inTransaction());
$this->db->setTransaction(true);
@@ -77,7 +74,7 @@ public function testInTransaction()
$this->assertSame(false, $this->db->inTransaction());
}
- public function testTransaction()
+ public function testTransaction(): void
{
// Make sure no transaction is running at the beginning
$this->assertSame(false, $this->db->inTransaction());
@@ -106,7 +103,7 @@ public function testTransaction()
$this->assertSame(false, $this->db->inTransaction());
}
- public function testTransactionWithinTransaction()
+ public function testTransactionWithinTransaction(): void
{
// Set transaction to "yes"
$this->db->setTransaction(true);
@@ -125,7 +122,7 @@ public function testTransactionWithinTransaction()
$this->assertSame(true, $this->db->inTransaction());
}
- public function testSelect()
+ public function testSelect(): void
{
// Query parameters
$query = 'SELECT blabla FROM yudihui';
@@ -139,14 +136,14 @@ public function testSelect()
$this->connection
->shouldReceive('prepare')
->once()
- ->with(\Mockery::mustBe($query))
+ ->with(IsEqual::equalTo($query))
->andReturn($statement);
// "Execute" call on doctrine result statement
$statement
->shouldReceive('executeQuery')
->once()
- ->with(\Mockery::mustBe($vars))
+ ->with(IsEqual::equalTo($vars))
->andReturn($statementResult);
$result = $this->db->select($query, $vars);
@@ -155,7 +152,7 @@ public function testSelect()
$this->assertEquals(new DBSelectQuery($statementResult), $result);
}
- public function testFetch()
+ public function testFetch(): void
{
// Doctrine result
$statementResult = \Mockery::mock(Result::class);
@@ -179,7 +176,7 @@ public function testFetch()
$this->assertEquals($returnValue, $result);
}
- public function testClear()
+ public function testClear(): void
{
// Doctrine result
$statementResult = \Mockery::mock(Result::class);
@@ -199,7 +196,7 @@ public function testClear()
$this->assertTrue(true);
}
- public function testFetchOne()
+ public function testFetchOne(): void
{
// Query parameters
$query = 'SELECT blabla FROM yudihui';
@@ -213,14 +210,14 @@ public function testFetchOne()
$this->connection
->shouldReceive('prepare')
->once()
- ->with(\Mockery::mustBe($query))
+ ->with(IsEqual::equalTo($query))
->andReturn($statement);
// "Execute" call on doctrine result statement
$statement
->shouldReceive('executeQuery')
->once()
- ->with(\Mockery::mustBe($vars))
+ ->with(IsEqual::equalTo($vars))
->andReturn($statementResult);
// Return value from fetch
@@ -243,7 +240,7 @@ public function testFetchOne()
$this->assertEquals($returnValue, $result);
}
- public function testFetchAll()
+ public function testFetchAll(): void
{
// Query parameters
$query = 'SELECT blabla FROM yudihui';
@@ -257,14 +254,14 @@ public function testFetchAll()
$this->connection
->shouldReceive('prepare')
->once()
- ->with(\Mockery::mustBe($query))
+ ->with(IsEqual::equalTo($query))
->andReturn($statement);
// "Execute" call on doctrine result statement
$statement
->shouldReceive('executeQuery')
->once()
- ->with(\Mockery::mustBe($vars))
+ ->with(IsEqual::equalTo($vars))
->andReturn($statementResult);
// Return value from fetch
@@ -287,7 +284,7 @@ public function testFetchAll()
$this->assertEquals($returnValue, $result);
}
- private function bindValues($statement, $vars)
+ private function bindValues(MockInterface $statement, array $vars): void
{
$varCounter = 1;
@@ -295,11 +292,11 @@ private function bindValues($statement, $vars)
$statement
->shouldReceive('bindValue')
->once()
- ->with(\Mockery::mustBe($varCounter++), \Mockery::mustBe($var), \PDO::PARAM_STR);
+ ->with(IsEqual::equalTo($varCounter++), IsEqual::equalTo($var), \PDO::PARAM_STR);
}
}
- public function testInsert()
+ public function testInsert(): void
{
// Expected query and parameters
$query = 'INSERT INTO "tableName" ("id","name","active","lastUpdate") VALUES (?,?,?,?)';
@@ -313,7 +310,7 @@ public function testInsert()
$this->connection
->shouldReceive('prepare')
->once()
- ->with(\Mockery::mustBe($query))
+ ->with(IsEqual::equalTo($query))
->andReturn($statement);
$this->bindValues($statement, $vars);
@@ -342,7 +339,7 @@ public function testInsert()
$this->assertTrue(true);
}
- public function testLastInsertId()
+ public function testLastInsertId(): void
{
// Expected query and parameters
$query = 'INSERT INTO "tableName" ("id","name","lastUpdate") VALUES (?,?,?)';
@@ -356,7 +353,7 @@ public function testLastInsertId()
$this->connection
->shouldReceive('prepare')
->once()
- ->with(\Mockery::mustBe($query))
+ ->with(IsEqual::equalTo($query))
->andReturn($statement);
$this->bindValues($statement, $vars);
@@ -376,7 +373,7 @@ public function testLastInsertId()
$this->connection
->shouldReceive('lastInsertId')
->once()
- ->with(\Mockery::mustBe('tableName_id_seq'))
+ ->with(IsEqual::equalTo('tableName_id_seq'))
->andReturn(5);
// Insert query call
@@ -390,7 +387,7 @@ public function testLastInsertId()
$this->assertEquals('5', $result);
}
- public function testUpdate()
+ public function testUpdate(): void
{
// Query we use to test the update
$query = [
@@ -411,7 +408,7 @@ public function testUpdate()
$this->db
->shouldReceive('change')
->once()
- ->with(\Mockery::mustBe($queryAsString), \Mockery::mustBe($vars))
+ ->with(IsEqual::equalTo($queryAsString), IsEqual::equalTo($vars))
->andReturn(33);
// Call the update
@@ -421,7 +418,7 @@ public function testUpdate()
$this->assertSame(33, $results);
}
- public function testChange()
+ public function testChange(): void
{
// Expected query and parameters
$query = 'INSERT INTO "tableName" ("id","name","active","lastUpdate") VALUES (?,?,?,?)';
@@ -435,7 +432,7 @@ public function testChange()
$this->connection
->shouldReceive('prepare')
->once()
- ->with(\Mockery::mustBe($query))
+ ->with(IsEqual::equalTo($query))
->andReturn($statement);
$this->bindValues($statement, $vars);
@@ -470,7 +467,7 @@ public function testChange()
$this->assertEquals(5, $result);
}
- public function testChangeSimple()
+ public function testChangeSimple(): void
{
// Expected query and parameters
$query = 'INSERT INTO "tableName" ("id","name","lastUpdate") VALUES (5,"Dada",4534)';
@@ -483,7 +480,7 @@ public function testChangeSimple()
$this->connection
->shouldReceive('prepare')
->once()
- ->with(\Mockery::mustBe($query))
+ ->with(IsEqual::equalTo($query))
->andReturn($statement);
// "Execute" call on doctrine result statement
@@ -511,7 +508,7 @@ public function testChangeSimple()
$this->assertEquals(5, $result);
}
- public function testInsertOrUpdateEmulationUpdate()
+ public function testInsertOrUpdateEmulationUpdate(): void
{
// Expected query and parameters
$query = 'UPDATE "tablename" SET "name"=? WHERE "id"=?';
@@ -529,7 +526,7 @@ public function testInsertOrUpdateEmulationUpdate()
$this->connection
->shouldReceive('prepare')
->once()
- ->with(\Mockery::mustBe($query))
+ ->with(IsEqual::equalTo($query))
->andReturn($statement);
$this->bindValues($statement, $vars);
@@ -564,7 +561,7 @@ public function testInsertOrUpdateEmulationUpdate()
$this->assertTrue(true);
}
- public function testInsertOrUpdateEmulationInsert()
+ public function testInsertOrUpdateEmulationInsert(): void
{
// Expected query and parameters
$query = 'UPDATE "tablename" SET "name"=? WHERE "id"=?';
@@ -582,7 +579,7 @@ public function testInsertOrUpdateEmulationInsert()
$this->connection
->shouldReceive('prepare')
->once()
- ->with(\Mockery::mustBe($query))
+ ->with(IsEqual::equalTo($query))
->andReturn($statement);
$this->bindValues($statement, $vars);
@@ -617,7 +614,7 @@ public function testInsertOrUpdateEmulationInsert()
$this->connection
->shouldReceive('prepare')
->once()
- ->with(\Mockery::mustBe($insertQuery))
+ ->with(IsEqual::equalTo($insertQuery))
->andReturn($insertStatement);
$this->bindValues($insertStatement, $insertVars);
@@ -652,7 +649,7 @@ public function testInsertOrUpdateEmulationInsert()
$this->assertTrue(true);
}
- public function testInsertOrUpdateEmulationDoNothingInsert()
+ public function testInsertOrUpdateEmulationDoNothingInsert(): void
{
// Expected query and parameters
$query = 'UPDATE "tablename" SET "id"="id" WHERE "id"=?';
@@ -670,7 +667,7 @@ public function testInsertOrUpdateEmulationDoNothingInsert()
$this->connection
->shouldReceive('prepare')
->once()
- ->with(\Mockery::mustBe($query))
+ ->with(IsEqual::equalTo($query))
->andReturn($statement);
$this->bindValues($statement, $vars);
@@ -705,7 +702,7 @@ public function testInsertOrUpdateEmulationDoNothingInsert()
$this->connection
->shouldReceive('prepare')
->once()
- ->with(\Mockery::mustBe($insertQuery))
+ ->with(IsEqual::equalTo($insertQuery))
->andReturn($insertStatement);
$this->bindValues($insertStatement, $insertVars);
@@ -740,7 +737,7 @@ public function testInsertOrUpdateEmulationDoNothingInsert()
$this->assertTrue(true);
}
- public function testDelete()
+ public function testDelete(): void
{
// Expected query and parameters
$query = 'DELETE FROM "tablename" WHERE "mamamia"=? AND "fumbal" IN (?,?,?)';
@@ -754,7 +751,7 @@ public function testDelete()
$this->connection
->shouldReceive('prepare')
->once()
- ->with(\Mockery::mustBe($query))
+ ->with(IsEqual::equalTo($query))
->andReturn($statement);
$this->bindValues($statement, $vars);
@@ -787,7 +784,7 @@ public function testDelete()
$this->assertEquals(5, $result);
}
- public function testDeleteSimple()
+ public function testDeleteSimple(): void
{
// Expected query and parameters
$query = 'DELETE FROM "tablename" WHERE ("mamamia"=1)';
@@ -800,7 +797,7 @@ public function testDeleteSimple()
$this->connection
->shouldReceive('prepare')
->once()
- ->with(\Mockery::mustBe($query))
+ ->with(IsEqual::equalTo($query))
->andReturn($statement);
// "Execute" call on doctrine result statement
@@ -830,7 +827,7 @@ public function testDeleteSimple()
$this->assertEquals(5, $result);
}
- public function testNoLowerLayer()
+ public function testNoLowerLayer(): void
{
// Expect an InvalidArgument exception
$this->expectException(\LogicException::class);
@@ -839,7 +836,7 @@ public function testNoLowerLayer()
$this->db->setLowerLayer(\Mockery::mock(DBAbstractImplementation::class));
}
- public function testNoSelectObject1()
+ public function testNoSelectObject1(): void
{
$this->expectException(DBInvalidOptionException::class);
@@ -850,7 +847,7 @@ public function testNoSelectObject1()
$this->db->fetch($selectQueryInterface);
}
- public function testNoSelectObject2()
+ public function testNoSelectObject2(): void
{
$this->expectException(DBInvalidOptionException::class);
@@ -861,7 +858,7 @@ public function testNoSelectObject2()
$this->db->clear($selectQueryInterface);
}
- public function testInsertNoTableName()
+ public function testInsertNoTableName(): void
{
$this->expectException(DBInvalidOptionException::class);
@@ -871,7 +868,7 @@ public function testInsertNoTableName()
]);
}
- public function testDeleteNoTableName()
+ public function testDeleteNoTableName(): void
{
$this->expectException(DBInvalidOptionException::class);
@@ -881,7 +878,7 @@ public function testDeleteNoTableName()
]);
}
- public function testSelectStructuredSimple()
+ public function testSelectStructuredSimple(): void
{
// Query parameters
$query = 'SELECT "blabla" FROM "yudihui" WHERE "lala"=?';
@@ -895,14 +892,14 @@ public function testSelectStructuredSimple()
$this->connection
->shouldReceive('prepare')
->once()
- ->with(\Mockery::mustBe($query))
+ ->with(IsEqual::equalTo($query))
->andReturn($statement);
// "Execute" call on doctrine result statement
$statement
->shouldReceive('executeQuery')
->once()
- ->with(\Mockery::mustBe($vars))
+ ->with(IsEqual::equalTo($vars))
->andReturn($statementResult);
$result = $this->db->select([
@@ -932,7 +929,7 @@ public function testSelectStructuredSimple()
$this->assertEquals(new DBSelectQuery($statementResult), $result);
}
- public function testSelectStructuredCatchAll()
+ public function testSelectStructuredCatchAll(): void
{
// Query parameters
$query = 'SELECT "a".*,"b"."lala" FROM "yudihui" "a","ahoi" "b" WHERE "a"."lala"=?';
@@ -946,14 +943,14 @@ public function testSelectStructuredCatchAll()
$this->connection
->shouldReceive('prepare')
->once()
- ->with(\Mockery::mustBe($query))
+ ->with(IsEqual::equalTo($query))
->andReturn($statement);
// "Execute" call on doctrine result statement
$statement
->shouldReceive('executeQuery')
->once()
- ->with(\Mockery::mustBe($vars))
+ ->with(IsEqual::equalTo($vars))
->andReturn($statementResult);
$result = $this->db->select([
@@ -985,14 +982,14 @@ public function testSelectStructuredCatchAll()
$this->connection
->shouldReceive('prepare')
->once()
- ->with(\Mockery::mustBe($query))
+ ->with(IsEqual::equalTo($query))
->andReturn($statement);
// "Execute" call on doctrine result statement
$statement
->shouldReceive('executeQuery')
->once()
- ->with(\Mockery::mustBe($vars))
+ ->with(IsEqual::equalTo($vars))
->andReturn($statementResult);
$result = $this->db->select([
@@ -1013,7 +1010,7 @@ public function testSelectStructuredCatchAll()
$this->assertEquals(new DBSelectQuery($statementResult), $result);
}
- public function testSelectStructuredCatchAllNoFields()
+ public function testSelectStructuredCatchAllNoFields(): void
{
// Query parameters
$query = 'SELECT * FROM "yudihui" "a","ahoi" "b" WHERE "a"."lala"=?';
@@ -1027,14 +1024,14 @@ public function testSelectStructuredCatchAllNoFields()
$this->connection
->shouldReceive('prepare')
->once()
- ->with(\Mockery::mustBe($query))
+ ->with(IsEqual::equalTo($query))
->andReturn($statement);
// "Execute" call on doctrine result statement
$statement
->shouldReceive('executeQuery')
->once()
- ->with(\Mockery::mustBe($vars))
+ ->with(IsEqual::equalTo($vars))
->andReturn($statementResult);
$result = $this->db->select([
@@ -1051,7 +1048,7 @@ public function testSelectStructuredCatchAllNoFields()
$this->assertEquals(new DBSelectQuery($statementResult), $result);
}
- public function testSelectStructuredNoWhere()
+ public function testSelectStructuredNoWhere(): void
{
// Query parameters
$query = 'SELECT * FROM "yudihui" "a","ahoi" "b"';
@@ -1065,14 +1062,14 @@ public function testSelectStructuredNoWhere()
$this->connection
->shouldReceive('prepare')
->once()
- ->with(\Mockery::mustBe($query))
+ ->with(IsEqual::equalTo($query))
->andReturn($statement);
// "Execute" call on doctrine result statement
$statement
->shouldReceive('executeQuery')
->once()
- ->with(\Mockery::mustBe($vars))
+ ->with(IsEqual::equalTo($vars))
->andReturn($statementResult);
$result = $this->db->select([
@@ -1087,7 +1084,7 @@ public function testSelectStructuredNoWhere()
$this->assertEquals(new DBSelectQuery($statementResult), $result);
}
- public function testSelectStructuredComplicated()
+ public function testSelectStructuredComplicated(): void
{
// Query parameters
$query = 'SELECT "fufumama","b"."lalala","a"."setting_value" AS "result",' .
@@ -1121,14 +1118,14 @@ public function testSelectStructuredComplicated()
$this->connection
->shouldReceive('prepare')
->once()
- ->with(\Mockery::mustBe($query . ' LIMIT 10 OFFSET 5'))
+ ->with(IsEqual::equalTo($query . ' LIMIT 10 OFFSET 5'))
->andReturn($statement);
// "Execute" call on doctrine result statement
$statement
->shouldReceive('executeQuery')
->once()
- ->with(\Mockery::mustBe($vars))
+ ->with(IsEqual::equalTo($vars))
->andReturn($statementResult);
$result = $this->db->select([
@@ -1165,7 +1162,7 @@ public function testSelectStructuredComplicated()
$this->assertEquals(new DBSelectQuery($statementResult), $result);
}
- public function testFetchOneStructured()
+ public function testFetchOneStructured(): void
{
// Query parameters
$query = 'SELECT "user_agent_id" AS "id","user_agent_hash" AS "hash" ' .
@@ -1203,14 +1200,14 @@ public function testFetchOneStructured()
$this->connection
->shouldReceive('prepare')
->once()
- ->with(\Mockery::mustBe($query))
+ ->with(IsEqual::equalTo($query))
->andReturn($statement);
// "Execute" call on doctrine result statement
$statement
->shouldReceive('executeQuery')
->once()
- ->with(\Mockery::mustBe($vars))
+ ->with(IsEqual::equalTo($vars))
->andReturn($statementResult);
// Return value from fetch
@@ -1233,7 +1230,7 @@ public function testFetchOneStructured()
$this->assertEquals($returnValue, $result);
}
- public function testFetchAllStructured()
+ public function testFetchAllStructured(): void
{
// Query parameters
$query = 'SELECT "user_agent_id" AS "id","user_agent_hash" AS "hash" ' .
@@ -1262,14 +1259,14 @@ public function testFetchAllStructured()
$this->connection
->shouldReceive('prepare')
->once()
- ->with(\Mockery::mustBe($query))
+ ->with(IsEqual::equalTo($query))
->andReturn($statement);
// "Execute" call on doctrine result statement
$statement
->shouldReceive('executeQuery')
->once()
- ->with(\Mockery::mustBe($vars))
+ ->with(IsEqual::equalTo($vars))
->andReturn($statementResult);
// Return value from fetch
@@ -1292,7 +1289,7 @@ public function testFetchAllStructured()
$this->assertEquals($returnValue, $result);
}
- public function testFetchAllStructuredFlattened()
+ public function testFetchAllStructuredFlattened(): void
{
// Query parameters
$query = 'SELECT "user_agent_id" AS "id","user_agent_hash" AS "hash" ' .
@@ -1321,14 +1318,14 @@ public function testFetchAllStructuredFlattened()
$this->connection
->shouldReceive('prepare')
->once()
- ->with(\Mockery::mustBe($query))
+ ->with(IsEqual::equalTo($query))
->andReturn($statement);
// "Execute" call on doctrine result statement
$statement
->shouldReceive('executeQuery')
->once()
- ->with(\Mockery::mustBe($vars))
+ ->with(IsEqual::equalTo($vars))
->andReturn($statementResult);
// Return value from fetch
@@ -1351,7 +1348,7 @@ public function testFetchAllStructuredFlattened()
$this->assertEquals(['5', 'fhsdkj'], $result);
}
- public function testFetchOneStructured2()
+ public function testFetchOneStructured2(): void
{
// Query parameters
$query = 'SELECT "c"."cart_id","c"."checkout_step","s"."session_id","s"."user_id","s"."domain" ' .
@@ -1408,14 +1405,14 @@ public function testFetchOneStructured2()
$this->connection
->shouldReceive('prepare')
->once()
- ->with(\Mockery::mustBe($query))
+ ->with(IsEqual::equalTo($query))
->andReturn($statement);
// "Execute" call on doctrine result statement
$statement
->shouldReceive('executeQuery')
->once()
- ->with(\Mockery::mustBe($vars))
+ ->with(IsEqual::equalTo($vars))
->andReturn($statementResult);
// Return value from fetch
@@ -1481,14 +1478,14 @@ public function testFetchOneStructured2()
$this->connection
->shouldReceive('prepare')
->once()
- ->with(\Mockery::mustBe($query))
+ ->with(IsEqual::equalTo($query))
->andReturn($statement);
// "Execute" call on doctrine result statement
$statement
->shouldReceive('executeQuery')
->once()
- ->with(\Mockery::mustBe($vars))
+ ->with(IsEqual::equalTo($vars))
->andReturn($statementResult);
// Return value from fetch
@@ -1511,7 +1508,7 @@ public function testFetchOneStructured2()
$this->assertEquals($returnValue, $result);
}
- public function testUpdateStructured()
+ public function testUpdateStructured(): void
{
$query = 'UPDATE "blobs"."aa_sexy" SET "anyfieldname"=? WHERE "blabla"=?';
$vars = ['nicevalue', 5];
@@ -1533,7 +1530,7 @@ public function testUpdateStructured()
$this->connection
->shouldReceive('prepare')
->once()
- ->with(\Mockery::mustBe($query))
+ ->with(IsEqual::equalTo($query))
->andReturn($statement);
$this->bindValues($statement, $vars);
@@ -1565,7 +1562,7 @@ public function testUpdateStructured()
$this->assertEquals(33, $result);
}
- public function testUpdateStructuredNULL()
+ public function testUpdateStructuredNULL(): void
{
$query = 'UPDATE "blobs"."aa_sexy" SET "anyfieldname"=?,"nullentry"=?,"active"=? WHERE "blabla"=?';
$vars = ['nicevalue', null, 1, 5];
@@ -1578,7 +1575,7 @@ public function testUpdateStructuredNULL()
$this->connection
->shouldReceive('prepare')
->once()
- ->with(\Mockery::mustBe($query))
+ ->with(IsEqual::equalTo($query))
->andReturn($statement);
$this->bindValues($statement, $vars);
@@ -1612,7 +1609,7 @@ public function testUpdateStructuredNULL()
$this->assertEquals(33, $result);
}
- public function testConvertToSelectSQLStringInvalidOptionFields1()
+ public function testConvertToSelectSQLStringInvalidOptionFields1(): void
{
$this->expectException(DBInvalidOptionException::class);
@@ -1630,7 +1627,7 @@ public function testConvertToSelectSQLStringInvalidOptionFields1()
]);
}
- public function testConvertToSelectSQLStringInvalidOptionFields2()
+ public function testConvertToSelectSQLStringInvalidOptionFields2(): void
{
$this->expectException(DBInvalidOptionException::class);
@@ -1650,7 +1647,7 @@ public function testConvertToSelectSQLStringInvalidOptionFields2()
]);
}
- public function testConvertToSelectSQLStringInvalidOptionFields3()
+ public function testConvertToSelectSQLStringInvalidOptionFields3(): void
{
$this->expectException(DBInvalidOptionException::class);
@@ -1670,7 +1667,7 @@ public function testConvertToSelectSQLStringInvalidOptionFields3()
]);
}
- public function testConvertToSelectSQLStringInvalidOptionFields4()
+ public function testConvertToSelectSQLStringInvalidOptionFields4(): void
{
$this->expectException(DBInvalidOptionException::class);
@@ -1690,7 +1687,7 @@ public function testConvertToSelectSQLStringInvalidOptionFields4()
]);
}
- public function testConvertToSelectSQLStringInvalidOptionFields5()
+ public function testConvertToSelectSQLStringInvalidOptionFields5(): void
{
$this->expectException(DBInvalidOptionException::class);
@@ -1710,7 +1707,7 @@ public function testConvertToSelectSQLStringInvalidOptionFields5()
]);
}
- public function testConvertToSelectSQLStringInvalidOptionTables1()
+ public function testConvertToSelectSQLStringInvalidOptionTables1(): void
{
$this->expectException(DBInvalidOptionException::class);
@@ -1727,7 +1724,7 @@ public function testConvertToSelectSQLStringInvalidOptionTables1()
]);
}
- public function testConvertToSelectSQLStringInvalidOptionTables2()
+ public function testConvertToSelectSQLStringInvalidOptionTables2(): void
{
$this->expectException(DBInvalidOptionException::class);
@@ -1745,7 +1742,7 @@ public function testConvertToSelectSQLStringInvalidOptionTables2()
]);
}
- public function testConvertToSelectSQLStringInvalidOptionTables3()
+ public function testConvertToSelectSQLStringInvalidOptionTables3(): void
{
$this->expectException(DBInvalidOptionException::class);
@@ -1765,7 +1762,7 @@ public function testConvertToSelectSQLStringInvalidOptionTables3()
]);
}
- public function testConvertToSelectSQLStringInvalidOptionTables4()
+ public function testConvertToSelectSQLStringInvalidOptionTables4(): void
{
$this->expectException(DBInvalidOptionException::class);
@@ -1785,7 +1782,7 @@ public function testConvertToSelectSQLStringInvalidOptionTables4()
]);
}
- public function testConvertToSelectSQLStringInvalidOptionTablesWithNULL()
+ public function testConvertToSelectSQLStringInvalidOptionTablesWithNULL(): void
{
$this->expectException(DBInvalidOptionException::class);
@@ -1805,7 +1802,7 @@ public function testConvertToSelectSQLStringInvalidOptionTablesWithNULL()
]);
}
- public function testConvertToSelectSQLStringInvalidOptionWhere1()
+ public function testConvertToSelectSQLStringInvalidOptionWhere1(): void
{
$this->expectException(DBInvalidOptionException::class);
@@ -1822,7 +1819,7 @@ public function testConvertToSelectSQLStringInvalidOptionWhere1()
]);
}
- public function testConvertToSelectSQLStringInvalidOptionWhere2()
+ public function testConvertToSelectSQLStringInvalidOptionWhere2(): void
{
$this->expectException(DBInvalidOptionException::class);
@@ -1841,7 +1838,7 @@ public function testConvertToSelectSQLStringInvalidOptionWhere2()
]);
}
- public function testConvertToSelectSQLStringInvalidOptionWhere3()
+ public function testConvertToSelectSQLStringInvalidOptionWhere3(): void
{
$this->expectException(DBInvalidOptionException::class);
@@ -1860,7 +1857,7 @@ public function testConvertToSelectSQLStringInvalidOptionWhere3()
]);
}
- public function testConvertToSelectSQLStringInvalidOptionWhere4()
+ public function testConvertToSelectSQLStringInvalidOptionWhere4(): void
{
$this->expectException(DBInvalidOptionException::class);
@@ -1879,7 +1876,7 @@ public function testConvertToSelectSQLStringInvalidOptionWhere4()
]);
}
- public function testConvertToSelectSQLStringInvalidOptionWhere5()
+ public function testConvertToSelectSQLStringInvalidOptionWhere5(): void
{
$this->expectException(DBInvalidOptionException::class);
@@ -1898,7 +1895,7 @@ public function testConvertToSelectSQLStringInvalidOptionWhere5()
]);
}
- public function testConvertToSelectSQLStringInvalidOptionGroup1()
+ public function testConvertToSelectSQLStringInvalidOptionGroup1(): void
{
$this->expectException(DBInvalidOptionException::class);
@@ -1920,7 +1917,7 @@ public function testConvertToSelectSQLStringInvalidOptionGroup1()
]);
}
- public function testConvertToSelectSQLStringInvalidOptionGroup2()
+ public function testConvertToSelectSQLStringInvalidOptionGroup2(): void
{
$this->expectException(DBInvalidOptionException::class);
@@ -1942,7 +1939,7 @@ public function testConvertToSelectSQLStringInvalidOptionGroup2()
]);
}
- public function testConvertToSelectSQLStringInvalidOptionOrder1()
+ public function testConvertToSelectSQLStringInvalidOptionOrder1(): void
{
$this->expectException(DBInvalidOptionException::class);
@@ -1964,7 +1961,7 @@ public function testConvertToSelectSQLStringInvalidOptionOrder1()
]);
}
- public function testConvertToSelectSQLStringInvalidOptionOrder2()
+ public function testConvertToSelectSQLStringInvalidOptionOrder2(): void
{
$this->expectException(DBInvalidOptionException::class);
@@ -1986,7 +1983,7 @@ public function testConvertToSelectSQLStringInvalidOptionOrder2()
]);
}
- public function testConvertToSelectSQLStringInvalidOptionOrder3()
+ public function testConvertToSelectSQLStringInvalidOptionOrder3(): void
{
$this->expectException(DBInvalidOptionException::class);
@@ -2008,7 +2005,7 @@ public function testConvertToSelectSQLStringInvalidOptionOrder3()
]);
}
- public function testConvertToSelectSQLStringInvalidOptionLimit()
+ public function testConvertToSelectSQLStringInvalidOptionLimit(): void
{
$this->expectException(DBInvalidOptionException::class);
@@ -2027,7 +2024,7 @@ public function testConvertToSelectSQLStringInvalidOptionLimit()
]);
}
- public function testConvertToSelectSQLStringInvalidOptionLimitNoInteger()
+ public function testConvertToSelectSQLStringInvalidOptionLimitNoInteger(): void
{
$this->expectException(DBInvalidOptionException::class);
@@ -2046,7 +2043,7 @@ public function testConvertToSelectSQLStringInvalidOptionLimitNoInteger()
]);
}
- public function testConvertToSelectSQLStringInvalidOptionLimitBoolean()
+ public function testConvertToSelectSQLStringInvalidOptionLimitBoolean(): void
{
$this->expectException(DBInvalidOptionException::class);
@@ -2065,7 +2062,7 @@ public function testConvertToSelectSQLStringInvalidOptionLimitBoolean()
]);
}
- public function testConvertToSelectSQLStringInvalidOptionOffset()
+ public function testConvertToSelectSQLStringInvalidOptionOffset(): void
{
$this->expectException(DBInvalidOptionException::class);
@@ -2084,7 +2081,7 @@ public function testConvertToSelectSQLStringInvalidOptionOffset()
]);
}
- public function testConvertToSelectSQLStringInvalidOptionOffsetNoInteger()
+ public function testConvertToSelectSQLStringInvalidOptionOffsetNoInteger(): void
{
$this->expectException(DBInvalidOptionException::class);
@@ -2103,7 +2100,7 @@ public function testConvertToSelectSQLStringInvalidOptionOffsetNoInteger()
]);
}
- public function testConvertToSelectSQLStringInvalidOptionLockNoBool()
+ public function testConvertToSelectSQLStringInvalidOptionLockNoBool(): void
{
$this->expectException(DBInvalidOptionException::class);
@@ -2122,7 +2119,7 @@ public function testConvertToSelectSQLStringInvalidOptionLockNoBool()
]);
}
- public function testConvertToSelectSQLStringInvalidOptionFieldAndFields()
+ public function testConvertToSelectSQLStringInvalidOptionFieldAndFields(): void
{
$this->expectException(DBInvalidOptionException::class);
@@ -2141,7 +2138,7 @@ public function testConvertToSelectSQLStringInvalidOptionFieldAndFields()
]);
}
- public function testConvertToSelectSQLStringInvalidOptionTableAndTables()
+ public function testConvertToSelectSQLStringInvalidOptionTableAndTables(): void
{
$this->expectException(DBInvalidOptionException::class);
@@ -2160,7 +2157,7 @@ public function testConvertToSelectSQLStringInvalidOptionTableAndTables()
]);
}
- public function testConvertToSelectSQLStringInvalidOptionResourceUsed()
+ public function testConvertToSelectSQLStringInvalidOptionResourceUsed(): void
{
$this->expectException(DBInvalidOptionException::class);
@@ -2176,7 +2173,7 @@ public function testConvertToSelectSQLStringInvalidOptionResourceUsed()
]);
}
- public function testConvertToUpdateSQLStringInvalidOptionNoChanges()
+ public function testConvertToUpdateSQLStringInvalidOptionNoChanges(): void
{
$this->expectException(DBInvalidOptionException::class);
@@ -2186,7 +2183,7 @@ public function testConvertToUpdateSQLStringInvalidOptionNoChanges()
]);
}
- public function testConvertToUpdateSQLStringInvalidOptionBadChange()
+ public function testConvertToUpdateSQLStringInvalidOptionBadChange(): void
{
$this->expectException(DBInvalidOptionException::class);
@@ -2197,7 +2194,7 @@ public function testConvertToUpdateSQLStringInvalidOptionBadChange()
]);
}
- public function testConvertToUpdateSQLStringInvalidOptionBadChange2()
+ public function testConvertToUpdateSQLStringInvalidOptionBadChange2(): void
{
$this->expectException(DBInvalidOptionException::class);
@@ -2210,7 +2207,7 @@ public function testConvertToUpdateSQLStringInvalidOptionBadChange2()
]);
}
- public function testConvertToUpdateSQLStringInvalidOptionBadExpression()
+ public function testConvertToUpdateSQLStringInvalidOptionBadExpression(): void
{
$this->expectException(DBInvalidOptionException::class);
@@ -2220,7 +2217,7 @@ public function testConvertToUpdateSQLStringInvalidOptionBadExpression()
]);
}
- public function testConvertToUpdateSQLStringInvalidOptionBadExpression2()
+ public function testConvertToUpdateSQLStringInvalidOptionBadExpression2(): void
{
$this->expectException(DBInvalidOptionException::class);
@@ -2228,7 +2225,7 @@ public function testConvertToUpdateSQLStringInvalidOptionBadExpression2()
$this->db->update('blobs.aa_sexy', [':no_equal_sign:' => 5], ['blabla' => 5]);
}
- public function testInsertOrUpdateEmulationNoIndex()
+ public function testInsertOrUpdateEmulationNoIndex(): void
{
$this->expectException(DBInvalidOptionException::class);
@@ -2239,7 +2236,7 @@ public function testInsertOrUpdateEmulationNoIndex()
], []);
}
- public function testInsertOrUpdateEmulationIndexNotInRow()
+ public function testInsertOrUpdateEmulationIndexNotInRow(): void
{
$this->expectException(DBInvalidOptionException::class);
diff --git a/tests/DoctrineMySQLImplementationTest.php b/tests/DoctrineMySQLImplementationTest.php
index 8aafb9f..44cf2f8 100644
--- a/tests/DoctrineMySQLImplementationTest.php
+++ b/tests/DoctrineMySQLImplementationTest.php
@@ -5,6 +5,8 @@
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Result;
use Doctrine\DBAL\Statement;
+use Hamcrest\Core\IsEqual;
+use Mockery\MockInterface;
use Squirrel\Queries\Doctrine\DBMySQLImplementation;
use Squirrel\Queries\Exception\DBInvalidOptionException;
@@ -13,14 +15,8 @@
*/
class DoctrineMySQLImplementationTest extends \PHPUnit\Framework\TestCase
{
- /**
- * @var DBMySQLImplementation
- */
- private $db;
-
- /**
- * @var Connection
- */
+ private DBMySQLImplementation $db;
+ /** @var Connection&MockInterface */
private $connection;
/**
@@ -36,7 +32,7 @@ protected function setUp(): void
$this->db = new DBMySQLImplementation($this->connection);
}
- private function bindValues($statement, $vars)
+ private function bindValues(MockInterface $statement, array $vars): void
{
$varCounter = 1;
@@ -44,14 +40,14 @@ private function bindValues($statement, $vars)
$statement
->shouldReceive('bindValue')
->once()
- ->with(\Mockery::mustBe($varCounter++), \Mockery::mustBe($var), \PDO::PARAM_STR);
+ ->with(IsEqual::equalTo($varCounter++), IsEqual::equalTo($var), \PDO::PARAM_STR);
}
}
/**
* Test vanilla upsert without explicit update part
*/
- public function testUpsert()
+ public function testUpsert(): void
{
// SQL query which should be generated by the implementation
$sql = 'INSERT INTO ' . $this->quoteIdentifier('example.example') .
@@ -93,7 +89,7 @@ public function testUpsert()
$this->connection
->shouldReceive('prepare')
->once()
- ->with(\Mockery::mustBe($sql))
+ ->with(IsEqual::equalTo($sql))
->andReturn($statement);
// Close result set
@@ -141,7 +137,7 @@ function ($p) {
/**
* Test upsert with an explicit update part
*/
- public function testUpsertCustomUpdate()
+ public function testUpsertCustomUpdate(): void
{
// SQL query which should be generated by the implementation
$sql = 'INSERT INTO ' . $this->quoteIdentifier('example.example') . ' (' .
@@ -184,7 +180,7 @@ public function testUpsertCustomUpdate()
$this->connection
->shouldReceive('prepare')
->once()
- ->with(\Mockery::mustBe($sql))
+ ->with(IsEqual::equalTo($sql))
->andReturn($statement);
// Close result set
@@ -216,7 +212,7 @@ public function testUpsertCustomUpdate()
/**
* Test upsert with an explicit update part and escapeable variables in there
*/
- public function testUpsertCustomUpdateWithVars()
+ public function testUpsertCustomUpdateWithVars(): void
{
// SQL query which should be generated by the implementation
$sql = 'INSERT INTO ' . $this->quoteIdentifier('example.example') . ' (' .
@@ -261,7 +257,7 @@ public function testUpsertCustomUpdateWithVars()
$this->connection
->shouldReceive('prepare')
->once()
- ->with(\Mockery::mustBe($sql))
+ ->with(IsEqual::equalTo($sql))
->andReturn($statement);
// Close result set
@@ -294,7 +290,7 @@ public function testUpsertCustomUpdateWithVars()
/**
* Test upsert with an explicit update part and escapeable variables in there
*/
- public function testUpsertNoUpdateRows()
+ public function testUpsertNoUpdateRows(): void
{
// SQL query which should be generated by the implementation
$sql = 'INSERT INTO ' . $this->quoteIdentifier('example.example') . ' (' .
@@ -325,7 +321,7 @@ public function testUpsertNoUpdateRows()
$this->connection
->shouldReceive('prepare')
->once()
- ->with(\Mockery::mustBe($sql))
+ ->with(IsEqual::equalTo($sql))
->andReturn($statement);
// Close result set
@@ -345,7 +341,7 @@ public function testUpsertNoUpdateRows()
$this->assertTrue(true);
}
- public function testUpsertInvalidOptionNoTableName()
+ public function testUpsertInvalidOptionNoTableName(): void
{
// Expect an InvalidOptions exception
$this->expectException(DBInvalidOptionException::class);
@@ -357,7 +353,7 @@ public function testUpsertInvalidOptionNoTableName()
]);
}
- public function testUpsertInvalidOptionNoRow()
+ public function testUpsertInvalidOptionNoRow(): void
{
// Expect an InvalidOptions exception
$this->expectException(DBInvalidOptionException::class);
diff --git a/tests/DoctrinePostgreSQLImplementationTest.php b/tests/DoctrinePostgreSQLImplementationTest.php
index fd20960..dc3066d 100644
--- a/tests/DoctrinePostgreSQLImplementationTest.php
+++ b/tests/DoctrinePostgreSQLImplementationTest.php
@@ -5,6 +5,8 @@
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Result;
use Doctrine\DBAL\Statement;
+use Hamcrest\Core\IsEqual;
+use Mockery\MockInterface;
use Squirrel\Queries\Doctrine\DBPostgreSQLImplementation;
use Squirrel\Queries\Exception\DBInvalidOptionException;
@@ -13,15 +15,9 @@
*/
class DoctrinePostgreSQLImplementationTest extends \PHPUnit\Framework\TestCase
{
- /**
- * @var DBPostgreSQLImplementation
- */
- private $db;
-
- /**
- * @var Connection
- */
- private $connection;
+ private DBPostgreSQLImplementation $db;
+ /** @var Connection&MockInterface */
+ private Connection $connection;
/**
* Prepare common aspects of all tests
@@ -36,7 +32,7 @@ protected function setUp(): void
$this->db = new DBPostgreSQLImplementation($this->connection);
}
- private function bindValues($statement, $vars)
+ private function bindValues(MockInterface $statement, array $vars): void
{
$varCounter = 1;
@@ -44,11 +40,11 @@ private function bindValues($statement, $vars)
$statement
->shouldReceive('bindValue')
->once()
- ->with(\Mockery::mustBe($varCounter++), \Mockery::mustBe($var), \PDO::PARAM_STR);
+ ->with(IsEqual::equalTo($varCounter++), IsEqual::equalTo($var), \PDO::PARAM_STR);
}
}
- public function testFetchOne()
+ public function testFetchOne(): void
{
// Query parameters
$query = 'SELECT blob FROM yudihui WHERE active = ? AND name = ? AND balance = ?';
@@ -62,14 +58,14 @@ public function testFetchOne()
$this->connection
->shouldReceive('prepare')
->once()
- ->with(\Mockery::mustBe($query))
+ ->with(IsEqual::equalTo($query))
->andReturn($statement);
// "Execute" call on doctrine result statement
$statement
->shouldReceive('executeQuery')
->once()
- ->with(\Mockery::mustBe($vars))
+ ->with(IsEqual::equalTo($vars))
->andReturn($statementResult);
$fp = \fopen('php://temp', 'rb+');
@@ -93,7 +89,7 @@ public function testFetchOne()
$this->assertEquals(['blob' => 'binary data!'], $result);
}
- public function testFetchAll()
+ public function testFetchAll(): void
{
// Query parameters
$query = 'SELECT blob FROM yudihui WHERE active = ? AND name = ? AND balance = ?';
@@ -107,14 +103,14 @@ public function testFetchAll()
$this->connection
->shouldReceive('prepare')
->once()
- ->with(\Mockery::mustBe($query))
+ ->with(IsEqual::equalTo($query))
->andReturn($statement);
// "Execute" call on doctrine result statement
$statement
->shouldReceive('executeQuery')
->once()
- ->with(\Mockery::mustBe($vars))
+ ->with(IsEqual::equalTo($vars))
->andReturn($statementResult);
$fp = \fopen('php://temp', 'rb+');
@@ -141,7 +137,7 @@ public function testFetchAll()
/**
* Test vanilla upsert without explicit update part
*/
- public function testUpsert()
+ public function testUpsert(): void
{
// SQL query which should be generated by the implementation
$sql = 'INSERT INTO ' . $this->quoteIdentifier('example.example') .
@@ -184,7 +180,7 @@ public function testUpsert()
$this->connection
->shouldReceive('prepare')
->once()
- ->with(\Mockery::mustBe($sql))
+ ->with(IsEqual::equalTo($sql))
->andReturn($statement);
// Close result set
@@ -232,7 +228,7 @@ function ($p) {
/**
* Test upsert with an explicit update part
*/
- public function testUpsertCustomUpdate()
+ public function testUpsertCustomUpdate(): void
{
// SQL query which should be generated by the implementation
$sql = 'INSERT INTO ' . $this->quoteIdentifier('example.example') . ' (' .
@@ -276,7 +272,7 @@ public function testUpsertCustomUpdate()
$this->connection
->shouldReceive('prepare')
->once()
- ->with(\Mockery::mustBe($sql))
+ ->with(IsEqual::equalTo($sql))
->andReturn($statement);
// Close result set
@@ -308,7 +304,7 @@ public function testUpsertCustomUpdate()
/**
* Test upsert with an explicit update part and escapeable variables in there
*/
- public function testUpsertCustomUpdateWithVars()
+ public function testUpsertCustomUpdateWithVars(): void
{
// SQL query which should be generated by the implementation
$sql = 'INSERT INTO ' . $this->quoteIdentifier('example.example') . ' (' .
@@ -354,7 +350,7 @@ public function testUpsertCustomUpdateWithVars()
$this->connection
->shouldReceive('prepare')
->once()
- ->with(\Mockery::mustBe($sql))
+ ->with(IsEqual::equalTo($sql))
->andReturn($statement);
// Close result set
@@ -387,7 +383,7 @@ public function testUpsertCustomUpdateWithVars()
/**
* Test upsert with an explicit update part and escapeable variables in there
*/
- public function testUpsertNoUpdateRows()
+ public function testUpsertNoUpdateRows(): void
{
// SQL query which should be generated by the implementation
$sql = 'INSERT INTO ' . $this->quoteIdentifier('example.example') . ' (' .
@@ -423,7 +419,7 @@ public function testUpsertNoUpdateRows()
$this->connection
->shouldReceive('prepare')
->once()
- ->with(\Mockery::mustBe($sql))
+ ->with(IsEqual::equalTo($sql))
->andReturn($statement);
// Close result set
@@ -443,7 +439,7 @@ public function testUpsertNoUpdateRows()
$this->assertTrue(true);
}
- public function testUpsertInvalidOptionNoTableName()
+ public function testUpsertInvalidOptionNoTableName(): void
{
// Expect an InvalidOptions exception
$this->expectException(DBInvalidOptionException::class);
@@ -455,7 +451,7 @@ public function testUpsertInvalidOptionNoTableName()
]);
}
- public function testUpsertInvalidOptionNoRow()
+ public function testUpsertInvalidOptionNoRow(): void
{
// Expect an InvalidOptions exception
$this->expectException(DBInvalidOptionException::class);
diff --git a/tests/DoctrineSQLiteImplementationTest.php b/tests/DoctrineSQLiteImplementationTest.php
index 09a410b..134d29f 100644
--- a/tests/DoctrineSQLiteImplementationTest.php
+++ b/tests/DoctrineSQLiteImplementationTest.php
@@ -6,19 +6,15 @@
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Result;
use Doctrine\DBAL\Statement;
+use Hamcrest\Core\IsEqual;
+use Mockery\MockInterface;
use Squirrel\Queries\Doctrine\DBSQLiteImplementation;
class DoctrineSQLiteImplementationTest extends \PHPUnit\Framework\TestCase
{
- /**
- * @var DBSQLiteImplementation
- */
- private $db;
-
- /**
- * @var Connection
- */
- private $connection;
+ private DBSQLiteImplementation $db;
+ /** @var Connection&MockInterface */
+ private Connection $connection;
/**
* Prepare common aspects of all tests
@@ -33,7 +29,7 @@ protected function setUp(): void
$this->db = new DBSQLiteImplementation($this->connection);
}
- private function bindValues($statement, $vars)
+ private function bindValues(MockInterface $statement, array $vars): void
{
$varCounter = 1;
@@ -41,11 +37,11 @@ private function bindValues($statement, $vars)
$statement
->shouldReceive('bindValue')
->once()
- ->with(\Mockery::mustBe($varCounter++), \Mockery::mustBe($var), \PDO::PARAM_STR);
+ ->with(IsEqual::equalTo($varCounter++), IsEqual::equalTo($var), \PDO::PARAM_STR);
}
}
- public function testFetchOneStructured2()
+ public function testFetchOneStructured2(): void
{
// Query parameters
$query = 'SELECT "c"."cart_id","c"."checkout_step","s"."session_id","s"."user_id","s"."domain" ' .
@@ -101,14 +97,14 @@ public function testFetchOneStructured2()
$this->connection
->shouldReceive('prepare')
->once()
- ->with(\Mockery::mustBe($query))
+ ->with(IsEqual::equalTo($query))
->andReturn($statement);
// "Execute" call on doctrine result statement
$statement
->shouldReceive('executeQuery')
->once()
- ->with(\Mockery::mustBe($vars))
+ ->with(IsEqual::equalTo($vars))
->andReturn($statementResult);
// Return value from fetch
diff --git a/tests/Integration/AbstractDoctrineIntegrationTests.php b/tests/Integration/AbstractDoctrineIntegrationTests.php
index 9aa66cc..8cc8f46 100644
--- a/tests/Integration/AbstractDoctrineIntegrationTests.php
+++ b/tests/Integration/AbstractDoctrineIntegrationTests.php
@@ -45,7 +45,7 @@ protected function setUp(): void
self::$db->change($this->createAccountTableQuery());
}
- public function testInsert()
+ public function testInsert(): void
{
if (self::$db === null) {
return;
@@ -74,6 +74,10 @@ public function testInsert()
],
]);
+ if ($insertedData === null) {
+ throw new \LogicException('Inserted row not found');
+ }
+
$accountData['picture'] = \hex2bin(\md5('dadaism'));
$accountData['phone'] = null;
$accountData['user_id'] = $userId;
@@ -91,7 +95,7 @@ public function testInsert()
$this->assertEquals($accountData, $insertedData);
}
- public function testInsertOrUpdateWithUpdate()
+ public function testInsertOrUpdateWithUpdate(): void
{
if (self::$db === null) {
return;
@@ -131,6 +135,10 @@ public function testInsertOrUpdateWithUpdate()
],
]);
+ if ($insertedData === null) {
+ throw new \LogicException('Inserted row not found');
+ }
+
$accountData['phone'] = null;
$insertedData['user_id'] = \intval($insertedData['user_id']);
@@ -146,7 +154,7 @@ public function testInsertOrUpdateWithUpdate()
$this->assertEquals($accountData, $insertedData);
}
- public function testInsertOrUpdateWithInsert()
+ public function testInsertOrUpdateWithInsert(): void
{
if (self::$db === null) {
return;
@@ -186,6 +194,10 @@ public function testInsertOrUpdateWithInsert()
],
]);
+ if ($insertedData === null) {
+ throw new \LogicException('Inserted row not found');
+ }
+
$accountData['phone'] = null;
$accountData['user_id'] = \intval($accountData['user_id']);
$insertedData['user_id'] = \intval($insertedData['user_id']);
@@ -202,7 +214,7 @@ public function testInsertOrUpdateWithInsert()
$this->assertEquals($accountData, $insertedData);
}
- public function testInsertOrUpdateNoUpdate()
+ public function testInsertOrUpdateNoUpdate(): void
{
if (self::$db === null) {
return;
@@ -232,10 +244,14 @@ public function testInsertOrUpdateNoUpdate()
],
]);
+ if ($insertedData === null) {
+ throw new \LogicException('Inserted row not found');
+ }
+
$this->assertEquals(800, \intval($insertedData['balance']));
}
- public function testUpdate()
+ public function testUpdate(): void
{
if (self::$db === null) {
return;
@@ -267,6 +283,10 @@ public function testUpdate()
],
]);
+ if ($insertedData === null) {
+ throw new \LogicException('Inserted row not found');
+ }
+
$accountData['picture'] = \hex2bin(\md5('dadaism'));
$accountData['phone'] = null;
$accountData['user_id'] = 2;
@@ -291,7 +311,7 @@ public function testUpdate()
$this->assertEquals(1, $rowsAffected);
}
- public function testCount()
+ public function testCount(): void
{
if (self::$db === null) {
return;
@@ -304,6 +324,10 @@ public function testCount()
],
]);
+ if ($rowData === null) {
+ throw new \LogicException('Expected row did not exist');
+ }
+
$rowData['num'] = \intval($rowData['num']);
$this->assertEquals(['num' => 0], $rowData);
@@ -317,12 +341,16 @@ public function testCount()
],
]);
+ if ($rowData === null) {
+ throw new \LogicException('Expected row did not exist');
+ }
+
$rowData['num'] = \intval($rowData['num']);
$this->assertEquals(['num' => 2], $rowData);
}
- public function testSelect()
+ public function testSelect(): void
{
if (self::$db === null) {
return;
@@ -357,6 +385,10 @@ public function testSelect()
],
]);
+ if ($rowData === null) {
+ throw new \LogicException('Expected row did not exist');
+ }
+
$rowData['user_id'] = \intval($rowData['user_id']);
$rowData['active'] = \boolval($rowData['active']);
$rowData['create_date'] = \intval($rowData['create_date']);
@@ -365,7 +397,7 @@ public function testSelect()
$this->assertEquals($accountData, $rowData);
}
- public function testSelectFlattened()
+ public function testSelectFlattened(): void
{
if (self::$db === null) {
return;
@@ -388,7 +420,7 @@ public function testSelectFlattened()
$this->assertEquals(['Mary', 'John'], $flattenedResults);
}
- public function testSelectFieldsWithAlias()
+ public function testSelectFieldsWithAlias(): void
{
if (self::$db === null) {
return;
@@ -414,13 +446,17 @@ public function testSelectFieldsWithAlias()
],
]);
+ if ($rowData === null) {
+ throw new \LogicException('Expected row did not exist');
+ }
+
$rowData['id'] = \intval($rowData['id']);
$rowData['active'] = \boolval($rowData['active']);
$this->assertEquals($accountData, $rowData);
}
- public function testSelectWithGroupByOrderBy()
+ public function testSelectWithGroupByOrderBy(): void
{
if (self::$db === null) {
return;
@@ -560,6 +596,10 @@ public function testSelectWithGroupByOrderBy()
],
]);
+ if ($rowsData === null) {
+ throw new \LogicException('Expected row did not exist');
+ }
+
$this->assertEquals([
'username' => 'Mary',
'number' => 1,
@@ -574,7 +614,7 @@ public function testSelectWithGroupByOrderBy()
$this->assertEquals(4, \count($rowsData));
}
- public function testTransactionSelectAndUpdate()
+ public function testTransactionSelectAndUpdate(): void
{
if (self::$db === null) {
return;
@@ -607,6 +647,10 @@ public function testTransactionSelectAndUpdate()
'lock' => true,
]);
+ if ($rowData === null) {
+ throw new \LogicException('Expected row did not exist');
+ }
+
$rowData['id'] = \intval($rowData['id']);
$rowData['active'] = \boolval($rowData['active']);
@@ -620,7 +664,7 @@ public function testTransactionSelectAndUpdate()
});
}
- public function testDelete()
+ public function testDelete(): void
{
if (self::$db === null) {
return;
@@ -646,7 +690,7 @@ public function testDelete()
$this->assertEquals(0, $rowsAffected);
}
- private function initializeDataWithDefaultTwoEntries()
+ private function initializeDataWithDefaultTwoEntries(): void
{
self::$db->insert('account', [
'username' => 'Mary',
diff --git a/tests/Integration/MariaDBDoctrineIntegrationTest.php b/tests/Integration/MariaDBDoctrineIntegrationTest.php
index c8c747d..2867795 100644
--- a/tests/Integration/MariaDBDoctrineIntegrationTest.php
+++ b/tests/Integration/MariaDBDoctrineIntegrationTest.php
@@ -49,7 +49,7 @@ protected static function createAccountTableQuery(): string
) ENGINE InnoDB;';
}
- public function testInsertNoLargeObject()
+ public function testInsertNoLargeObject(): void
{
if (self::$db === null) {
return;
@@ -76,6 +76,10 @@ public function testInsertNoLargeObject()
],
]);
+ if ($insertedData === null) {
+ throw new \LogicException('Inserted row not found');
+ }
+
$accountData['picture'] = \hex2bin(\md5('dadaism'));
$accountData['phone'] = null;
$accountData['user_id'] = $userId;
diff --git a/tests/Integration/MySQLDoctrineIntegrationTest.php b/tests/Integration/MySQLDoctrineIntegrationTest.php
index 3bdbab0..ae34ea6 100644
--- a/tests/Integration/MySQLDoctrineIntegrationTest.php
+++ b/tests/Integration/MySQLDoctrineIntegrationTest.php
@@ -49,7 +49,7 @@ protected static function createAccountTableQuery(): string
) ENGINE InnoDB;';
}
- public function testInsertNoLargeObject()
+ public function testInsertNoLargeObject(): void
{
if (self::$db === null) {
return;
@@ -76,6 +76,10 @@ public function testInsertNoLargeObject()
],
]);
+ if ($insertedData === null) {
+ throw new \LogicException('Inserted row not found');
+ }
+
$accountData['picture'] = \hex2bin(\md5('dadaism'));
$accountData['phone'] = null;
$accountData['user_id'] = $userId;
diff --git a/tests/Integration/PostgreSQLDoctrineIntegrationTest.php b/tests/Integration/PostgreSQLDoctrineIntegrationTest.php
index 9c61008..c39fb1c 100644
--- a/tests/Integration/PostgreSQLDoctrineIntegrationTest.php
+++ b/tests/Integration/PostgreSQLDoctrineIntegrationTest.php
@@ -45,7 +45,7 @@ protected static function createAccountTableQuery(): string
);';
}
- public function testSpecialTypes()
+ public function testSpecialTypes(): void
{
if (self::$db === null) {
return;
@@ -71,6 +71,10 @@ public function testSpecialTypes()
'table' => 'locations',
]);
+ if ($entry === null) {
+ throw new \LogicException('Inserted row not found');
+ }
+
$entry['create_date'] = \intval($entry['create_date']);
$this->assertEquals([
diff --git a/tests/Integration/SQLiteDoctrineIntegrationTest.php b/tests/Integration/SQLiteDoctrineIntegrationTest.php
index 913fd34..4e56f52 100644
--- a/tests/Integration/SQLiteDoctrineIntegrationTest.php
+++ b/tests/Integration/SQLiteDoctrineIntegrationTest.php
@@ -43,7 +43,7 @@ protected static function createAccountTableQuery(): string
);';
}
- public function testInsertNoLargeObject()
+ public function testInsertNoLargeObject(): void
{
if (self::$db === null) {
return;
@@ -70,6 +70,10 @@ public function testInsertNoLargeObject()
],
]);
+ if ($insertedData === null) {
+ throw new \LogicException('Inserted row not found');
+ }
+
$accountData['picture'] = \hex2bin(\md5('dadaism'));
$accountData['phone'] = null;
$accountData['user_id'] = $userId;
diff --git a/tests/LargeObjectTest.php b/tests/LargeObjectTest.php
index eedb37f..531a2e7 100644
--- a/tests/LargeObjectTest.php
+++ b/tests/LargeObjectTest.php
@@ -6,7 +6,7 @@
class LargeObjectTest extends \PHPUnit\Framework\TestCase
{
- public function testObject()
+ public function testObject(): void
{
$obj = new LargeObject('some string');
diff --git a/vendor-bin/psalm/composer.json b/vendor-bin/psalm/composer.json
index d522577..150fb9d 100644
--- a/vendor-bin/psalm/composer.json
+++ b/vendor-bin/psalm/composer.json
@@ -1,5 +1,7 @@
{
"require": {
- "vimeo/psalm": "^4.0"
+ "vimeo/psalm": "^4.0",
+ "psalm/plugin-phpunit": "^0.16",
+ "psalm/plugin-mockery": "^0.7"
}
}