UcwordsValueConverterTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 4 1
A testConverterThrowsExceptionIfValueIsNotString() 0 9 1
A testConverterUpperCasesStringInput() 0 7 1
1
<?php
2
3
namespace Jh\DataImportTest\ValueConverter;
4
5
use Jh\DataImportMagento\ValueConverter\UcwordsValueConverter;
6
7
/**
8
 * Class UcwordsValueConverterTest
9
 * @package Jh\DataImportTest\ValueConverter
10
 * @author Aydin Hassan <[email protected]>
11
 */
12
class UcwordsValueConverterTest extends \PHPUnit_Framework_TestCase
13
{
14
    /**
15
     * @var UcwordsValueConverter
16
     */
17
    protected $converter = null;
18
19
    public function setUp()
20
    {
21
        $this->converter = new UcwordsValueConverter();
22
    }
23
24
    public function testConverterThrowsExceptionIfValueIsNotString()
25
    {
26
        $this->setExpectedException(
27
            'Ddeboer\DataImport\Exception\UnexpectedTypeException',
28
            'Expected argument of type "string", "stdClass" given'
29
        );
30
31
        $this->converter->convert(new \stdClass);
0 ignored issues
show
Documentation introduced by
new \stdClass() is of type object<stdClass>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
32
    }
33
34
    public function testConverterUpperCasesStringInput()
35
    {
36
        $this->assertSame(
37
            "All These Words Should Begin With A Capital Letter",
38
            $this->converter->convert('all these words should begin with a capital letter')
39
        );
40
    }
41
}
42