Passed
Branch develop (bae466)
by Paul
06:12
created

EmailTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 25
dl 0
loc 37
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A test_email() 0 18 1
A set_up() 0 10 1
1
<?php
2
3
namespace GeminiLabs\SiteReviews\Tests;
4
5
use Faker\Factory;
6
use GeminiLabs\SiteReviews\Modules\Email;
7
use WP_UnitTestCase;
0 ignored issues
show
Bug introduced by
The type WP_UnitTestCase 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...
8
9
/**
10
 * Test case for the Emails.
11
 * @group email
12
 */
13
class EmailTest extends WP_UnitTestCase
14
{
15
    use Setup;
16
17
    protected $review;
18
19
    public function set_up()
20
    {
21
        parent::set_up();
22
        $faker = Factory::create();
23
        $this->review = [
24
            'content' => $faker->text,
25
            'email' => $faker->email,
26
            'name' => $faker->name,
27
            'rating' => '5',
28
            'title' => $faker->sentence,
29
        ];
30
    }
31
32
    public function test_email()
33
    {
34
        $email = [
35
            'to' => '[email protected]',
36
            'subject' => 'Test Email',
37
            'template' => 'default',
38
            'template-tags' => [
39
                'review_author' => $this->review['name'],
40
                'review_content' => $this->review['content'],
41
                'review_email' => $this->review['email'],
42
                'review_ip' => '127.0.0.1',
43
                'review_link' => 'http://...',
44
                'review_rating' => $this->review['rating'],
45
                'review_title' => $this->review['title'],
46
            ],
47
        ];
48
        $sent = glsr(Email::class)->compose($email)->send();
49
        $this->assertEquals($sent, 1);
50
    }
51
}
52