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
7 changes: 4 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ jobs:
matrix:
os:
- ubuntu-24.04
- windows-2022
- windows-2025
php:
- 8.5
- 8.4
- 8.3
- 8.2
Expand All @@ -28,7 +29,7 @@ jobs:
- 5.5
- 5.4
exclude: # ignore flaky results for legacy PHP on Windows
- os: windows-2022
- os: windows-2025
php: 5.4
steps:
- uses: actions/checkout@v3
Expand All @@ -46,7 +47,7 @@ jobs:
- run: vendor/bin/phpunit --coverage-text --coverage-clover=clover.xml -c phpunit.xml.legacy
if: ${{ matrix.php < 7.3 }}
- name: Check 100% code coverage
if: ${{ matrix.os != 'windows-2022' }}
if: ${{ matrix.os != 'windows-2025' }}
shell: php {0}
run: |
<?php
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
"php": ">=5.4",
"ext-sqlite3": "*",
"clue/ndjson-react": "^1.0",
"react/child-process": "^0.6.6",
"react/event-loop": "^1.2",
"react/promise": "^3.2 || ^2.7 || ^1.2.1"
"react/child-process": "^0.6.7",
"react/event-loop": "^1.6",
"react/promise": "^3.3 || ^2.7 || ^1.2.1"
},
"require-dev": {
"phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36"
Expand Down
32 changes: 24 additions & 8 deletions tests/FactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ public function testConstructWithoutLoopAssignsLoopAutomatically()
$factory = new Factory();

$ref = new \ReflectionProperty($factory, 'loop');
$ref->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$ref->setAccessible(true);
}
$loop = $ref->getValue($factory);

$this->assertInstanceOf('React\EventLoop\LoopInterface', $loop);
Expand All @@ -24,11 +26,15 @@ public function testConstructWitLoopAndBinaryAssignsBothVariables()
$factory = new Factory($loop, 'php6.0');

$ref = new \ReflectionProperty($factory, 'loop');
$ref->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$ref->setAccessible(true);
}
$this->assertSame($loop, $ref->getValue($factory));

$ref = new \ReflectionProperty($factory, 'bin');
$ref->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$ref->setAccessible(true);
}
$this->assertSame('php6.0', $ref->getValue($factory));
}

Expand Down Expand Up @@ -64,7 +70,9 @@ public function testLoadLazyWithIdleOptionsReturnsDatabaseWithIdleTimeApplied()
$db = $factory->openLazy(':memory:', null, ['idle' => 10.0]);

$ref = new \ReflectionProperty($db, 'idlePeriod');
$ref->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$ref->setAccessible(true);
}
$value = $ref->getValue($db);

$this->assertEquals(10.0, $value);
Expand All @@ -78,7 +86,9 @@ public function testLoadLazyWithAbsolutePathWillBeUsedAsIs()
$db = $factory->openLazy(__DIR__ . '/users.db');

$ref = new \ReflectionProperty($db, 'filename');
$ref->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$ref->setAccessible(true);
}
$value = $ref->getValue($db);

$this->assertEquals(__DIR__ . '/users.db', $value);
Expand All @@ -92,7 +102,9 @@ public function testLoadLazyWithMemoryPathWillBeUsedAsIs()
$db = $factory->openLazy(':memory:');

$ref = new \ReflectionProperty($db, 'filename');
$ref->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$ref->setAccessible(true);
}
$value = $ref->getValue($db);

$this->assertEquals(':memory:', $value);
Expand All @@ -106,7 +118,9 @@ public function testLoadLazyWithEmptyPathWillBeUsedAsIs()
$db = $factory->openLazy('');

$ref = new \ReflectionProperty($db, 'filename');
$ref->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$ref->setAccessible(true);
}
$value = $ref->getValue($db);

$this->assertEquals('', $value);
Expand All @@ -127,7 +141,9 @@ public function testLoadLazyWithRelativePathWillBeResolvedWhenConstructingAndWil
chdir('../');

$ref = new \ReflectionProperty($db, 'filename');
$ref->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$ref->setAccessible(true);
}
$value = $ref->getValue($db);

chdir($original);
Expand Down
84 changes: 63 additions & 21 deletions tests/FunctionalDatabaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ public function testOpenMemoryDatabaseResolvesWithDatabaseAndRunsUntilClose($php

if ($useSocket !== null) {
$ref = new \ReflectionProperty($factory, 'useSocket');
$ref->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$ref->setAccessible(true);
}
$ref->setValue($factory, $useSocket);
}

Expand Down Expand Up @@ -81,7 +83,9 @@ public function testOpenMemoryDatabaseResolvesWithDatabaseAndRunsUntilQuit($php,

if ($useSocket !== null) {
$ref = new \ReflectionProperty($factory, 'useSocket');
$ref->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$ref->setAccessible(true);
}
$ref->setValue($factory, $useSocket);
}

Expand Down Expand Up @@ -149,7 +153,9 @@ public function testOpenInvalidPathRejects($php, $useSocket)

if ($useSocket !== null) {
$ref = new \ReflectionProperty($factory, 'useSocket');
$ref->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$ref->setAccessible(true);
}
$ref->setValue($factory, $useSocket);
}

Expand All @@ -174,7 +180,9 @@ public function testOpenInvalidPathWithNullByteRejects($php, $useSocket)

if ($useSocket !== null) {
$ref = new \ReflectionProperty($factory, 'useSocket');
$ref->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$ref->setAccessible(true);
}
$ref->setValue($factory, $useSocket);
}

Expand All @@ -199,7 +207,9 @@ public function testOpenInvalidFlagsRejects($php, $useSocket)

if ($useSocket !== null) {
$ref = new \ReflectionProperty($factory, 'useSocket');
$ref->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$ref->setAccessible(true);
}
$ref->setValue($factory, $useSocket);
}

Expand All @@ -224,7 +234,9 @@ public function testQuitResolvesAndRunsUntilQuit($php, $useSocket)

if ($useSocket !== null) {
$ref = new \ReflectionProperty($factory, 'useSocket');
$ref->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$ref->setAccessible(true);
}
$ref->setValue($factory, $useSocket);
}

Expand Down Expand Up @@ -254,7 +266,9 @@ public function testQuitResolvesAndRunsUntilQuitWhenParentHasManyFileDescriptors

if ($useSocket !== null) {
$ref = new \ReflectionProperty($factory, 'useSocket');
$ref->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$ref->setAccessible(true);
}
$ref->setValue($factory, $useSocket);
}

Expand Down Expand Up @@ -283,7 +297,9 @@ public function testQuitTwiceWillRejectSecondCall($php, $useSocket)

if ($useSocket !== null) {
$ref = new \ReflectionProperty($factory, 'useSocket');
$ref->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$ref->setAccessible(true);
}
$ref->setValue($factory, $useSocket);
}

Expand All @@ -309,7 +325,9 @@ public function testQueryIntegerResolvesWithResultWithTypeIntegerAndRunsUntilQui

if ($useSocket !== null) {
$ref = new \ReflectionProperty($factory, 'useSocket');
$ref->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$ref->setAccessible(true);
}
$ref->setValue($factory, $useSocket);
}

Expand Down Expand Up @@ -340,7 +358,9 @@ public function testQueryStringResolvesWithResultWithTypeStringAndRunsUntilQuit(

if ($useSocket !== null) {
$ref = new \ReflectionProperty($factory, 'useSocket');
$ref->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$ref->setAccessible(true);
}
$ref->setValue($factory, $useSocket);
}

Expand Down Expand Up @@ -371,7 +391,9 @@ public function testQueryInvalidTableRejectsWithExceptionAndRunsUntilQuit($php,

if ($useSocket !== null) {
$ref = new \ReflectionProperty($factory, 'useSocket');
$ref->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$ref->setAccessible(true);
}
$ref->setValue($factory, $useSocket);
}

