-
-
Save cspray/976d0f57c659a1d7bf8fcde3197c7bca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class DatabaseTestSuite implements TestSuite { | |
#[BeforeAll] | |
public function setUpDatabase() { | |
$conn = yield pool()->extractConnection(); | |
$this-set('db', $conn); | |
} | |
#[BeforeEach] | |
public function startTransaction() { | |
yield $this-get('db')->query('START TRANSACTION'); | |
} | |
#[AfterEach] | |
public function rollback() { | |
yield $this->get('db')->query('ROLLBACK'); | |
} | |
#[AfterAll] | |
public function closeLink() { | |
$this->get('db')->close(); | |
} | |
} | |
#[TestSuite(DatabaseTestSuite) | |
class DatabaseTestCase extends TestCase { | |
#[BeforeEach] | |
public function loadFixture() { | |
yield $this-get('db')->query('...'); | |
} | |
#[Test] | |
public function ensureStuff() { | |
// | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment