-
Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy pathWP_SQLite_Driver_PDO_API_Tests.php
More file actions
53 lines (43 loc) · 1.52 KB
/
WP_SQLite_Driver_PDO_API_Tests.php
File metadata and controls
53 lines (43 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
use PHPUnit\Framework\TestCase;
class WP_SQLite_Driver_PDO_API_Tests extends TestCase {
/** @var WP_SQLite_Driver */
private $driver;
public function setUp(): void {
$connection = new WP_SQLite_Connection( array( 'path' => ':memory:' ) );
$this->driver = new WP_SQLite_Driver( $connection, 'wp' );
}
public function test_begin_transaction(): void {
$result = $this->driver->beginTransaction();
$this->assertTrue( $result );
}
public function test_begin_transaction_already_active(): void {
$this->driver->beginTransaction();
$this->expectException( PDOException::class );
$this->expectExceptionMessage( 'There is already an active transaction' );
$this->expectExceptionCode( 0 );
$this->driver->beginTransaction();
}
public function test_commit(): void {
$this->driver->beginTransaction();
$result = $this->driver->commit();
$this->assertTrue( $result );
}
public function test_commit_no_active_transaction(): void {
$this->expectException( PDOException::class );
$this->expectExceptionMessage( 'There is no active transaction' );
$this->expectExceptionCode( 0 );
$this->driver->commit();
}
public function test_rollback(): void {
$this->driver->beginTransaction();
$result = $this->driver->rollBack();
$this->assertTrue( $result );
}
public function test_rollback_no_active_transaction(): void {
$this->expectException( PDOException::class );
$this->expectExceptionMessage( 'There is no active transaction' );
$this->expectExceptionCode( 0 );
$this->driver->rollBack();
}
}