Expand Down Expand Up @@ -402,7 +424,9 @@ public function testQueryInvalidTableWithPlaceholderRejectsWithExceptionAndRunsU

if ($useSocket !== null) {
$ref = new \ReflectionProperty($factory, 'useSocket');
$ref->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$ref->setAccessible(true);
}
$ref->setValue($factory, $useSocket);
}

Expand Down Expand Up @@ -604,7 +628,9 @@ public function testQueryRejectsWhenQueryIsInvalid($php, $useSocket)

if ($useSocket !== null) {
$ref = new \ReflectionProperty($factory, 'useSocket');
$ref->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$ref->setAccessible(true);
}
$ref->setValue($factory, $useSocket);
}

Expand All @@ -629,7 +655,9 @@ public function testQueryRejectsWhenClosedImmediately($useSocket)
$factory = new Factory();

$ref = new \ReflectionProperty($factory, 'useSocket');
$ref->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$ref->setAccessible(true);
}
$ref->setValue($factory, $useSocket);

$promise = $factory->open(':memory:');
Expand All @@ -655,7 +683,9 @@ public function testExecCreateTableResolvesWithResultWithoutRows($php, $useSocke

if ($useSocket !== null) {
$ref = new \ReflectionProperty($factory, 'useSocket');
$ref->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$ref->setAccessible(true);
}
$ref->setValue($factory, $useSocket);
}

Expand Down Expand Up @@ -686,7 +716,9 @@ public function testExecRejectsWhenClosedImmediately($php, $useSocket)

if ($useSocket !== null) {
$ref = new \ReflectionProperty($factory, 'useSocket');
$ref->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$ref->setAccessible(true);
}
$ref->setValue($factory, $useSocket);
}

Expand All @@ -713,7 +745,9 @@ public function testExecRejectsWhenAlreadyClosed($php, $useSocket)

if ($useSocket !== null) {
$ref = new \ReflectionProperty($factory, 'useSocket');
$ref->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$ref->setAccessible(true);
}
$ref->setValue($factory, $useSocket);
}

Expand All @@ -739,7 +773,9 @@ public function testQueryInsertResolvesWithEmptyResultSetWithLastInsertIdAndRuns

if ($useSocket !== null) {
$ref = new \ReflectionProperty($factory, 'useSocket');
$ref->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$ref->setAccessible(true);
}
$ref->setValue($factory, $useSocket);
}

Expand Down Expand Up @@ -774,7 +810,9 @@ public function testQuerySelectEmptyResolvesWithEmptyResultSetWithColumnsAndNoRo

if ($useSocket !== null) {
$ref = new \ReflectionProperty($factory, 'useSocket');
$ref->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$ref->setAccessible(true);
}
$ref->setValue($factory, $useSocket);
}

Expand Down Expand Up @@ -802,7 +840,9 @@ public function testCancelOpenWithSocketRejectsPromise()
$factory = new Factory();

$ref = new \ReflectionProperty($factory, 'useSocket');
$ref->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$ref->setAccessible(true);
}
$ref->setValue($factory, true);

$promise = $factory->open(':memory:');
Expand Down Expand Up @@ -830,7 +870,9 @@ public function testOpenWithSocketWillRejectWhenSocketConnectionTimesOut()
$factory = new Factory($loop);

$ref = new \ReflectionProperty($factory, 'useSocket');
$ref->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$ref->setAccessible(true);
}
$ref->setValue($factory, true);

$promise = $factory->open(':memory:');
Expand Down
4 changes: 3 additions & 1 deletion tests/FunctionalFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ public function testOpenReturnsPromiseWhichRejectsWithExceptionWhenExplicitPhpBi
$factory = new Factory(null, 'echo');

$ref = new \ReflectionProperty($factory, 'useSocket');
$ref->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$ref->setAccessible(true);
}
$ref->setValue($factory, true);

$promise = $factory->open(':memory:');
Expand Down
Loading