CallbackWriterTest::testPrepare()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
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