ProductStatusValueConverterTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
c 2
b 0
f 0
lcom 1
cbo 2
dl 0
loc 31
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setup() 0 4 1
A testConvert() 0 4 1
A testDefaultValueIsUsedIfNoValueSet() 0 4 1
A testExceptionIsThrownIfInvalidStatusIsPassed() 0 8 1
1
<?php
2
3
namespace Jh\DataImportTest\ValueConverter;
4
5
use Jh\DataImportMagento\ValueConverter\ProductStatusValueConverter;
6
7
/**
8
 * Class ProductStatusValueConverterTest
9
 * @package Jh\DataImportTest\ValueConverter
10
 * @author  Aydin Hassan <[email protected]>
11
 */
12
class ProductStatusValueConverterTest extends \PHPUnit_Framework_TestCase
13
{
14
    /**
15
     * @var ProductStatusValueConverter
16
     */
17
    protected $converter;
18
19
    public function setup()
20
    {
21
        $this->converter = new ProductStatusValueConverter;
22
    }
23
24
    public function testExceptionIsThrownIfInvalidStatusIsPassed()
25
    {
26
        $message  = 'Given Product Status: "on-vacation" is not valid. Allowed values: ';
27
        $message .= '"Enabled", "Disabled"';
28
29
        $this->setExpectedException('\Ddeboer\DataImport\Exception\UnexpectedValueException', $message);
30
        $this->converter->convert('on-vacation');
31
    }
32
33
    public function testConvert()
34
    {
35
        $this->assertEquals(1, $this->converter->convert('Enabled'));
36
    }
37
38
    public function testDefaultValueIsUsedIfNoValueSet()
39
    {
40
        $this->assertEquals(2, $this->converter->convert(""));
41
    }
42
}
43