Conditions | 6 |
Paths | 4 |
Total Lines | 35 |
Code Lines | 20 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
20 | public function testReadOnlyTransaction() |
||
21 | { |
||
22 | if (DB::get_conn()->supportsTransactions() == true |
||
23 | && DB::get_conn() instanceof PostgreSQLDatabase |
||
24 | ) { |
||
25 | $page = new Page(); |
||
26 | $page->Title = 'Read only success'; |
||
27 | $page->write(); |
||
28 | |||
29 | DB::get_conn()->transactionStart('READ ONLY'); |
||
30 | |||
31 | try { |
||
32 | $page = new Page(); |
||
33 | $page->Title = 'Read only page failed'; |
||
34 | $page->write(); |
||
35 | } catch (Exception $e) { |
||
36 | //could not write this record |
||
37 | //We need to do a rollback or a commit otherwise we'll get error messages |
||
38 | DB::get_conn()->transactionRollback(); |
||
39 | } |
||
40 | |||
41 | DB::get_conn()->transactionEnd(); |
||
42 | |||
43 | DataObject::flush_and_destroy_cache(); |
||
44 | |||
45 | $success = DataObject::get('Page', "\"Title\"='Read only success'"); |
||
46 | $fail = DataObject::get('Page', "\"Title\"='Read only page failed'"); |
||
47 | |||
48 | //This page should be in the system |
||
49 | $this->assertTrue(is_object($success) && $success->exists()); |
||
50 | |||
51 | //This page should NOT exist, we had 'read only' permissions |
||
52 | $this->assertFalse(is_object($fail) && $fail->exists()); |
||
53 | } else { |
||
54 | $this->markTestSkipped('Current database is not PostgreSQL'); |
||
55 | } |
||
58 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths