RecordsTraitTest::testReduceOldEmailsData()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 25
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 1
Metric Value
eloc 17
c 1
b 1
f 1
dl 0
loc 25
rs 9.7
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Nip\MailModule\Tests\EmailsTable\Traits\Cleanup;
4
5
use Mockery;
0 ignored issues
show
Bug introduced by
The type Mockery was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Nip\Database\Adapters\MySQLi;
7
use Nip\Database\Connections\Connection;
8
use Nip\MailModule\Tests\AbstractTest;
9
use Nip\MailModule\Tests\Fixtures\Models\Emails\Emails;
10
11
/**
12
 * Class RecordsTraitTest
13
 * @package Nip\MailModule\Tests\EmailsTable\Traits\Cleanup
14
 */
15
class RecordsTraitTest extends AbstractTest
16
{
17
    public function testReduceOldEmailsData()
18
    {
19
        $adapter = Mockery::mock(MySQLi::class)->makePartial();
20
        $adapter->shouldReceive('cleanData')
21
            ->andReturnUsing(function ($data) {
22
                return $data;
23
            });
24
25
        $database = Mockery::mock(Connection::class)->makePartial();
26
        $database->shouldReceive('execute')
27
            ->andReturnUsing(function ($query) {
28
                return $query->getString();
29
            });
30
        $database->setAdapter($adapter);
31
32
        $emails = new Emails();
33
        $emails->setDB($database);
34
35
        $query = $emails->reduceOldEmailsData();
36
37
        self::assertSame(
38
            'UPDATE `emails` '
39
            . 'SET `vars` = \'\', `body` = \'\', `compiled_subject` = \'\', `compiled_body` = \'\' '
40
            . 'WHERE `date_sent` <= DATE_SUB(CURRENT_DATE(), INTERVAL 500 DAY)',
41
            $query
42
        );
43
    }
44
45
    public function test_reduceEmailsByType()
46
    {
47
        $emails = new Emails();
48
        $types = $emails::reduceEmailsByType();
49
50
        self::assertSame(['*' => 365, 'donation' => 365], $types);
51
    }
52
}
53