Completed
Push — develop ( f3c189...e92436 )
by Alejandro
08:55
created

testDefaultAttachmentsOptionsValues()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 11
nc 1
nop 0
1
<?php
2
namespace AcMailerTest\Options;
3
4
use AcMailer\Options\AttachmentsOptions;
5
use PHPUnit_Framework_TestCase as TestCase;
6
7
/**
8
 * Class AttachmentsOptionsTest
9
 * @author Alejandro Celaya Alastrué
10
 * @link http://www.alejandrocelaya.com
11
 */
12
class AttachmentsOptionsTest extends TestCase
13
{
14
    /**
15
     * @var AttachmentsOptions
16
     */
17
    private $attachmentsOptions;
18
19
    public function setUp()
20
    {
21
        $this->attachmentsOptions = new AttachmentsOptions();
22
    }
23
24
    public function testDefaultAttachmentsOptionsValues()
25
    {
26
        $this->assertTrue(is_array($this->attachmentsOptions->getFiles()));
27
        $this->assertCount(0, $this->attachmentsOptions->getFiles());
28
        $this->assertTrue(is_array($this->attachmentsOptions->getDir()));
29
        $this->assertArrayHasKey('recursive', $this->attachmentsOptions->getDir());
30
        $this->assertArrayHasKey('iterate', $this->attachmentsOptions->getDir());
31
        $this->assertArrayHasKey('path', $this->attachmentsOptions->getDir());
32
33
        $dir = $this->attachmentsOptions->getDir();
34
        $this->assertEquals(AttachmentsOptions::DEFAULT_PATH, $dir['path']);
35
        $this->assertEquals(AttachmentsOptions::DEFAULT_ITERATE, $dir['iterate']);
36
        $this->assertEquals(AttachmentsOptions::DEFAULT_RECURSIVE, $dir['recursive']);
37
    }
38
39 View Code Duplication
    public function testDireHasDefaultKeys()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
40
    {
41
        $this->attachmentsOptions->setDir(['recursive' => true]);
42
        $this->assertArrayHasKey('recursive', $this->attachmentsOptions->getDir());
43
        $this->assertArrayHasKey('iterate', $this->attachmentsOptions->getDir());
44
        $this->assertArrayHasKey('path', $this->attachmentsOptions->getDir());
45
        $dir = $this->attachmentsOptions->getDir();
46
        $this->assertEquals(AttachmentsOptions::DEFAULT_PATH, $dir['path']);
47
        $this->assertEquals(AttachmentsOptions::DEFAULT_ITERATE, $dir['iterate']);
48
        $this->assertEquals(true, $dir['recursive']);
49
    }
50
51
    public function testTotalFiles()
52
    {
53
        $this->assertCount(0, $this->attachmentsOptions->getFiles());
54
55
        $this->attachmentsOptions->setFiles(['file1', 'file2', 'file3']);
56
        $this->attachmentsOptions->addFiles(['file4', 'file5', 'file6']);
57
        $this->attachmentsOptions->addFile('file7');
58
        $this->attachmentsOptions->addFile('file8');
59
        $this->assertCount(8, $this->attachmentsOptions->getFiles());
60
61
        $this->attachmentsOptions->setFiles(['file1', 'file2', 'file3']);
62
        $this->assertCount(3, $this->attachmentsOptions->getFiles());
63
64
        $this->attachmentsOptions->addFiles(['file4', 'file5', 'file6']);
65
        $this->assertCount(6, $this->attachmentsOptions->getFiles());
66
    }
67
68 View Code Duplication
    public function testDirNormalization()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
69
    {
70
        $this->attachmentsOptions->setDir([]);
71
        $this->assertArrayHasKey('recursive', $this->attachmentsOptions->getDir());
72
        $this->assertArrayHasKey('iterate', $this->attachmentsOptions->getDir());
73
        $this->assertArrayHasKey('path', $this->attachmentsOptions->getDir());
74
75
        $dir = $this->attachmentsOptions->getDir();
76
        $this->assertEquals(AttachmentsOptions::DEFAULT_PATH, $dir['path']);
77
        $this->assertEquals(AttachmentsOptions::DEFAULT_ITERATE, $dir['iterate']);
78
        $this->assertEquals(AttachmentsOptions::DEFAULT_RECURSIVE, $dir['recursive']);
79
    }
80
}
81