Skip to content

Commit 162a0fd

Browse files
PHPUnit to Pest Converter (#33)
* Add Pest dependencies * Add base Pest file * Convert test cases * Remove non-compound imports * Adopt expectation API * Optimize uses * Use Pest test runner * Migrated tests from Phpunit to Pest --------- Co-authored-by: Shift <shift@laravelshift.com>
1 parent 44d8598 commit 162a0fd

20 files changed

+1403
-1571
lines changed

.github/workflows/run-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
matrix:
1414
os: [ubuntu-latest]
1515
arangodb: ["3.10", 3.11, 3.12]
16-
php: [8.1, 8.2, 8.3]
16+
php: [8.2, 8.3]
1717
stability: [prefer-stable]
1818

1919
name: P${{ matrix.php }} - A${{ matrix.arangodb }} - ${{ matrix.stability }}

composer.json

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
}
1515
],
1616
"minimum-stability": "dev",
17-
"prefer-stable" : true,
17+
"prefer-stable": true,
1818
"require": {
1919
"php": "^8.1",
2020
"ext-curl": "*",
@@ -29,9 +29,9 @@
2929
"mockery/mockery": "^1.4",
3030
"phpmd/phpmd": "^2.9",
3131
"phpstan/phpstan": "^1.0",
32-
"phpunit/phpunit": "^9.5",
3332
"rector/rector": "^0.14.8",
34-
"scrutinizer/ocular": "^1.8"
33+
"scrutinizer/ocular": "^1.8",
34+
"pestphp/pest": "^2.2"
3535
},
3636
"autoload": {
3737
"psr-4": {
@@ -45,11 +45,14 @@
4545
},
4646
"scripts": {
4747
"analyse": "vendor/bin/phpstan analyse",
48-
"test": "vendor/bin/phpunit",
49-
"test:coverage": "vendor/bin/phpunit --coverage-clover clover.xml --whitelist src",
48+
"test": "vendor/bin/pest",
49+
"test:coverage": "vendor/bin/pest --coverage-clover clover.xml",
5050
"style": "vendor/bin/pint"
5151
},
5252
"config": {
53-
"sort-packages": true
53+
"sort-packages": true,
54+
"allow-plugins": {
55+
"pestphp/pest-plugin": true
56+
}
5457
}
5558
}

phpunit.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@
1616
</include>
1717
</coverage>
1818
<php>
19-
<env name="ARANGODB_VERSION" value="3.8"/>
19+
<env name="ARANGODB_VERSION" value="3.12"/>
2020
</php>
2121
</phpunit>

tests/AdminManagerTest.php

Lines changed: 28 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,33 @@
22

33
declare(strict_types=1);
44

5-
namespace Tests;
6-
75
use ArangoClient\Admin\AdminManager;
86

9-
class AdminManagerTest extends TestCase
10-
{
11-
protected AdminManager $adminManager;
12-
13-
protected function setUp(): void
14-
{
15-
parent::setUp();
16-
17-
$this->adminManager = new AdminManager($this->arangoClient);
18-
}
19-
20-
public function testGetVersion()
21-
{
22-
$result = $this->adminManager->getVersion();
23-
24-
$this->assertSame('arango', $result->server);
25-
$this->assertSame('community', $result->license);
26-
$this->assertIsString($result->version);
27-
}
28-
29-
public function testGetVersionWithDetails()
30-
{
31-
$result = $this->adminManager->getVersion(true);
32-
33-
$this->assertSame('arango', $result->server);
34-
$this->assertSame('community', $result->license);
35-
$this->assertIsString($result->version);
36-
}
37-
38-
public function testGetRunningTransactions()
39-
{
40-
$transactions = $this->adminManager->getRunningTransactions();
41-
$this->assertEmpty($transactions);
42-
}
43-
}
7+
uses(Tests\TestCase::class);
8+
9+
beforeEach(function () {
10+
$this->adminManager = new AdminManager($this->arangoClient);
11+
});
12+
13+
14+
test('get version', function () {
15+
$result = $this->adminManager->getVersion();
16+
17+
expect($result->server)->toBe('arango');
18+
expect($result->license)->toBe('community');
19+
expect($result->version)->toBeString();
20+
});
21+
22+
test('get version with details', function () {
23+
$result = $this->adminManager->getVersion(true);
24+
25+
expect($result->server)->toBe('arango');
26+
expect($result->license)->toBe('community');
27+
expect($result->version)->toBeString();
28+
});
29+
30+
test('get running transactions', function () {
31+
$transactions = $this->adminManager->getRunningTransactions();
32+
33+
expect($transactions)->toBeEmpty();
34+
});

0 commit comments

Comments
 (0)