Conditions | 1 |
Paths | 1 |
Total Lines | 25 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
20 | public function test_delete() |
||
21 | { |
||
22 | $query = null; |
||
23 | |||
24 | $adapter = Mockery::mock(MySQLi::class)->shouldAllowMockingProtectedMethods()->makePartial(); |
||
25 | $adapter->shouldReceive('cleanData')->andReturnArg(0); |
||
26 | |||
27 | /** @var Connection|Mockery\Mock $database */ |
||
28 | $database = Mockery::mock(Connection::class)->shouldAllowMockingProtectedMethods()->makePartial(); |
||
29 | $database->shouldReceive('execute')->with(\Mockery::capture($query))->once(); |
||
|
|||
30 | $database->setAdapter($adapter); |
||
31 | |||
32 | $emailsTable = new Emails(); |
||
33 | $emailsTable->setDB($database); |
||
34 | ModelLocator::set('emails', $emailsTable); |
||
35 | |||
36 | $command = new EmailsCleanupRecords(); |
||
37 | $command->handle(); |
||
38 | |||
39 | self::assertInstanceOf(Delete::class, $query); |
||
40 | self::assertSame( |
||
41 | 'DELETE FROM `emails` WHERE `type` = \'donation\' AND `date_sent` <= DATE_SUB(CURRENT_DATE(), INTERVAL 365 DAY)', |
||
42 | $query->getString() |
||
43 | ); |
||
44 | } |
||
45 | } |
||
46 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: