XmlWriterSpec::it_is_initializable()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace spec\Port\Xml;
4
5
use PhpSpec\ObjectBehavior;
6
use Prophecy\Argument;
7
8
class XmlWriterSpec extends ObjectBehavior
9
{
10
    function let(\XmlWriter $xmlWriter)
11
    {
12
        $this->beConstructedWith($xmlWriter, 'file', 'elements', 'element', '1.0', 'UTF-8');
13
    }
14
15
    function it_is_initializable()
16
    {
17
        $this->shouldHaveType('Port\Xml\XmlWriter');
18
    }
19
20
    function it_is_a_writer()
21
    {
22
        $this->shouldImplement('Port\Writer');
23
        $this->shouldImplement('Port\Writer\FlushableWriter');
24
    }
25
26
    function it_writes_an_item(\XmlWriter $xmlWriter)
27
    {
28
        $xmlWriter->openUri('file')->shouldBeCalled();
29
        $xmlWriter->startDocument('1.0', 'UTF-8')->shouldBeCalled();
30
        $xmlWriter->startElement('elements')->shouldBeCalled();
31
        $xmlWriter->startElement('element')->shouldBeCalledTimes(2);
32
        $xmlWriter->writeElement('key1', 'value1')->shouldBeCalled();
33
        $xmlWriter->writeElement('key2', 'value2')->shouldBeCalled();
34
        $xmlWriter->endElement()->shouldBeCalledTimes(3);
35
        $xmlWriter->endDocument()->shouldBeCalled();
36
        $xmlWriter->flush()->shouldBeCalled();
37
38
        $this->prepare();
39
40
        $this->writeItem(['key1' => 'value1']);
41
        $this->writeItem(['key2' => 'value2']);
42
43
        $this->finish();
44
    }
45
}
46