Skip to content

Commit

Permalink
test with php 8
Browse files Browse the repository at this point in the history
  • Loading branch information
dbu committed Oct 8, 2020
1 parent 98c4ebb commit 6584dd7
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 37 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ php:
- 7.2
- 7.3
- 7.4
- nightly

sudo: false

Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@
}
],
"require": {
"php": "^7.1",
"php": "^7.1 || ^8.0",
"ext-pdo": "*",
"doctrine/dbal": "^2.9.3",
"phpcr/phpcr": "~2.1.5",
"phpcr/phpcr-utils": "^1.4.1",
"jackalope/jackalope": "^1.3.8"
"jackalope/jackalope": "dev-phpunit-9@dev"
},
"provide": {
"jackalope/jackalope-transport": "1.3.0"
},
"require-dev": {
"psr/log": "^1.0",
"phpcr/phpcr-api-tests": "2.1.20",
"phpunit/phpunit": "^7.5.18",
"phpcr/phpcr-api-tests": "dev-allow-php8@dev",
"phpunit/phpunit": "^7.5.18 || ^8.0 || ^9.0",
"phpunit/dbunit": "^4.0"
},
"autoload": {
Expand Down
4 changes: 2 additions & 2 deletions tests/Jackalope/Test/FunctionalTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class FunctionalTestCase extends TestCase
*/
protected $session;

public function setUp()
public function setUp(): void
{
parent::setUp();

Expand All @@ -54,7 +54,7 @@ public function setUp()
$this->session = $this->repository->login(new SimpleCredentials('user', 'passwd'), $GLOBALS['phpcr.workspace']);
}

protected function loadFixtures(Connection $conn)
protected function loadFixtures(Connection $conn): void
{
$options = ['disable_fks' => $conn->getDatabasePlatform() instanceof SqlitePlatform];
$schema = new RepositorySchema($options, $conn);
Expand Down
18 changes: 7 additions & 11 deletions tests/Jackalope/Tools/Console/InitDoctrineDbalCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,32 +40,28 @@ class InitDoctrineDbalCommandTest extends TestCase
*/
protected $application;

public function setUp()
public function setUp(): void
{
$this->connection = $this->createMock(Connection::class);
$this->schemaManager = $this->createMock(AbstractSchemaManager::class);

$this->platform = $this->createMock(MySqlPlatform::class);

$this->connection
->expects($this->any())
->method('getDatabasePlatform')
->will($this->returnValue($this->platform));
->willReturn($this->platform);

$this->schemaManager
->expects($this->any())
->method('createSchemaConfig')
->will($this->returnValue(null));
->willReturn(null);

$this->connection
->expects($this->any())
->method('getSchemaManager')
->will($this->returnValue($this->schemaManager));
->willReturn($this->schemaManager);

$this->platform
->expects($this->any())
->method('getCreateTableSQL')
->will($this->returnValue([]));
->willReturn([]);

$this->helperSet = new HelperSet([
'phpcr' => new DoctrineDbalHelper($this->connection),
Expand All @@ -87,7 +83,7 @@ public function setUp()
*
* @return CommandTester
*/
protected function executeCommand($name, $args, $status = 0)
protected function executeCommand($name, $args, $status = 0): CommandTester
{
$command = $this->application->find($name);
$commandTester = new CommandTester($command);
Expand All @@ -99,7 +95,7 @@ protected function executeCommand($name, $args, $status = 0)
return $commandTester;
}

public function testCommand()
public function testCommand(): void
{
$this->executeCommand('jackalope:init:dbal', [], 2);
$this->executeCommand('jackalope:init:dbal', ['--dump-sql' => true], 0);
Expand Down
10 changes: 5 additions & 5 deletions tests/Jackalope/Transport/DoctrineDBAL/PrefetchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class PrefetchTest extends FunctionalTestCase
{
protected $conn;

public function setUp()
public function setUp(): void
{
parent::setUp();

Expand All @@ -21,7 +21,7 @@ public function setUp()
$this->session->save();
}

public function testGetNode()
public function testGetNode(): void
{
$this->transport->setFetchDepth(1);

Expand All @@ -30,7 +30,7 @@ public function testGetNode()
$this->assertNode($raw, 'a');
}

public function testGetNodes()
public function testGetNodes(): void
{
$this->transport->setFetchDepth(1);

Expand All @@ -55,7 +55,7 @@ public function testGetNodes()
$this->assertChildNode($list['/node-b/child-b'], 'b', 'b');
}

protected function assertNode($raw)
protected function assertNode($raw): void
{
$this->assertInstanceOf('\stdClass', $raw);

Expand All @@ -66,7 +66,7 @@ protected function assertNode($raw)
$this->assertObjectHasAttribute($name, $raw);
}

protected function assertChildNode($raw, $parent, $child)
protected function assertChildNode($raw, $parent, $child): void
{
$this->assertInstanceOf('\stdClass', $raw);

Expand Down
53 changes: 38 additions & 15 deletions tests/Jackalope/Transport/DoctrineDBAL/Query/QOMWalkerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class QOMWalkerTest extends TestCase
*/
private $defaultColumns = '*';

public function setUp()
public function setUp(): void
{
parent::setUp();

Expand All @@ -49,29 +49,36 @@ public function setUp()
;

$this->nodeTypeManager
->expects($this->any())
->method('hasNodeType')
->will($this->returnValue(true))
->willReturn(true)
;

$this->factory = new QueryObjectModelFactory(new Factory);
$this->walker = new QOMWalker($this->nodeTypeManager, $conn);
$this->defaultColumns = 'n0.path AS n0_path, n0.identifier AS n0_identifier, n0.props AS n0_props';
}

public function testDefaultQuery()
public function testDefaultQuery(): void
{
$this->nodeTypeManager->expects($this->once())->method('getSubtypes')->will($this->returnValue([]));
$this->nodeTypeManager
->expects($this->once())
->method('getSubtypes')
->willReturn([])
;

$query = $this->factory->createQuery($this->factory->selector('nt:unstructured', 'nt:unstructured'), null, [], []);
list($selectors, $selectorAliases, $sql) = $this->walker->walkQOMQuery($query);

$this->assertEquals(sprintf("SELECT %s FROM phpcr_nodes n0 WHERE n0.workspace_name = ? AND n0.type IN ('nt:unstructured')", $this->defaultColumns), $sql);
}

public function testQueryWithPathComparisonConstraint()
public function testQueryWithPathComparisonConstraint(): void
{
$this->nodeTypeManager->expects($this->once())->method('getSubtypes')->will($this->returnValue([]));
$this->nodeTypeManager
->expects($this->once())
->method('getSubtypes')
->willReturn([])
;

$query = $this->factory->createQuery(
$this->factory->selector('nt:unstructured', 'nt:unstructured'),
Expand All @@ -84,9 +91,13 @@ public function testQueryWithPathComparisonConstraint()
$this->assertEquals(sprintf("SELECT %s FROM phpcr_nodes n0 WHERE n0.workspace_name = ? AND n0.type IN ('nt:unstructured') AND n0.path = '/'", $this->defaultColumns), $sql);
}

public function testQueryWithPropertyComparisonConstraint()
public function testQueryWithPropertyComparisonConstraint(): void
{
$this->nodeTypeManager->expects($this->once())->method('getSubtypes')->will($this->returnValue([]));
$this->nodeTypeManager
->expects($this->once())
->method('getSubtypes')
->willReturn([])
;

$query = $this->factory->createQuery(
$this->factory->selector('nt:unstructured', 'nt:unstructured'),
Expand All @@ -102,9 +113,13 @@ public function testQueryWithPropertyComparisonConstraint()
);
}

public function testQueryWithPropertyComparisonConstraintNumericLiteral()
public function testQueryWithPropertyComparisonConstraintNumericLiteral(): void
{
$this->nodeTypeManager->expects($this->once())->method('getSubtypes')->will($this->returnValue([]));
$this->nodeTypeManager
->expects($this->once())
->method('getSubtypes')
->willReturn([])
;

$query = $this->factory->createQuery(
$this->factory->selector('a', 'nt:unstructured'),
Expand All @@ -117,9 +132,13 @@ public function testQueryWithPropertyComparisonConstraintNumericLiteral()
$this->assertContains('> 100', $sql);
}

public function testQueryWithAndConstraint()
public function testQueryWithAndConstraint(): void
{
$this->nodeTypeManager->expects($this->once())->method('getSubtypes')->will($this->returnValue([]));
$this->nodeTypeManager
->expects($this->once())
->method('getSubtypes')
->willReturn([])
;

$query = $this->factory->createQuery(
$this->factory->selector('nt:unstructured', 'nt:unstructured'),
Expand All @@ -135,9 +154,13 @@ public function testQueryWithAndConstraint()
$this->assertEquals(sprintf("SELECT %s FROM phpcr_nodes n0 WHERE n0.workspace_name = ? AND n0.type IN ('nt:unstructured') AND (n0.path = '/' AND n0.path = '/')", $this->defaultColumns), $sql);
}

public function testQueryWithOrConstraint()
public function testQueryWithOrConstraint(): void
{
$this->nodeTypeManager->expects($this->once())->method('getSubtypes')->will($this->returnValue([]));
$this->nodeTypeManager
->expects($this->once())
->method('getSubtypes')
->willReturn([])
;

$query = $this->factory->createQuery(
$this->factory->selector('nt:unstructured', 'nt:unstructured'),
Expand Down

0 comments on commit 6584dd7

Please sign in to comment.