Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ vendor

tests/unit/coverage/*
tests/integration/coverage/*
tests/unit/.phpunit.result.cache
.vagrant/
.bash_history
.cache/motd.legal-displayed
Expand Down
17 changes: 10 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/Engine/Elasticsearch/ElasticsearchClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/Engine/Elasticsearch/Operators/ConsistentRandomKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ public function format()
]
];
}
}
}
2 changes: 1 addition & 1 deletion src/Engine/Elasticsearch/Operators/ExistsOperator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]];
}
}
4 changes: 3 additions & 1 deletion src/Engine/Elasticsearch/Operators/LikeCIOperator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
]
];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ public function format()
]
];
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
]
];
}
Expand Down
2 changes: 1 addition & 1 deletion src/Engine/Http/HttpPath.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
26 changes: 12 additions & 14 deletions tests/unit/src/BuilderTest.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?php

use G4\DataMapper\Builder;
use G4\DataMapper\Engine\MySQL\MySQLMapper;
use G4\DataMapper\Engine\MySQL\MySQLTableName;

class BuilderTest extends PHPUnit_Framework_TestCase
class BuilderTest extends \PHPUnit\Framework\TestCase
{

/**
Expand All @@ -16,8 +17,7 @@ class BuilderTest extends PHPUnit_Framework_TestCase
*/
private $params;


protected function setUp()
protected function setUp(): void
{
$this->params = [
'host' => 'localhost',
Expand All @@ -29,7 +29,7 @@ protected function setUp()
$this->builder = Builder::create();
}

protected function tearDown()
protected function tearDown(): void
{
$this->params = null;
$this->builder = null;
Expand All @@ -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()
Expand All @@ -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');
Expand All @@ -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);
Expand All @@ -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();
}
}
6 changes: 3 additions & 3 deletions tests/unit/src/Common/BulkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use G4\DataMapper\Common\Bulk;

class BulkTest extends PHPUnit_Framework_TestCase
class BulkTest extends \PHPUnit\Framework\TestCase
{

/**
Expand All @@ -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()
Expand All @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/src/Common/CoordinatesValueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@

use G4\DataMapper\Common\CoordinatesValue;

class CoordinatesValueTest extends PHPUnit_Framework_TestCase
class CoordinatesValueTest extends \PHPUnit\Framework\TestCase
{

/**
* @var CoordinatesValue
*/
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;
}
Expand Down
36 changes: 23 additions & 13 deletions tests/unit/src/Common/IdentityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use G4\DataMapper\Common\Identity;

class IdentityTest extends PHPUnit_Framework_TestCase
class IdentityTest extends \PHPUnit\Framework\TestCase
{

/**
Expand All @@ -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;
}
Expand All @@ -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]);
}

Expand All @@ -42,15 +43,17 @@ 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]);
}

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]);
}

Expand All @@ -63,23 +66,26 @@ 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]);
}

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]);
}

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]);
}

Expand All @@ -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]);
}

Expand All @@ -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');
}

Expand All @@ -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);
}

Expand Down
6 changes: 3 additions & 3 deletions tests/unit/src/Common/RangeValueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Loading