You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Fix ConnectionAdapterTestCase with ConnectionAdapter::selectAll returning array
* Adjust TestDatabase to not require static methods
* Update README example
Copy file name to clipboardExpand all lines: README.md
+8-6Lines changed: 8 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,7 +35,7 @@ listed, please submit an issue to this repository!
35
35
## Quick Example
36
36
37
37
This example is intended to reflect what should be capable with this library. We're going to
38
-
use [cspray/database-testing-phpunit]() as our testing extension, it is ubiquitous and likely the framework you'll start off using with this library.
38
+
use [cspray/database-testing-phpunit](https://github.com/cspray/databse-testing-phpunit) as our testing extension, it is ubiquitous and likely the framework you'll start off using with this library.
39
39
40
40
```php
41
41
<?php declare(strict_types=1);
@@ -46,6 +46,7 @@ use Cspray\DatabaseTesting\DatabaseCleanup\TransactionWithRollback;
46
46
use Cspray\DatabaseTesting\Fixture\LoadFixture;
47
47
use Cspray\DatabaseTesting\Fixture\SingleRecordFixture;
48
48
use Cspray\DatabaseTesting\TestDatabase;
49
+
use Cspray\DatabaseTesting\PhpUnit\InjectTestDatabase;
49
50
use Cspray\DatabaseTesting\PhpUnit\RequiresTestDatabase;
50
51
use PHPUnit\Framework\TestCase;
51
52
use PDO;
@@ -60,13 +61,16 @@ use PDO;
60
61
)]
61
62
final class RepositoryTest extends TestCase {
62
63
64
+
#[InjectTestDatabase]
65
+
private static TestDatabase $testDatabase;
66
+
63
67
private PDO $pdo;
64
68
private MyRepository $myRepository;
65
69
66
70
protected function setUp() : void {
67
71
// be sure to use the connection from TestDatabase! depending on CleanupStrategy,
68
72
// using a different connection could wind up with a dirty database state
69
-
$this->pdo = TestDatabase::connection();
73
+
$this->pdo = self::$testDatabase->connection();
70
74
$this->myRepository = new MyRepository($this->pdo);
71
75
}
72
76
@@ -79,7 +83,7 @@ final class RepositoryTest extends TestCase {
79
83
])
80
84
)]
81
85
public function testTableHasCorrectlyLoadedFixtures() : void {
82
-
$table = TestDatabase::table('my_table');
86
+
$table = self::$testDatabase->table('my_table');
83
87
84
88
self::assertCount(1, $table);
85
89
@@ -88,7 +92,7 @@ final class RepositoryTest extends TestCase {
88
92
}
89
93
90
94
public function testTableCanBeReloadedToGetNewlyInsertedRecords() : void {
91
-
$table = TestDatabase::table('my_table');
95
+
$table = self::$testDatabase->table('my_table');
92
96
93
97
self::assertCount(0, $table);
94
98
@@ -101,5 +105,3 @@ final class RepositoryTest extends TestCase {
0 commit comments