Completed
Push — master ( fe2892...6427ed )
by Oleg
03:03
created

AttributeTest::testCreateNewAttribute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 21
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 18
nc 1
nop 0
dl 0
loc 21
rs 9.3142
c 0
b 0
f 0
1
<?php
2
namespace OptimizelyPHPTest\Resource\v2;
3
4
use PHPUnit_Framework_TestCase;
5
use WebMarketingROI\OptimizelyPHP\Resource\v2\Attribute;
6
7
class AttributeTest extends PHPUnit_Framework_TestCase
8
{
9
    public function testCreateNewAttribute()
10
    {
11
        $attribute = new Attribute();
12
        $attribute->setKey('subscriber_status');
13
        $attribute->setProjectId(1000);
14
        $attribute->setArchived(false);
15
        $attribute->setDescription('string');
16
        $attribute->setName('Subscriber Status');
17
        $attribute->setConditionType('custom_attribute');
18
        $attribute->setId(0);
19
        $attribute->setLastModified('2017-05-08T03:34:01.035Z');
20
        
21
        $this->assertEquals('subscriber_status', $attribute->getKey());
22
        $this->assertEquals(1000, $attribute->getProjectId());
23
        $this->assertEquals(false, $attribute->getArchived());
24
        $this->assertEquals('string', $attribute->getDescription());
25
        $this->assertEquals('Subscriber Status', $attribute->getName());
26
        $this->assertEquals('custom_attribute', $attribute->getConditionType());
27
        $this->assertEquals(0, $attribute->getId());
28
        $this->assertEquals('2017-05-08T03:34:01.035Z', $attribute->getLastModified());
29
    }
30
    
31
    public function testCreateNewAttributeWithOptions()
32
    {
33
        $options = array(
34
            "key" => "subscriber_status",
35
            "project_id" => 0,
36
            "archived" => false,
37
            "description" => "string",
38
            "name" => "Subscriber Status",
39
            "condition_type" => "custom_attribute",
40
            "id" => 0,
41
            "last_modified" => "2017-05-08T03:34:01.035Z"
42
        );
43
        
44
        $attribute = new Attribute($options);        
45
        
46
        $this->assertEquals('subscriber_status', $attribute->getKey());
47
        $this->assertEquals(0, $attribute->getProjectId());
48
        $this->assertEquals(false, $attribute->getArchived());
49
        $this->assertEquals('string', $attribute->getDescription());
50
        $this->assertEquals('Subscriber Status', $attribute->getName());
51
        $this->assertEquals('custom_attribute', $attribute->getConditionType());
52
        $this->assertEquals(0, $attribute->getId());
53
        $this->assertEquals('2017-05-08T03:34:01.035Z', $attribute->getLastModified());        
54
    }
55
    
56
    public function testToArray()
57
    {
58
        $options = array(
59
            "key" => "subscriber_status",
60
            "project_id" => 0,
61
            "archived" => false,
62
            "description" => "string",
63
            "name" => "Subscriber Status",
64
            "condition_type" => "custom_attribute",
65
            "id" => 0,
66
            "last_modified" => "2017-05-08T03:34:01.035Z"
67
        );
68
        
69
        $attribute = new Attribute($options);     
70
        
71
        $this->assertEquals($options, $attribute->toArray());        
72
    }
73
}
74
75
76