testDefaultValueIsUsedIfNoValueSet()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
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