These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | namespace Da\Mailer\Test; |
||
3 | |||
4 | use Da\Mailer\Queue\Backend\Pdo\PdoQueueStoreConnection; |
||
5 | use Da\Mailer\Test\Fixture\FixtureHelper; |
||
6 | use PHPUnit_Extensions_Database_TestCase; |
||
7 | |||
8 | abstract class AbstractMySqlDatabaseTestCase extends PHPUnit_Extensions_Database_TestCase |
||
9 | { |
||
10 | |||
11 | protected static function getPdoQueueStoreConnection() |
||
12 | { |
||
13 | static $pdoQueue; |
||
14 | |||
15 | if ($pdoQueue === null) { |
||
16 | $pdoQueue = new PdoQueueStoreConnection(FixtureHelper::getMySqlConnectionConfiguration()); |
||
17 | } |
||
18 | |||
19 | return $pdoQueue; |
||
20 | } |
||
21 | |||
22 | /** |
||
23 | * @inheritdoc |
||
24 | */ |
||
25 | protected function getConnection() |
||
26 | { |
||
27 | $pdo = self::getPdoQueueStoreConnection(); |
||
28 | |||
29 | return $this->createDefaultDBConnection($pdo->getInstance()); |
||
0 ignored issues
–
show
|
|||
30 | } |
||
31 | |||
32 | /** |
||
33 | * @inheritdoc |
||
34 | */ |
||
35 | protected function getDataSet() |
||
36 | { |
||
37 | return $this->createFlatXMLDataSet(__DIR__ . '/data/test.xml'); |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * @inheritdoc |
||
42 | */ |
||
43 | protected function setUp() |
||
44 | { |
||
45 | $sql = file_get_contents(__DIR__ . '/migrations/mysql.sql'); |
||
46 | |||
47 | $statements = array_map('trim', array_filter(explode(";", $sql))); |
||
48 | |||
49 | foreach($statements as $sqlQuery) |
||
50 | { |
||
51 | if(empty($sqlQuery)) { |
||
52 | continue; |
||
53 | } |
||
54 | $query = self::getPdoQueueStoreConnection()->getInstance()->prepare($sqlQuery); |
||
55 | $query->execute(); |
||
56 | } |
||
57 | |||
58 | |||
59 | parent::setUp(); |
||
60 | } |
||
61 | } |
||
62 |
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: