CallbackWriterTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 35
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testPrepare() 0 9 1
A testWriteItem() 0 12 1
A testFinish() 0 9 1
1
<?php
2
3
namespace Ddeboer\DataImport\Tests\Writer;
4
5
use Ddeboer\DataImport\Writer\CallbackWriter;
6
7
/**
8
 * @author Markus Bachmann <[email protected]>
9
 */
10
class CallbackWriterTest extends \PHPUnit_Framework_TestCase
11
{
12
    public function testPrepare()
13
    {
14
        $callable = function(array $item) {
0 ignored issues
show
Unused Code introduced by
The parameter $item is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
15
            return '';
16
        };
17
18
        $writer = new CallbackWriter($callable);
19
        $writer->prepare();
20
    }
21
22
    public function testWriteItem()
23
    {
24
        $string = '';
25
        $callable = function(array $item) use (&$string) {
26
            $string = implode(',', array_values($item));
27
        };
28
29
        $writer = new CallbackWriter($callable);
30
        $writer->writeItem(array('foo' => 'bar', 'bar' => 'foo'));
31
32
        $this->assertEquals('bar,foo', $string);
33
    }
34
35
    public function testFinish()
36
    {
37
        $callable = function(array $item) {
0 ignored issues
show
Unused Code introduced by
The parameter $item is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
38
            return '';
39
        };
40
41
        $writer = new CallbackWriter($callable);
42
        $writer->finish();
43
    }
44
}
45