diff --git a/.gitignore b/.gitignore index 62109a5..1c9cae8 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ vendor tests/unit/coverage/* tests/integration/coverage/* +tests/unit/.phpunit.result.cache .vagrant/ .bash_history .cache/motd.legal-displayed diff --git a/composer.json b/composer.json index ec5e439..4488bd6 100644 --- a/composer.json +++ b/composer.json @@ -32,30 +32,33 @@ "G4\\DataMapper\\Test\\Integration\\": "tests/integration" } }, + "include-path": [ + "vendor/g4/zf1-future-zend-db/library/" + ], "require-dev": { - "phpunit/phpunit" : "5.*", - "phpunit/php-code-coverage" : "^3", + "phpunit/phpunit" : "9.6.*", + "phpunit/php-code-coverage" : "9.2.*", "squizlabs/php_codesniffer" : "3.*", "g4/code-coverage" : "1.*" }, "require": { - "php" : ">=5.6", + "php" : ">=7.3", "ext-curl" : "*", "ext-json" : "*", "g4/factory" : "1.*", "g4/profiler" : ">=1.11.0", "g4/value-object" : ">=3.6.0", - "zf1/zend-db" : "1.12.*" + "g4/zf1-future-zend-db" : "1.23.*" }, "scripts": { "unit-test": [ - "vendor/bin/phpunit -c tests/unit/phpunit.xml --colors=always --coverage-html tests/unit/coverage" + "XDEBUG_MODE=coverage vendor/bin/phpunit -c tests/unit/phpunit.xml --colors=always --coverage-html tests/unit/coverage" ], "test-coverage": [ - "./vendor/bin/phpunit --colors=always -c tests/unit/phpunit.xml --coverage-text" + "XDEBUG_MODE=coverage ./vendor/bin/phpunit --colors=always -c tests/unit/phpunit.xml --coverage-text" ], "test-report": [ - "./vendor/bin/phpunit --colors=always -c tests/unit/phpunit.xml --coverage-clover=tests/unit/coverage/code-coverage.xml" + ".XDEBUG_MODE=coverage /vendor/bin/phpunit --colors=always -c tests/unit/phpunit.xml --coverage-clover=tests/unit/coverage/code-coverage.xml" ], "code-coverage": [ "./vendor/bin/code-coverage -p 90 -f tests/unit/coverage/code-coverage.xml" diff --git a/src/Engine/Elasticsearch/ElasticsearchClient.php b/src/Engine/Elasticsearch/ElasticsearchClient.php index a09252b..a263540 100644 --- a/src/Engine/Elasticsearch/ElasticsearchClient.php +++ b/src/Engine/Elasticsearch/ElasticsearchClient.php @@ -307,7 +307,7 @@ private function throwCurlException($code, $message, $url, $body, $response) { throw new ClientException( sprintf( - "Unexpected response code:%s from ES has been returned on submit. More info: %s. Url: %s. Body: %s. Response: %s", + "Unexpected response code:%s from ES has been returned on submit. More info: %s. Url: %s. Body: %s. Response: %s", // phpcs:ignore $code, json_encode($message), (string) $url, diff --git a/src/Engine/Elasticsearch/Operators/ConsistentRandomKey.php b/src/Engine/Elasticsearch/Operators/ConsistentRandomKey.php index de5db81..b9be4ba 100644 --- a/src/Engine/Elasticsearch/Operators/ConsistentRandomKey.php +++ b/src/Engine/Elasticsearch/Operators/ConsistentRandomKey.php @@ -27,4 +27,4 @@ public function format() ] ]; } -} \ No newline at end of file +} diff --git a/src/Engine/Elasticsearch/Operators/ExistsOperator.php b/src/Engine/Elasticsearch/Operators/ExistsOperator.php index 7c346ef..4149767 100644 --- a/src/Engine/Elasticsearch/Operators/ExistsOperator.php +++ b/src/Engine/Elasticsearch/Operators/ExistsOperator.php @@ -20,6 +20,6 @@ public function __construct($name, SingleValue $value) public function format() { - return [QueryConnector::EXISTS => ['field' => $this->name]]; + return [QueryConnector::EXISTS => ['field' => $this->name]]; } } diff --git a/src/Engine/Elasticsearch/Operators/LikeCIOperator.php b/src/Engine/Elasticsearch/Operators/LikeCIOperator.php index c17ece1..3748764 100644 --- a/src/Engine/Elasticsearch/Operators/LikeCIOperator.php +++ b/src/Engine/Elasticsearch/Operators/LikeCIOperator.php @@ -29,7 +29,9 @@ public function format() { return [ QueryConnector::NAME_QUERY_STRING => [ - QueryConnector::NAME_QUERY_STRING_QUERY => $this->name . ":" . QueryConnector::ROUND_BRACKET_OPEN . QueryConnector::WILDCARD . $this->value . QueryConnector::WILDCARD . QueryConnector::ROUND_BRACKET_CLOSE + QueryConnector::NAME_QUERY_STRING_QUERY => + $this->name . QueryConnector::COLON . QueryConnector::ROUND_BRACKET_OPEN . QueryConnector::WILDCARD + . $this->value . QueryConnector::WILDCARD . QueryConnector::ROUND_BRACKET_CLOSE ] ]; } diff --git a/src/Engine/Elasticsearch/Version7/Operators/ConsistentRandomKey.php b/src/Engine/Elasticsearch/Version7/Operators/ConsistentRandomKey.php index 80c678b..c28ebfc 100644 --- a/src/Engine/Elasticsearch/Version7/Operators/ConsistentRandomKey.php +++ b/src/Engine/Elasticsearch/Version7/Operators/ConsistentRandomKey.php @@ -29,4 +29,4 @@ public function format() ] ]; } -} \ No newline at end of file +} diff --git a/src/Engine/Elasticsearch/Version7/Operators/LikeCIOperator.php b/src/Engine/Elasticsearch/Version7/Operators/LikeCIOperator.php index 7e32e26..50fd8fd 100644 --- a/src/Engine/Elasticsearch/Version7/Operators/LikeCIOperator.php +++ b/src/Engine/Elasticsearch/Version7/Operators/LikeCIOperator.php @@ -29,7 +29,8 @@ public function format() { return [ QueryConnector::NAME_QUERY_STRING => [ - QueryConnector::NAME_QUERY_STRING_QUERY => $this->name . ":" . QueryConnector::WILDCARD . strtolower($this->value) . QueryConnector::WILDCARD + QueryConnector::NAME_QUERY_STRING_QUERY => + $this->name . ":" . QueryConnector::WILDCARD . strtolower($this->value) . QueryConnector::WILDCARD ] ]; } diff --git a/src/Engine/Http/HttpPath.php b/src/Engine/Http/HttpPath.php index 590225e..8becf47 100644 --- a/src/Engine/Http/HttpPath.php +++ b/src/Engine/Http/HttpPath.php @@ -20,7 +20,7 @@ class HttpPath implements CollectionNameInterface * HttpPath constructor. * @param array ...$parts string */ - public function __construct(... $parts) + public function __construct(...$parts) { $path = join(self::SLASH, $parts); diff --git a/tests/unit/src/BuilderTest.php b/tests/unit/src/BuilderTest.php index fd95401..750b446 100644 --- a/tests/unit/src/BuilderTest.php +++ b/tests/unit/src/BuilderTest.php @@ -1,9 +1,10 @@ params = [ 'host' => 'localhost', @@ -29,7 +29,7 @@ protected function setUp() $this->builder = Builder::create(); } - protected function tearDown() + protected function tearDown(): void { $this->params = null; $this->builder = null; @@ -54,7 +54,7 @@ public function testBuildMapper() $this->builder ->collectionName(new MySQLTableName('profiles')) ->adapter($this->getMockForMySQLAdapter()); - $this->builder->buildMapper(); + $this->assertInstanceOf(MySQLMapper::class, $this->builder->buildMapper()); } public function testBuildBulk() @@ -76,7 +76,7 @@ public function testBuildWithNoAdapter() public function testBuildWithNoType() { - $this->builder->adapter($this->getMock('\G4\DataMapper\Common\AdapterInterface')); + $this->builder->adapter($this->createMock('\G4\DataMapper\Common\AdapterInterface')); $this->expectException('\Exception'); $this->expectExceptionCode(601); $this->expectExceptionMessage('DataSet cannot be emty'); @@ -86,7 +86,7 @@ public function testBuildWithNoType() public function testBuildForUnknownEngine() { $this->builder - ->adapter($this->getMock('\G4\DataMapper\Common\AdapterInterface')) + ->adapter($this->createMock('\G4\DataMapper\Common\AdapterInterface')) ->collectionName(new MySQLTableName('profiles')); $this->expectException('\Exception'); $this->expectExceptionCode(601); @@ -104,12 +104,10 @@ public function testBuildTransaction() private function getMockForMySQLAdapter() { - return $this->getMock( - '\G4\DataMapper\Engine\MySQL\MySQLAdapter', - null, - [ - $this->getMock('\G4\DataMapper\Engine\MySQL\MySQLClientFactory', null, [$this->params]), - ] - ); + return $this->getMockBuilder('\G4\DataMapper\Engine\MySQL\MySQLAdapter') + ->setConstructorArgs([ + $this->createMock('\G4\DataMapper\Engine\MySQL\MySQLClientFactory'), + ]) + ->getMock(); } } \ No newline at end of file diff --git a/tests/unit/src/Common/BulkTest.php b/tests/unit/src/Common/BulkTest.php index fbfc3b2..aa63a9c 100644 --- a/tests/unit/src/Common/BulkTest.php +++ b/tests/unit/src/Common/BulkTest.php @@ -2,7 +2,7 @@ use G4\DataMapper\Common\Bulk; -class BulkTest extends PHPUnit_Framework_TestCase +class BulkTest extends \PHPUnit\Framework\TestCase { /** @@ -21,7 +21,7 @@ class BulkTest extends PHPUnit_Framework_TestCase private $tableNameMock; - protected function setUp() + protected function setUp(): void { $this->adapterMock = $this->getMockBuilder('\G4\DataMapper\Common\AdapterInterface') ->disableOriginalConstructor() @@ -39,7 +39,7 @@ protected function setUp() $this->bulk = new Bulk($this->adapterMock, $this->tableNameMock); } - protected function tearDown() + protected function tearDown(): void { $this->adapterMock = null; $this->tableNameMock = null; diff --git a/tests/unit/src/Common/CoordinatesValueTest.php b/tests/unit/src/Common/CoordinatesValueTest.php index d96a3c2..69441d7 100644 --- a/tests/unit/src/Common/CoordinatesValueTest.php +++ b/tests/unit/src/Common/CoordinatesValueTest.php @@ -2,7 +2,7 @@ use G4\DataMapper\Common\CoordinatesValue; -class CoordinatesValueTest extends PHPUnit_Framework_TestCase +class CoordinatesValueTest extends \PHPUnit\Framework\TestCase { /** @@ -10,12 +10,12 @@ class CoordinatesValueTest extends PHPUnit_Framework_TestCase */ private $coordinates; - protected function setUp() + protected function setUp(): void { $this->coordinates = new CoordinatesValue(46.100376, 19.667587, 100); } - protected function tearDown() + protected function tearDown(): void { $this->coordinates = null; } diff --git a/tests/unit/src/Common/IdentityTest.php b/tests/unit/src/Common/IdentityTest.php index 6550eec..39f6eca 100644 --- a/tests/unit/src/Common/IdentityTest.php +++ b/tests/unit/src/Common/IdentityTest.php @@ -2,7 +2,7 @@ use G4\DataMapper\Common\Identity; -class IdentityTest extends PHPUnit_Framework_TestCase +class IdentityTest extends \PHPUnit\Framework\TestCase { /** @@ -11,12 +11,12 @@ class IdentityTest extends PHPUnit_Framework_TestCase private $identity; - protected function setUp() + protected function setUp(): void { $this->identity = new Identity(); } - protected function tearDown() + protected function tearDown(): void { $this->identity = null; } @@ -27,7 +27,8 @@ public function testEqual() $this->assertInstanceOf(\G4\DataMapper\Common\Selection\Comparison::class, $this->identity->getComparisons()[0]); - $this->setExpectedException('\Exception', 'Value can not be array'); + $this->expectException(\Exception::class); + $this->expectExceptionMessage('Value can not be array'); $this->identity->field('name')->equal([1]); } @@ -42,7 +43,8 @@ public function testGreaterThan() { $this->assertInstanceOf(\G4\DataMapper\Common\Identity::class, $this->identity->field('id')->greaterThan(1)); - $this->setExpectedException('\Exception', 'Value can not be array'); + $this->expectException(\Exception::class); + $this->expectExceptionMessage('Value can not be array'); $this->identity->field('name')->greaterThan([1]); } @@ -50,7 +52,8 @@ public function testGreaterThanOrEqual() { $this->assertInstanceOf(\G4\DataMapper\Common\Identity::class, $this->identity->field('id')->greaterThanOrEqual(1)); - $this->setExpectedException('\Exception', 'Value can not be array'); + $this->expectException(\Exception::class); + $this->expectExceptionMessage('Value can not be array'); $this->identity->field('name')->greaterThanOrEqual([1]); } @@ -63,7 +66,8 @@ public function testLessThan() { $this->assertInstanceOf(\G4\DataMapper\Common\Identity::class, $this->identity->field('id')->lessThan(1)); - $this->setExpectedException('\Exception', 'Value can not be array'); + $this->expectException(\Exception::class); + $this->expectExceptionMessage('Value can not be array'); $this->identity->field('name')->lessThan([1]); } @@ -71,7 +75,8 @@ public function testLessThanOrEqual() { $this->assertInstanceOf(\G4\DataMapper\Common\Identity::class, $this->identity->field('id')->lessThanOrEqual(1)); - $this->setExpectedException('\Exception', 'Value can not be array'); + $this->expectException(\Exception::class); + $this->expectExceptionMessage('Value can not be array'); $this->identity->field('name')->lessThanOrEqual([1]); } @@ -79,7 +84,8 @@ public function testLike() { $this->assertInstanceOf(\G4\DataMapper\Common\Identity::class, $this->identity->field('id')->like('this')); - $this->setExpectedException('\Exception', 'Value can not be array'); + $this->expectException(\Exception::class); + $this->expectExceptionMessage('Value can not be array'); $this->identity->field('name')->like([1]); } @@ -103,7 +109,8 @@ public function testNotEqual() { $this->assertInstanceOf(\G4\DataMapper\Common\Identity::class, $this->identity->field('id')->notEqual(1)); - $this->setExpectedException('\Exception', 'Value can not be array'); + $this->expectException(\Exception::class); + $this->expectExceptionMessage('Value can not be array'); $this->identity->field('name')->notEqual([1]); } @@ -120,7 +127,8 @@ public function testField() $this->assertFalse($this->identity->isVoid()); - $this->setExpectedException('\Exception', 'Incomplete field'); + $this->expectException(\Exception::class); + $this->expectExceptionMessage('Incomplete field'); $this->identity->field('name'); } @@ -130,13 +138,15 @@ public function testFieldAlreadySet() ->field('id') ->equal(1); - $this->setExpectedException('\Exception', 'Field is already set'); + $this->expectException(\Exception::class); + $this->expectExceptionMessage('Field is already set'); $this->identity->field('id'); } public function testFieldIsNotDefined() { - $this->setExpectedException('\Exception', 'Field is not defined'); + $this->expectException(\Exception::class); + $this->expectExceptionMessage('Field is not defined'); $this->identity->equal(1); } diff --git a/tests/unit/src/Common/RangeValueTest.php b/tests/unit/src/Common/RangeValueTest.php index 4bd4b81..3160f8d 100644 --- a/tests/unit/src/Common/RangeValueTest.php +++ b/tests/unit/src/Common/RangeValueTest.php @@ -2,16 +2,16 @@ use G4\DataMapper\Common\RangeValue; -class RangeValueTest extends PHPUnit_Framework_TestCase +class RangeValueTest extends \PHPUnit\Framework\TestCase { private $rangeValueObject; - protected function setup() + protected function setup(): void { $this->rangeValueObject = new RangeValue(5,18); } - protected function tearDown() + protected function tearDown(): void { $this->rangeValueObject = null; } diff --git a/tests/unit/src/Common/RawDataTest.php b/tests/unit/src/Common/RawDataTest.php index fd91c05..f914a21 100644 --- a/tests/unit/src/Common/RawDataTest.php +++ b/tests/unit/src/Common/RawDataTest.php @@ -2,7 +2,7 @@ use G4\DataMapper\Common\RawData; -class RawDataTest extends PHPUnit_Framework_TestCase +class RawDataTest extends \PHPUnit\Framework\TestCase { const ID_IDENTIFIER = 'id'; @@ -12,7 +12,7 @@ class RawDataTest extends PHPUnit_Framework_TestCase private $total; - protected function setUp() + protected function setUp(): void { $this->data = [ [ @@ -26,7 +26,7 @@ protected function setUp() $this->rawData = new RawData($this->data, $this->total); } - protected function tearDown() + protected function tearDown(): void { $this->data = null; $this->total = null; diff --git a/tests/unit/src/Common/Selection/ComparisonTest.php b/tests/unit/src/Common/Selection/ComparisonTest.php index 664ed06..cbf34b0 100644 --- a/tests/unit/src/Common/Selection/ComparisonTest.php +++ b/tests/unit/src/Common/Selection/ComparisonTest.php @@ -2,7 +2,7 @@ use G4\DataMapper\Common\Selection\Comparison; -class ComparisonTest extends PHPUnit_Framework_TestCase +class ComparisonTest extends \PHPUnit\Framework\TestCase { public function testGetComparison() diff --git a/tests/unit/src/Common/Selection/FieldTest.php b/tests/unit/src/Common/Selection/FieldTest.php index cdca4d4..18a6709 100644 --- a/tests/unit/src/Common/Selection/FieldTest.php +++ b/tests/unit/src/Common/Selection/FieldTest.php @@ -2,17 +2,17 @@ use G4\DataMapper\Common\Selection\Field; -class FieldTest extends PHPUnit_Framework_TestCase +class FieldTest extends \PHPUnit\Framework\TestCase { private $field; - protected function setUp() + protected function setUp(): void { $this->field = new Field('id'); } - protected function tearDown() + protected function tearDown(): void { $this->field = null; } diff --git a/tests/unit/src/Common/Selection/OperatorTest.php b/tests/unit/src/Common/Selection/OperatorTest.php index 0d031bb..33d0571 100644 --- a/tests/unit/src/Common/Selection/OperatorTest.php +++ b/tests/unit/src/Common/Selection/OperatorTest.php @@ -2,7 +2,7 @@ use G4\DataMapper\Common\Selection\Operator; -class OperatorTest extends PHPUnit_Framework_TestCase +class OperatorTest extends \PHPUnit\Framework\TestCase { public function testGetSymbol() @@ -14,7 +14,8 @@ public function testGetSymbol() public function testNotValidSymbol() { - $this->setExpectedException('\Exception', 'Symbol is not valid'); + $this->expectException('\Exception'); + $this->expectExceptionMessage('Symbol is not valid'); $operator = new Operator('not_valid'); } diff --git a/tests/unit/src/Common/Selection/SortTest.php b/tests/unit/src/Common/Selection/SortTest.php index e5af75d..c9d7a74 100644 --- a/tests/unit/src/Common/Selection/SortTest.php +++ b/tests/unit/src/Common/Selection/SortTest.php @@ -2,7 +2,7 @@ use G4\DataMapper\Common\Selection\Sort; -class SortTest extends PHPUnit_Framework_TestCase +class SortTest extends \PHPUnit\Framework\TestCase { public function testGetSort() @@ -25,7 +25,8 @@ public function testGetSort() public function testOrderIsNotValid() { - $this->setExpectedException('\Exception', 'Sort order is not valid'); + $this->expectException('\Exception'); + $this->expectExceptionMessage('Sort order is not valid'); new Sort('name', 'not_valid_order'); } } \ No newline at end of file diff --git a/tests/unit/src/Common/SimpleRawDataTest.php b/tests/unit/src/Common/SimpleRawDataTest.php index 3e87f8e..aeba3e1 100644 --- a/tests/unit/src/Common/SimpleRawDataTest.php +++ b/tests/unit/src/Common/SimpleRawDataTest.php @@ -2,13 +2,13 @@ use G4\DataMapper\Common\SimpleRawData; -class SimpleRawDataTest extends PHPUnit_Framework_TestCase +class SimpleRawDataTest extends \PHPUnit\Framework\TestCase { private $data; private $rawData; - protected function setUp() + protected function setUp(): void { $this->data = [ [ @@ -20,7 +20,7 @@ protected function setUp() $this->rawData = new SimpleRawData($this->data); } - protected function tearDown() + protected function tearDown(): void { $this->data = null; $this->rawData = null; diff --git a/tests/unit/src/Common/SingleValueTest.php b/tests/unit/src/Common/SingleValueTest.php index e8cb881..6521401 100644 --- a/tests/unit/src/Common/SingleValueTest.php +++ b/tests/unit/src/Common/SingleValueTest.php @@ -2,7 +2,7 @@ use G4\DataMapper\Common\SingleValue; -class SingleValueTest extends PHPUnit_Framework_TestCase +class SingleValueTest extends \PHPUnit\Framework\TestCase { public function testToStringWithStringValue() { diff --git a/tests/unit/src/Engine/Elasticsearch/ElasticsearchAdapterTest.php b/tests/unit/src/Engine/Elasticsearch/ElasticsearchAdapterTest.php index a94d0cc..6c199cf 100644 --- a/tests/unit/src/Engine/Elasticsearch/ElasticsearchAdapterTest.php +++ b/tests/unit/src/Engine/Elasticsearch/ElasticsearchAdapterTest.php @@ -5,7 +5,7 @@ use G4\DataMapper\ErrorCodes as ErrorCode; use G4\DataMapper\Exception\NotImplementedException; -class ElasticsearchAdapterTest extends PHPUnit_Framework_TestCase +class ElasticsearchAdapterTest extends \PHPUnit\Framework\TestCase { const METHOD_POST = 'POST'; @@ -27,7 +27,7 @@ class ElasticsearchAdapterTest extends PHPUnit_Framework_TestCase */ private $collectionNameMock; - protected function setUp() + protected function setUp(): void { $this->clientMock = $this->getMockBuilder(\G4\DataMapper\Engine\Elasticsearch\ElasticsearchClient::class) ->disableOriginalConstructor() @@ -45,7 +45,7 @@ protected function setUp() $this->adapter = new ElasticsearchAdapter($this->getMockForElasticsearchClientFactory()); } - protected function tearDown() + protected function tearDown(): void { $this->adapter = null; $this->clientMock = null; diff --git a/tests/unit/src/Engine/Elasticsearch/ElasticsearchClientFactoryTest.php b/tests/unit/src/Engine/Elasticsearch/ElasticsearchClientFactoryTest.php index fe8ec80..9175857 100644 --- a/tests/unit/src/Engine/Elasticsearch/ElasticsearchClientFactoryTest.php +++ b/tests/unit/src/Engine/Elasticsearch/ElasticsearchClientFactoryTest.php @@ -6,7 +6,7 @@ use G4\DataMapper\ErrorCodes as ErrorCode; use G4\DataMapper\ErrorMessages as ErrorMessage; -class ElasticsearchClientFactoryTest extends PHPUnit_Framework_TestCase +class ElasticsearchClientFactoryTest extends \PHPUnit\Framework\TestCase { /** * @var array @@ -19,7 +19,7 @@ class ElasticsearchClientFactoryTest extends PHPUnit_Framework_TestCase private $clientFactory; - protected function setUp() + protected function setUp(): void { $this->params = [ 'host' => [null, '127.0.0.1', null, null], @@ -31,7 +31,7 @@ protected function setUp() } - protected function tearDown() + protected function tearDown(): void { $this->params = null; $this->clientFactory = null; diff --git a/tests/unit/src/Engine/Elasticsearch/ElasticsearchClientTest.php b/tests/unit/src/Engine/Elasticsearch/ElasticsearchClientTest.php index b8862d0..6adf54a 100644 --- a/tests/unit/src/Engine/Elasticsearch/ElasticsearchClientTest.php +++ b/tests/unit/src/Engine/Elasticsearch/ElasticsearchClientTest.php @@ -5,7 +5,7 @@ use G4\DataMapper\Exception\ClientException; use G4\ValueObject\Url; -class ElasticsearchClientTest extends PHPUnit_Framework_TestCase +class ElasticsearchClientTest extends \PHPUnit\Framework\TestCase { /** @@ -51,7 +51,7 @@ public function testCurlError() $elasticsearchClient->execute(); // todo - misleading because execute is only called internally } - protected function setUp() + protected function setUp(): void { $this->urlMock = $this->getMockBuilder(Url::class) ->disableOriginalConstructor() @@ -60,7 +60,7 @@ protected function setUp() $this->elasticsearchClient = new ElasticsearchClient($this->urlMock, null, 5); } - protected function tearDown() + protected function tearDown(): void { $this->urlMock = null; $this->elasticsearchClient = null; diff --git a/tests/unit/src/Engine/Elasticsearch/ElasticsearchCollectionNameTest.php b/tests/unit/src/Engine/Elasticsearch/ElasticsearchCollectionNameTest.php index 255966e..1432a4c 100644 --- a/tests/unit/src/Engine/Elasticsearch/ElasticsearchCollectionNameTest.php +++ b/tests/unit/src/Engine/Elasticsearch/ElasticsearchCollectionNameTest.php @@ -2,19 +2,19 @@ use G4\DataMapper\Engine\Elasticsearch\ElasticsearchCollectionName; -class ElasticsearchCollectionNameTest extends \PHPUnit_Framework_TestCase +class ElasticsearchCollectionNameTest extends \PHPUnit\Framework\TestCase { private $elasticsearchCollectionName; private $collectionName; - protected function setUp() + protected function setUp(): void { $this->collectionName = 'profiles'; $this->elasticsearchCollectionName = new ElasticsearchCollectionName($this->collectionName); } - protected function tearDown() + protected function tearDown(): void { $this->elasticsearchCollectionName = null; $this->collectionName = null; diff --git a/tests/unit/src/Engine/Elasticsearch/ElasticsearchComparisonFormatterTest.php b/tests/unit/src/Engine/Elasticsearch/ElasticsearchComparisonFormatterTest.php index 0bd5b7b..6062678 100644 --- a/tests/unit/src/Engine/Elasticsearch/ElasticsearchComparisonFormatterTest.php +++ b/tests/unit/src/Engine/Elasticsearch/ElasticsearchComparisonFormatterTest.php @@ -5,7 +5,7 @@ use G4\DataMapper\Common\SingleValue; use G4\DataMapper\Engine\Elasticsearch\ElasticsearchIdentity; -class ElasticsearchComparisonFormatterTest extends \PHPUnit_Framework_TestCase +class ElasticsearchComparisonFormatterTest extends \PHPUnit\Framework\TestCase { /** * @var ElasticsearchComparisonFormatter @@ -17,7 +17,7 @@ class ElasticsearchComparisonFormatterTest extends \PHPUnit_Framework_TestCase */ private $operatorMock; - protected function setUp() + protected function setUp(): void { $this->comparisonFormatter = new ElasticsearchComparisonFormatter(new ElasticsearchIdentity(2)); @@ -26,7 +26,7 @@ protected function setUp() ->getMock(); } - public function tearDown() + public function tearDown(): void { $this->comparisonFormatter = null; $this->operatorMock = null; diff --git a/tests/unit/src/Engine/Elasticsearch/ElasticsearchGeodistFormatterTest.php b/tests/unit/src/Engine/Elasticsearch/ElasticsearchGeodistFormatterTest.php index cf41cb6..cfbd848 100644 --- a/tests/unit/src/Engine/Elasticsearch/ElasticsearchGeodistFormatterTest.php +++ b/tests/unit/src/Engine/Elasticsearch/ElasticsearchGeodistFormatterTest.php @@ -3,14 +3,14 @@ use G4\DataMapper\Engine\Elasticsearch\ElasticsearchIdentity; use G4\DataMapper\Engine\Elasticsearch\ElasticsearchGeodistFormatter; -class ElasticsearchGeodistFormatterTest extends \PHPUnit_Framework_TestCase +class ElasticsearchGeodistFormatterTest extends \PHPUnit\Framework\TestCase { /** * @var ElasticsearchIdentity */ private $identity; - protected function setUp() + protected function setUp(): void { $this->identity = new ElasticsearchIdentity(); } diff --git a/tests/unit/src/Engine/Elasticsearch/ElasticsearchGeodistSortFormatterTest.php b/tests/unit/src/Engine/Elasticsearch/ElasticsearchGeodistSortFormatterTest.php index 5fa4fa3..5dabb4f 100644 --- a/tests/unit/src/Engine/Elasticsearch/ElasticsearchGeodistSortFormatterTest.php +++ b/tests/unit/src/Engine/Elasticsearch/ElasticsearchGeodistSortFormatterTest.php @@ -3,14 +3,14 @@ use G4\DataMapper\Engine\Elasticsearch\ElasticsearchIdentity; use G4\DataMapper\Engine\Elasticsearch\ElasticsearchGeodistSortFormatter; -class ElasticsearchGeodistSortFormatterTest extends \PHPUnit_Framework_TestCase +class ElasticsearchGeodistSortFormatterTest extends \PHPUnit\Framework\TestCase { /** * @var ElasticsearchIdentity */ private $identity; - protected function setUp() + protected function setUp(): void { $this->identity = new ElasticsearchIdentity(); } diff --git a/tests/unit/src/Engine/Elasticsearch/ElasticsearchIdentityTest.php b/tests/unit/src/Engine/Elasticsearch/ElasticsearchIdentityTest.php index 0e24cf7..ec54288 100644 --- a/tests/unit/src/Engine/Elasticsearch/ElasticsearchIdentityTest.php +++ b/tests/unit/src/Engine/Elasticsearch/ElasticsearchIdentityTest.php @@ -3,14 +3,14 @@ use G4\DataMapper\Common\QueryConnector; use G4\DataMapper\Engine\Elasticsearch\ElasticsearchIdentity; -class ElasticsearchIdentityTest extends PHPUnit_Framework_TestCase +class ElasticsearchIdentityTest extends \PHPUnit\Framework\TestCase { /** * @var ElasticsearchIdentity */ private $elasticsearchIdentity; - protected function setUp() + protected function setUp(): void { $this->elasticsearchIdentity = new ElasticsearchIdentity(); } @@ -91,7 +91,8 @@ public function testLikeCI() $identity = new ElasticsearchIdentity(); $this->assertInstanceOf(ElasticsearchIdentity::class, $identity->field('id')->likeCI('this')); - $this->setExpectedException('\Exception', 'Value can not be array'); + $this->expectException(\Exception::class); + $this->expectExceptionMessage('Value can not be array'); $identity->field('name')->likeCI([1]); } } diff --git a/tests/unit/src/Engine/Elasticsearch/ElasticsearchMapperTest.php b/tests/unit/src/Engine/Elasticsearch/ElasticsearchMapperTest.php index 2ce5a95..c866600 100644 --- a/tests/unit/src/Engine/Elasticsearch/ElasticsearchMapperTest.php +++ b/tests/unit/src/Engine/Elasticsearch/ElasticsearchMapperTest.php @@ -4,7 +4,7 @@ use G4\DataMapper\Exception\ElasticSearchMapperException; use G4\DataMapper\Exception\NotImplementedException; -class ElasticsearchMapperTest extends \PHPUnit_Framework_TestCase +class ElasticsearchMapperTest extends \PHPUnit\Framework\TestCase { const ELASTIC_SEARCH_DATA_MAPPER_ERROR_MESSAGE = 'Elastic Search Mapper error'; @@ -24,7 +24,7 @@ class ElasticsearchMapperTest extends \PHPUnit_Framework_TestCase private $mappingMock; - protected function setUp() + protected function setUp(): void { $this->adapterMock = $this->getMockBuilder(\G4\DataMapper\Common\AdapterInterface::class) ->disableOriginalConstructor() @@ -46,7 +46,7 @@ protected function setUp() $this->mapper = new ElasticsearchMapper($this->collectionNameMock, $this->adapterMock); } - protected function tearDown() + protected function tearDown(): void { $this->adapterMock = null; $this->mapper = null; @@ -56,7 +56,7 @@ protected function tearDown() public function testDelete() { - $identityStub = $this->getMock(\G4\DataMapper\Engine\Elasticsearch\ElasticsearchIdentity::class); + $identityStub = $this->createMock(\G4\DataMapper\Engine\Elasticsearch\ElasticsearchIdentity::class); $this->adapterMock ->expects($this->once()) @@ -67,12 +67,11 @@ public function testDelete() ); $this->mapper->delete($identityStub); - } public function testDeleteException() { - $identityStub = $this->getMock(\G4\DataMapper\Engine\Elasticsearch\ElasticsearchIdentity::class); + $identityStub = $this->createMock(\G4\DataMapper\Engine\Elasticsearch\ElasticsearchIdentity::class); $this->adapterMock ->expects($this->once()) @@ -126,7 +125,10 @@ public function testFind() ->method('select') ->willReturn($rawDataStub); - $this->assertSame($rawDataStub, $this->mapper->find($this->getMock(\G4\DataMapper\Engine\Elasticsearch\ElasticsearchIdentity::class))); + $this->assertSame( + $rawDataStub, + $this->mapper->find($this->createMock(\G4\DataMapper\Engine\Elasticsearch\ElasticsearchIdentity::class)) + ); } public function testFindException() @@ -134,11 +136,13 @@ public function testFindException() $this->adapterMock ->expects($this->once()) ->method('select') - ->will($this->throwException(new ElasticSearchMapperException(self::ELASTIC_SEARCH_DATA_MAPPER_ERROR_MESSAGE))); + ->will( + $this->throwException(new ElasticSearchMapperException(self::ELASTIC_SEARCH_DATA_MAPPER_ERROR_MESSAGE)) + ); $this->expectException(ElasticSearchMapperException::class); - $this->mapper->find($this->getMock(\G4\DataMapper\Engine\Elasticsearch\ElasticsearchIdentity::class)); + $this->mapper->find($this->createMock(\G4\DataMapper\Engine\Elasticsearch\ElasticsearchIdentity::class)); } public function testInsert() @@ -171,7 +175,10 @@ public function testUpdate() ->method('update') ->with($this->equalTo($this->collectionNameMock), $this->equalTo($this->mappingMock)); - $this->mapper->update($this->mappingMock, $this->getMock(\G4\DataMapper\Engine\Elasticsearch\ElasticsearchIdentity::class)); + $this->mapper->update( + $this->mappingMock, + $this->createMock(\G4\DataMapper\Engine\Elasticsearch\ElasticsearchIdentity::class) + ); } public function testUpdateException() @@ -180,11 +187,13 @@ public function testUpdateException() ->expects($this->once()) ->method('update') ->with($this->equalTo($this->collectionNameMock), $this->equalTo($this->mappingMock)) - ->will($this->throwException(new ElasticSearchMapperException(self::ELASTIC_SEARCH_DATA_MAPPER_ERROR_MESSAGE))); + ->will( + $this->throwException(new ElasticSearchMapperException(self::ELASTIC_SEARCH_DATA_MAPPER_ERROR_MESSAGE)) + ); $this->expectException(ElasticSearchMapperException::class); - $this->mapper->update($this->mappingMock, $this->getMock(\G4\DataMapper\Engine\Elasticsearch\ElasticsearchIdentity::class)); + $this->mapper->update($this->mappingMock, $this->createMock(\G4\DataMapper\Engine\Elasticsearch\ElasticsearchIdentity::class)); } private function getIdentifiableMock() diff --git a/tests/unit/src/Engine/Elasticsearch/ElasticsearchResponseTest.php b/tests/unit/src/Engine/Elasticsearch/ElasticsearchResponseTest.php index 39bd4b2..1c00f02 100644 --- a/tests/unit/src/Engine/Elasticsearch/ElasticsearchResponseTest.php +++ b/tests/unit/src/Engine/Elasticsearch/ElasticsearchResponseTest.php @@ -4,7 +4,7 @@ use G4\DataMapper\Engine\Elasticsearch\ElasticsearchResponse; -class ElasticsearchResponseTest extends PHPUnit_Framework_TestCase +class ElasticsearchResponseTest extends \PHPUnit\Framework\TestCase { /** @@ -76,7 +76,7 @@ public function testGarbageResponse() $this->assertEquals(0, $elasticsearchResponse->getTotal()); } - protected function setUp() + protected function setUp(): void { $this->dataWithHits = '{"took":16,"timed_out":false,"_shards":{"total":1,"successful":1,"failed":0},"hits":{"total":1,"max_score":null,"hits":[1]}}'; $this->dataWithError = '{"error":{"root_cause":[{"type":"query_parsing_exception","reason":"field [location] is not a geo_point field","index":"profiles","line":1,"col":270}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query_fetch","grouped":true,"failed_shards":[{"shard":0,"index":"profiles","node":"75N9T595S-eqHYV8_o08ng","reason":{"type":"query_parsing_exception","reason":"field [location] is not a geo_point field","index":"profiles","line":1,"col":270}}]},"status":400}'; @@ -84,7 +84,7 @@ protected function setUp() $this->errorMessage = '["search_phase_execution_exception",[{"type":"query_parsing_exception","reason":"field [location] is not a geo_point field","index":"profiles","line":1,"col":270}]]'; } - protected function tearDown() + protected function tearDown(): void { $this->dataWithHits = null; $this->dataWithError = null; diff --git a/tests/unit/src/Engine/Elasticsearch/ElasticsearchSelectionFactoryTest.php b/tests/unit/src/Engine/Elasticsearch/ElasticsearchSelectionFactoryTest.php index ef20750..d749657 100644 --- a/tests/unit/src/Engine/Elasticsearch/ElasticsearchSelectionFactoryTest.php +++ b/tests/unit/src/Engine/Elasticsearch/ElasticsearchSelectionFactoryTest.php @@ -3,7 +3,7 @@ use G4\DataMapper\Engine\Elasticsearch\ElasticsearchSelectionFactory; use G4\DataMapper\Common\SingleValue; -class ElasticsearchSelectionFactoryTest extends \PHPUnit_Framework_TestCase +class ElasticsearchSelectionFactoryTest extends \PHPUnit\Framework\TestCase { /** * @var ElasticsearchSelectionFactory @@ -12,7 +12,7 @@ class ElasticsearchSelectionFactoryTest extends \PHPUnit_Framework_TestCase private $identityMock; - protected function setUp() + protected function setUp(): void { $this->identityMock = $this->getMockBuilder(\G4\DataMapper\Engine\Elasticsearch\ElasticsearchIdentity::class) ->disableOriginalConstructor() @@ -21,7 +21,7 @@ protected function setUp() $this->selectionFactory = new ElasticsearchSelectionFactory($this->identityMock); } - protected function tearDown() + protected function tearDown(): void { $this->identityMock = null; diff --git a/tests/unit/src/Engine/Elasticsearch/ElasticsearchSortingFormatterTest.php b/tests/unit/src/Engine/Elasticsearch/ElasticsearchSortingFormatterTest.php index a4715c9..7ac3b83 100644 --- a/tests/unit/src/Engine/Elasticsearch/ElasticsearchSortingFormatterTest.php +++ b/tests/unit/src/Engine/Elasticsearch/ElasticsearchSortingFormatterTest.php @@ -6,19 +6,19 @@ use G4\DataMapper\ErrorCodes as ErrorCode; use G4\DataMapper\ErrorMessages as ErrorMessage; -class ElasticsearchSortingFormatterTest extends \PHPUnit_Framework_TestCase +class ElasticsearchSortingFormatterTest extends \PHPUnit\Framework\TestCase { /** * @var ElasticsearchSortingFormatter */ private $sortingFormatter; - protected function setUp() + protected function setUp(): void { $this->sortingFormatter = new ElasticsearchSortingFormatter(); } - protected function tearDown() + protected function tearDown(): void { $this->sortingFormatter = null; } diff --git a/tests/unit/src/Engine/Elasticsearch/ElasticsearchUrlPathBuilderTest.php b/tests/unit/src/Engine/Elasticsearch/ElasticsearchUrlPathBuilderTest.php index 02a4319..2e5f3cd 100644 --- a/tests/unit/src/Engine/Elasticsearch/ElasticsearchUrlPathBuilderTest.php +++ b/tests/unit/src/Engine/Elasticsearch/ElasticsearchUrlPathBuilderTest.php @@ -6,7 +6,7 @@ use G4\ValueObject\Url; use PHPUnit_Framework_TestCase; -class ElasticsearchUrlPathBuilderTest extends PHPUnit_Framework_TestCase +class ElasticsearchUrlPathBuilderTest extends \PHPUnit\Framework\TestCase { public function testUpdateVersion8() { diff --git a/tests/unit/src/Engine/Elasticsearch/ElasticsearchVersionFactoryTest.php b/tests/unit/src/Engine/Elasticsearch/ElasticsearchVersionFactoryTest.php index 7d54562..4f4af7a 100644 --- a/tests/unit/src/Engine/Elasticsearch/ElasticsearchVersionFactoryTest.php +++ b/tests/unit/src/Engine/Elasticsearch/ElasticsearchVersionFactoryTest.php @@ -5,7 +5,7 @@ use G4\DataMapper\Engine\Elasticsearch\ElasticsearchVersionFactory; use PHPUnit_Framework_TestCase; -class ElasticsearchVersionFactoryTest extends PHPUnit_Framework_TestCase +class ElasticsearchVersionFactoryTest extends \PHPUnit\Framework\TestCase { public function testElasticsearchClientUrlPath() { diff --git a/tests/unit/src/Engine/Http/HttpComparisonFormatterTest.php b/tests/unit/src/Engine/Http/HttpComparisonFormatterTest.php index 7ab9062..d3f7586 100644 --- a/tests/unit/src/Engine/Http/HttpComparisonFormatterTest.php +++ b/tests/unit/src/Engine/Http/HttpComparisonFormatterTest.php @@ -5,7 +5,7 @@ use G4\DataMapper\Common\Selection\Operator; use G4\DataMapper\Common\SingleValue; -class HttpComparisonFormatterTest extends PHPUnit_Framework_TestCase +class HttpComparisonFormatterTest extends \PHPUnit\Framework\TestCase { diff --git a/tests/unit/src/Engine/Http/HttpPathTest.php b/tests/unit/src/Engine/Http/HttpPathTest.php index a0216d3..21d3940 100644 --- a/tests/unit/src/Engine/Http/HttpPathTest.php +++ b/tests/unit/src/Engine/Http/HttpPathTest.php @@ -3,7 +3,7 @@ use G4\DataMapper\Engine\Http\HttpPath; use G4\DataMapper\Exception\HttpPathException; -class HttpPathTest extends PHPUnit_Framework_TestCase +class HttpPathTest extends \PHPUnit\Framework\TestCase { public function testValidValueWithOnePart() diff --git a/tests/unit/src/Engine/Http/HttpSelectionFactoryTest.php b/tests/unit/src/Engine/Http/HttpSelectionFactoryTest.php index df10bbc..f5a7901 100644 --- a/tests/unit/src/Engine/Http/HttpSelectionFactoryTest.php +++ b/tests/unit/src/Engine/Http/HttpSelectionFactoryTest.php @@ -6,7 +6,7 @@ use G4\DataMapper\Engine\Http\HttpComparisonFormatter; use G4\DataMapper\Common\Selection\Comparison; -class HttpSelectionFactoryTest extends PHPUnit_Framework_TestCase +class HttpSelectionFactoryTest extends \PHPUnit\Framework\TestCase { /** @@ -81,7 +81,7 @@ public function testMakeComparisonFormatter() $this->assertInstanceOf(HttpComparisonFormatter::class, $this->selectionFactory->makeComparisonFormatter()); } - protected function setUp() + protected function setUp(): void { $this->identityMock = $this->getMockBuilder(Identity::class) ->disableOriginalConstructor() @@ -90,7 +90,7 @@ protected function setUp() $this->selectionFactory = new HttpSelectionFactory($this->identityMock); } - protected function tearDown() + protected function tearDown(): void { $this->identityMock = null; $this->selectionFactory = null; diff --git a/tests/unit/src/Engine/MySQL/MySQLAdapterTest.php b/tests/unit/src/Engine/MySQL/MySQLAdapterTest.php index cf8d5d5..102507a 100644 --- a/tests/unit/src/Engine/MySQL/MySQLAdapterTest.php +++ b/tests/unit/src/Engine/MySQL/MySQLAdapterTest.php @@ -3,7 +3,7 @@ use G4\DataMapper\Engine\MySQL\MySQLAdapter; use G4\DataMapper\Common\SingleValue; -class MySQLAdapterTest extends PHPUnit_Framework_TestCase +class MySQLAdapterTest extends \PHPUnit\Framework\TestCase { /** @@ -19,7 +19,7 @@ class MySQLAdapterTest extends PHPUnit_Framework_TestCase private $tableNameMock; - protected function setUp() + protected function setUp(): void { $this->clientMock = $this->getMockBuilder(\Zend_Db_Adapter_Mysqli::class) ->disableOriginalConstructor() @@ -49,7 +49,7 @@ protected function setUp() $this->adapter = new MySQLAdapter($this->getMockForMySQLClientFactory()); } - protected function tearDown() + protected function tearDown(): void { $this->adapter = null; $this->clientMock = null; @@ -137,7 +137,7 @@ public function testEmptyDataForUpdate() ->method('map') ->willReturn([]); - $selectionFactoryStub = $this->getMock(G4\DataMapper\Common\SelectionFactoryInterface::class); + $selectionFactoryStub = $this->createMock(G4\DataMapper\Common\SelectionFactoryInterface::class); $this->expectException(\Exception::class); $this->expectExceptionMessage('Empty data for update'); diff --git a/tests/unit/src/Engine/MySQL/MySQLClientFactoryTest.php b/tests/unit/src/Engine/MySQL/MySQLClientFactoryTest.php index 8d5555a..d802c5e 100644 --- a/tests/unit/src/Engine/MySQL/MySQLClientFactoryTest.php +++ b/tests/unit/src/Engine/MySQL/MySQLClientFactoryTest.php @@ -2,7 +2,7 @@ use G4\DataMapper\Engine\MySQL\MySQLClientFactory; -class MySQLClientFactoryTest extends PHPUnit_Framework_TestCase +class MySQLClientFactoryTest extends \PHPUnit\Framework\TestCase { /** @@ -16,7 +16,7 @@ class MySQLClientFactoryTest extends PHPUnit_Framework_TestCase private $clientFactory; - protected function setUp() + protected function setUp(): void { $this->params = [ 'host' => '127.0.0.1', @@ -30,7 +30,7 @@ protected function setUp() } - protected function tearDown() + protected function tearDown(): void { $this->params = null; $this->clientFactory = null; diff --git a/tests/unit/src/Engine/MySQL/MySQLComparisonFormatterTest.php b/tests/unit/src/Engine/MySQL/MySQLComparisonFormatterTest.php index 5122b6a..21be1a6 100644 --- a/tests/unit/src/Engine/MySQL/MySQLComparisonFormatterTest.php +++ b/tests/unit/src/Engine/MySQL/MySQLComparisonFormatterTest.php @@ -5,7 +5,7 @@ use G4\DataMapper\Common\SingleValue; use G4\DataMapper\Common\RangeValue; -class MySQLComparisonFormatterTest extends PHPUnit_Framework_TestCase +class MySQLComparisonFormatterTest extends \PHPUnit\Framework\TestCase { private $comparisonFormatter; @@ -13,7 +13,7 @@ class MySQLComparisonFormatterTest extends PHPUnit_Framework_TestCase private $operatorMock; - protected function setUp() + protected function setUp(): void { $this->comparisonFormatter = new MySQLComparisonFormatter(); @@ -22,7 +22,7 @@ protected function setUp() ->getMock(); } - protected function tearDown() + protected function tearDown(): void { $this->comparisonFormatter = null; $this->operatorMock = null; diff --git a/tests/unit/src/Engine/MySQL/MySQLMapperTest.php b/tests/unit/src/Engine/MySQL/MySQLMapperTest.php index f1bebb3..465d739 100644 --- a/tests/unit/src/Engine/MySQL/MySQLMapperTest.php +++ b/tests/unit/src/Engine/MySQL/MySQLMapperTest.php @@ -3,7 +3,7 @@ use G4\DataMapper\Engine\MySQL\MySQLMapper; use G4\DataMapper\Exception\MySQLMapperException; -class MySQLMapperTest extends PHPUnit_Framework_TestCase +class MySQLMapperTest extends \PHPUnit\Framework\TestCase { const MYSQL_DATA_MAPPER_ERROR_MESSAGE = 'MySQL Mapper error'; @@ -23,7 +23,7 @@ class MySQLMapperTest extends PHPUnit_Framework_TestCase private $tableNameMock; - protected function setUp() + protected function setUp(): void { $this->adapterMock = $this->getMockBuilder(\G4\DataMapper\Engine\MySQL\MySQLAdapter::class) ->disableOriginalConstructor() @@ -40,7 +40,7 @@ protected function setUp() $this->mapper = new MySQLMapper($this->adapterMock, $this->tableNameMock); } - protected function tearDown() + protected function tearDown(): void { $this->adapterMock = null; $this->mappingMock = null; @@ -50,7 +50,7 @@ protected function tearDown() public function testDelete() { - $identityStub = $this->getMock(\G4\DataMapper\Common\IdentityInterface::class); + $identityStub = $this->createMock(\G4\DataMapper\Common\IdentityInterface::class); $this->adapterMock ->expects($this->once()) @@ -61,7 +61,7 @@ public function testDelete() public function testDeleteException() { - $identityStub = $this->getMock(\G4\DataMapper\Common\IdentityInterface::class); + $identityStub = $this->createMock(\G4\DataMapper\Common\IdentityInterface::class); $this->adapterMock ->expects($this->once()) @@ -84,7 +84,7 @@ public function testFind() ->method('select') ->willReturn($rawDataStub); - $this->assertSame($rawDataStub, $this->mapper->find($this->getMock(\G4\DataMapper\Common\Identity::class))); + $this->assertSame($rawDataStub, $this->mapper->find($this->createMock(\G4\DataMapper\Common\Identity::class))); } public function testFindException() @@ -96,7 +96,7 @@ public function testFindException() $this->expectException(\G4\DataMapper\Exception\MySQLMapperException::class); - $this->mapper->find($this->getMock(\G4\DataMapper\Common\Identity::class)); + $this->mapper->find($this->createMock(\G4\DataMapper\Common\Identity::class)); } public function testInsert() @@ -129,7 +129,7 @@ public function testUpdate() ->method('update') ->with($this->equalTo($this->tableNameMock), $this->equalTo($this->mappingMock)); - $this->mapper->update($this->mappingMock, $this->getMock(\G4\DataMapper\Common\Identity::class)); + $this->mapper->update($this->mappingMock, $this->createMock(\G4\DataMapper\Common\Identity::class)); } public function testUpsert() @@ -164,7 +164,7 @@ public function testExceptionUpdate() $this->expectException(\G4\DataMapper\Exception\MySQLMapperException::class); - $this->mapper->update($this->mappingMock, $this->getMock(\G4\DataMapper\Common\Identity::class)); + $this->mapper->update($this->mappingMock, $this->createMock(\G4\DataMapper\Common\Identity::class)); } public function testQuery() diff --git a/tests/unit/src/Engine/MySQL/MySQLSelectionFactoryTest.php b/tests/unit/src/Engine/MySQL/MySQLSelectionFactoryTest.php index 704da86..258193e 100644 --- a/tests/unit/src/Engine/MySQL/MySQLSelectionFactoryTest.php +++ b/tests/unit/src/Engine/MySQL/MySQLSelectionFactoryTest.php @@ -4,7 +4,7 @@ use G4\DataMapper\Common\Identity; use G4\DataMapper\Common\Selection\Comparison; -class MySQLSelectionFactoryTest extends PHPUnit_Framework_TestCase +class MySQLSelectionFactoryTest extends \PHPUnit\Framework\TestCase { /** @@ -15,7 +15,7 @@ class MySQLSelectionFactoryTest extends PHPUnit_Framework_TestCase private $identityMock; - protected function setUp() + protected function setUp(): void { $this->identityMock = $this->getMockBuilder(\G4\DataMapper\Common\Identity::class) ->disableOriginalConstructor() @@ -24,7 +24,7 @@ protected function setUp() $this->selectionFactory = new MySQLSelectionFactory($this->identityMock); } - protected function tearDown() + protected function tearDown(): void { $this->identityMock = null; $this->selectionFactory = null; diff --git a/tests/unit/src/Engine/MySQL/MySQLSortingFormatterTest.php b/tests/unit/src/Engine/MySQL/MySQLSortingFormatterTest.php index c57e8fd..b631a8c 100644 --- a/tests/unit/src/Engine/MySQL/MySQLSortingFormatterTest.php +++ b/tests/unit/src/Engine/MySQL/MySQLSortingFormatterTest.php @@ -4,7 +4,7 @@ use G4\DataMapper\Common\Selection\Sort; -class MySQLSortingFormatterTest extends PHPUnit_Framework_TestCase +class MySQLSortingFormatterTest extends \PHPUnit\Framework\TestCase { /** * @var MySQLSortingFormatter @@ -12,12 +12,12 @@ class MySQLSortingFormatterTest extends PHPUnit_Framework_TestCase private $sortingFormatter; - protected function setUp() + protected function setUp(): void { $this->sortingFormatter = new MySQLSortingFormatter(); } - protected function tearDown() + protected function tearDown(): void { $this->sortingFormatter = null; } diff --git a/tests/unit/src/Engine/MySQL/MySQLTableNameTest.php b/tests/unit/src/Engine/MySQL/MySQLTableNameTest.php index 39c8170..c3091e0 100644 --- a/tests/unit/src/Engine/MySQL/MySQLTableNameTest.php +++ b/tests/unit/src/Engine/MySQL/MySQLTableNameTest.php @@ -2,20 +2,20 @@ use G4\DataMapper\Engine\MySQL\MySQLTableName; -class MySQLTableNameTest extends PHPUnit_Framework_TestCase +class MySQLTableNameTest extends \PHPUnit\Framework\TestCase { private $mySQLTableName; private $tableName; - protected function setUp() + protected function setUp(): void { $this->tableName = 'tralala'; $this->mySQLTableName = new MySQLTableName($this->tableName); } - protected function tearDown() + protected function tearDown(): void { $this->mySQLTableName = null; $this->tableName = null; diff --git a/tests/unit/src/Engine/MySQL/MySQLTransactionTest.php b/tests/unit/src/Engine/MySQL/MySQLTransactionTest.php index a022b88..1046a17 100644 --- a/tests/unit/src/Engine/MySQL/MySQLTransactionTest.php +++ b/tests/unit/src/Engine/MySQL/MySQLTransactionTest.php @@ -2,7 +2,7 @@ use G4\DataMapper\Engine\MySQL\MySQLTransaction; -class MySQLTransactionTest extends PHPUnit_Framework_TestCase +class MySQLTransactionTest extends \PHPUnit\Framework\TestCase { /** @@ -15,7 +15,7 @@ class MySQLTransactionTest extends PHPUnit_Framework_TestCase */ private $transaction; - protected function setUp() + protected function setUp(): void { $this->adapterMock = $this->getMockBuilder(\G4\DataMapper\Engine\MySQL\MySQLAdapter::class) ->disableOriginalConstructor() @@ -24,7 +24,7 @@ protected function setUp() $this->transaction = new MySQLTransaction($this->adapterMock); } - protected function tearDown() + protected function tearDown(): void { $this->adapterMock = null; diff --git a/tests/unit/src/Engine/MySQL/QuoteTest.php b/tests/unit/src/Engine/MySQL/QuoteTest.php index 7ee8c41..ec74aba 100644 --- a/tests/unit/src/Engine/MySQL/QuoteTest.php +++ b/tests/unit/src/Engine/MySQL/QuoteTest.php @@ -3,7 +3,7 @@ use G4\DataMapper\Engine\MySQL\Quote; use G4\DataMapper\Common\SingleValue; -class QuoteTest extends PHPUnit_Framework_TestCase +class QuoteTest extends \PHPUnit\Framework\TestCase { public function testInt() @@ -18,7 +18,7 @@ public function testFloat() { $quote = new Quote(new SingleValue(1.01)); $value = (string) $quote; - $this->assertEquals('1.01', $value); + $this->assertEquals('1.010000', $value); $this->assertTrue(is_string($value)); } diff --git a/tests/unit/src/Engine/Solr/SolrAdapterTest.php b/tests/unit/src/Engine/Solr/SolrAdapterTest.php index 8589877..ad24da9 100644 --- a/tests/unit/src/Engine/Solr/SolrAdapterTest.php +++ b/tests/unit/src/Engine/Solr/SolrAdapterTest.php @@ -5,7 +5,7 @@ use G4\DataMapper\ErrorCodes as ErrorCode; use G4\DataMapper\Exception\NotImplementedException; -class SolrAdapterTest extends PHPUnit_Framework_TestCase +class SolrAdapterTest extends \PHPUnit\Framework\TestCase { /** @@ -20,7 +20,7 @@ class SolrAdapterTest extends PHPUnit_Framework_TestCase private $collectionNameMock; - protected function setUp() + protected function setUp(): void { $this->clientMock = $this->getMockBuilder(\G4\DataMapper\Engine\Solr\SolrClient::class) ->disableOriginalConstructor() @@ -39,7 +39,7 @@ protected function setUp() $this->adapter = new SolrAdapter($this->getMockForSolrClientFactory()); } - protected function tearDown() + protected function tearDown(): void { $this->adapter = null; $this->clientMock = null; diff --git a/tests/unit/src/Engine/Solr/SolrClientFactoryTest.php b/tests/unit/src/Engine/Solr/SolrClientFactoryTest.php index dd58ecd..7aaf5e2 100644 --- a/tests/unit/src/Engine/Solr/SolrClientFactoryTest.php +++ b/tests/unit/src/Engine/Solr/SolrClientFactoryTest.php @@ -6,7 +6,7 @@ use G4\DataMapper\ErrorCodes as ErrorCode; use G4\DataMapper\ErrorMessages as ErrorMessage; -class SolrClientFactoryTest extends PHPUnit_Framework_TestCase +class SolrClientFactoryTest extends \PHPUnit\Framework\TestCase { /** * @var array @@ -19,7 +19,7 @@ class SolrClientFactoryTest extends PHPUnit_Framework_TestCase private $clientFactory; - protected function setUp() + protected function setUp(): void { $this->params = [ 'host' => '127.0.0.1', @@ -30,7 +30,7 @@ protected function setUp() } - protected function tearDown() + protected function tearDown(): void { $this->params = null; $this->clientFactory = null; diff --git a/tests/unit/src/Engine/Solr/SolrCollectionNameTest.php b/tests/unit/src/Engine/Solr/SolrCollectionNameTest.php index ea750e9..e965dae 100644 --- a/tests/unit/src/Engine/Solr/SolrCollectionNameTest.php +++ b/tests/unit/src/Engine/Solr/SolrCollectionNameTest.php @@ -2,20 +2,20 @@ use G4\DataMapper\Engine\Solr\SolrCollectionName; -class SolrCollectionNameTest extends PHPUnit_Framework_TestCase +class SolrCollectionNameTest extends \PHPUnit\Framework\TestCase { private $solrCollectionName; private $collectionName; - protected function setUp() + protected function setUp(): void { $this->collectionName = 'profiles'; $this->solrCollectionName = new SolrCollectionName($this->collectionName); } - protected function tearDown() + protected function tearDown(): void { $this->solrCollectionName = null; $this->collectionName = null; diff --git a/tests/unit/src/Engine/Solr/SolrComparisonFormatterTest.php b/tests/unit/src/Engine/Solr/SolrComparisonFormatterTest.php index 50e2a51..b0e5af6 100644 --- a/tests/unit/src/Engine/Solr/SolrComparisonFormatterTest.php +++ b/tests/unit/src/Engine/Solr/SolrComparisonFormatterTest.php @@ -5,14 +5,14 @@ use G4\DataMapper\Common\SingleValue; use G4\DataMapper\Common\RangeValue; -class SolrComparisonFormatterTest extends PHPUnit_Framework_TestCase +class SolrComparisonFormatterTest extends \PHPUnit\Framework\TestCase { private $comparisonFormatter; private $operatorMock; - protected function setUp() + protected function setUp(): void { $this->comparisonFormatter = new SolrComparisonFormatter(); @@ -21,7 +21,7 @@ protected function setUp() ->getMock(); } - public function tearDown() + public function tearDown(): void { $this->comparisonFormatter = null; $this->operatorMock = null; diff --git a/tests/unit/src/Engine/Solr/SolrIdentityTest.php b/tests/unit/src/Engine/Solr/SolrIdentityTest.php index d26d5c3..03baa46 100644 --- a/tests/unit/src/Engine/Solr/SolrIdentityTest.php +++ b/tests/unit/src/Engine/Solr/SolrIdentityTest.php @@ -2,19 +2,19 @@ use G4\DataMapper\Engine\Solr\SolrIdentity; -class SolrIdentityTest extends PHPUnit_Framework_TestCase +class SolrIdentityTest extends \PHPUnit\Framework\TestCase { /** * @var SolrIdentity */ private $solrIdentity; - protected function setUp() + protected function setUp(): void { $this->solrIdentity = new SolrIdentity(); } - protected function tearDown() + protected function tearDown(): void { $this->solrIdentity = null; } diff --git a/tests/unit/src/Engine/Solr/SolrMapperTest.php b/tests/unit/src/Engine/Solr/SolrMapperTest.php index 3ca7950..5f360af 100644 --- a/tests/unit/src/Engine/Solr/SolrMapperTest.php +++ b/tests/unit/src/Engine/Solr/SolrMapperTest.php @@ -4,7 +4,7 @@ use G4\DataMapper\Exception\NotImplementedException; use G4\DataMapper\Exception\SolrMapperException; -class SolrMapperTest extends PHPUnit_Framework_TestCase +class SolrMapperTest extends \PHPUnit\Framework\TestCase { const SOLR_DATA_MAPPER_ERROR_MESSAGE = 'Solr Mapper error'; @@ -28,7 +28,7 @@ class SolrMapperTest extends PHPUnit_Framework_TestCase */ private $mappingMock; - protected function setUp() + protected function setUp(): void { $this->adapterMock = $this->getMockBuilder(\G4\DataMapper\Engine\Solr\SolrAdapter::class) ->disableOriginalConstructor() @@ -45,7 +45,7 @@ protected function setUp() $this->mapper = new SolrMapper($this->collectionNameMock, $this->adapterMock); } - protected function tearDown() + protected function tearDown(): void { $this->adapterMock = null; $this->mapper = null; @@ -55,7 +55,7 @@ protected function tearDown() public function testDelete() { - $identityStub = $this->getMock(\G4\DataMapper\Engine\Solr\SolrIdentity::class); + $identityStub = $this->createMock(\G4\DataMapper\Engine\Solr\SolrIdentity::class); $this->adapterMock ->expects($this->once()) @@ -66,7 +66,7 @@ public function testDelete() public function testDeleteException() { - $identityStub = $this->getMock(\G4\DataMapper\Engine\Solr\SolrIdentity::class); + $identityStub = $this->createMock(\G4\DataMapper\Engine\Solr\SolrIdentity::class); $this->adapterMock ->expects($this->once()) @@ -89,7 +89,10 @@ public function testFind() ->method('select') ->willReturn($rawDataStub); - $this->assertSame($rawDataStub, $this->mapper->find($this->getMock(\G4\DataMapper\Engine\Solr\SolrIdentity::class))); + $this->assertSame( + $rawDataStub, + $this->mapper->find($this->createMock(\G4\DataMapper\Engine\Solr\SolrIdentity::class)) + ); } public function testFindException() @@ -101,7 +104,7 @@ public function testFindException() $this->expectException(SolrMapperException::class); - $this->mapper->find($this->getMock(\G4\DataMapper\Engine\Solr\SolrIdentity::class)); + $this->mapper->find($this->createMock(\G4\DataMapper\Engine\Solr\SolrIdentity::class)); } public function testInsert() @@ -134,7 +137,7 @@ public function testUpdate() ->method('update') ->with($this->equalTo($this->collectionNameMock), $this->equalTo($this->mappingMock)); - $this->mapper->update($this->mappingMock, $this->getMock(\G4\DataMapper\Engine\Solr\SolrIdentity::class)); + $this->mapper->update($this->mappingMock, $this->createMock(\G4\DataMapper\Engine\Solr\SolrIdentity::class)); } public function testUpdateException() @@ -147,7 +150,7 @@ public function testUpdateException() $this->expectException(SolrMapperException::class); - $this->mapper->update($this->mappingMock, $this->getMock(\G4\DataMapper\Engine\Solr\SolrIdentity::class)); + $this->mapper->update($this->mappingMock, $this->createMock(\G4\DataMapper\Engine\Solr\SolrIdentity::class)); } public function testUpdateBulk() @@ -187,7 +190,6 @@ public function testUpdateBulkWithException() $this->expectException(SolrMapperException::class); $this->mapper->updateBulk(); - } public function testUpsert() diff --git a/tests/unit/src/Engine/Solr/SolrSelectionFactoryTest.php b/tests/unit/src/Engine/Solr/SolrSelectionFactoryTest.php index ef06f87..0412133 100644 --- a/tests/unit/src/Engine/Solr/SolrSelectionFactoryTest.php +++ b/tests/unit/src/Engine/Solr/SolrSelectionFactoryTest.php @@ -6,7 +6,7 @@ use G4\DataMapper\Common\SingleValue; use G4\DataMapper\Common\RangeValue; -class SolrSelectionFactoryTest extends PHPUnit_Framework_TestCase +class SolrSelectionFactoryTest extends \PHPUnit\Framework\TestCase { /** * @var SolrSelectionFactory @@ -15,7 +15,7 @@ class SolrSelectionFactoryTest extends PHPUnit_Framework_TestCase private $identityMock; - protected function setUp() + protected function setUp(): void { $this->identityMock = $this->getMockBuilder(\G4\DataMapper\Engine\Solr\SolrIdentity::class) ->disableOriginalConstructor() @@ -24,7 +24,7 @@ protected function setUp() $this->selectionFactory = new SolrSelectionFactory($this->identityMock); } - protected function tearDown() + protected function tearDown(): void { $this->identityMock = null; diff --git a/tests/unit/src/Engine/Solr/SolrSortingFormatterTest.php b/tests/unit/src/Engine/Solr/SolrSortingFormatterTest.php index a7d85bb..4e380a0 100644 --- a/tests/unit/src/Engine/Solr/SolrSortingFormatterTest.php +++ b/tests/unit/src/Engine/Solr/SolrSortingFormatterTest.php @@ -6,19 +6,19 @@ use G4\DataMapper\ErrorCodes as ErrorCode; use G4\DataMapper\ErrorMessages as ErrorMessage; -class SolrSortingFormatterTest extends PHPUnit_Framework_TestCase +class SolrSortingFormatterTest extends \PHPUnit\Framework\TestCase { /** * @var SolrSortingFormatter */ private $sortingFormatter; - protected function setUp() + protected function setUp(): void { $this->sortingFormatter = new SolrSortingFormatter(); } - protected function tearDown() + protected function tearDown(): void { $this->sortingFormatter = null; }