Skip to content

Commit 4ed056c

Browse files
committed
Test installing as dependency
1 parent 8d7ecd0 commit 4ed056c

File tree

6 files changed

+42
-0
lines changed

6 files changed

+42
-0
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,4 @@ jobs:
3535
if: ${{ matrix.php >= 7.3 }}
3636
- run: vendor/bin/phpunit --coverage-text -c phpunit.xml.legacy
3737
if: ${{ matrix.php < 7.3 }}
38+
- run: cd tests/install-as-dep && composer install && php query.php

phpunit.xml.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<testsuites>
1010
<testsuite name="SQLite React Test Suite">
1111
<directory>./tests/</directory>
12+
<exclude>./tests/install-as-dep/</exclude>
1213
</testsuite>
1314
</testsuites>
1415
<coverage>

phpunit.xml.legacy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<testsuites>
99
<testsuite name="SQLite React Test Suite">
1010
<directory>./tests/</directory>
11+
<exclude>./tests/install-as-dep/</exclude>
1112
</testsuite>
1213
</testsuites>
1314
<filter>

tests/install-as-dep/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/composer.lock
2+
/vendor/

tests/install-as-dep/composer.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"require": {
3+
"clue/reactphp-sqlite": "*@dev"
4+
},
5+
"repositories": [
6+
{
7+
"type": "path",
8+
"url": "../../"
9+
}
10+
]
11+
}

tests/install-as-dep/query.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
if (file_exists(__DIR__ . '/vendor/autoload.php')) {
4+
require __DIR__ . '/vendor/autoload.php';
5+
} else {
6+
require __DIR__ . '/../../vendor/autoload.php';
7+
}
8+
9+
$factory = new Clue\React\SQLite\Factory();
10+
$db = $factory->openLazy(':memory:', null, ['idle' => 0.001]);
11+
12+
$query = isset($argv[1]) ? $argv[1] : 'SELECT 42 AS value';
13+
$args = array_slice(isset($argv) ? $argv : [], 2);
14+
15+
$db->query('SELECT ? AS answer', [42])->then(function (Clue\React\SQLite\Result $result) {
16+
if ($result->columns !== ['answer'] || count($result->rows) !== 1 || $result->rows[0]['answer'] !== 42) {
17+
var_dump($result);
18+
throw new RuntimeException('Unexpected result');
19+
}
20+
21+
$answer = $result->rows[0]['answer'];
22+
echo 'Answer: ' . $answer . PHP_EOL;
23+
})->then(null, function (Exception $e) {
24+
echo 'Error: ' . $e->getMessage() . PHP_EOL;
25+
exit(1);
26+
});

0 commit comments

Comments
 (0)