1 | <?php |
||
7 | class CsvExtractorSpec extends ObjectBehavior |
||
8 | { |
||
9 | function let() |
||
10 | { |
||
11 | $this->beConstructedWith(new \SplFileObject(__DIR__.'/../../Fixture/extract.csv')); |
||
12 | } |
||
13 | |||
14 | function it_is_initializable() |
||
15 | { |
||
16 | $this->shouldHaveType('Extraload\Extractor\CsvExtractor'); |
||
17 | } |
||
18 | |||
19 | function it_implements_extractor_interface() |
||
20 | { |
||
21 | $this->shouldImplement('Extraload\Extractor\ExtractorInterface'); |
||
22 | } |
||
23 | |||
24 | function it_iterates_over_csv_rows() |
||
25 | { |
||
26 | $this->extract()->shouldReturn(['a1', 'b1', 'c1']); |
||
27 | $this->extract()->shouldReturn(['a2', 'b2', 'c2']); |
||
28 | $this->extract()->shouldReturn(['a3', 'b3', 'c3']); |
||
29 | } |
||
30 | |||
31 | function it_moves_over_csv_rows() |
||
32 | { |
||
33 | $this->current()->shouldReturn(['a1', 'b1', 'c1']); |
||
34 | $this->next(); |
||
35 | $this->current()->shouldReturn(['a2', 'b2', 'c2']); |
||
36 | $this->next(); |
||
37 | $this->current()->shouldReturn(['a3', 'b3', 'c3']); |
||
38 | } |
||
39 | |||
40 | function it_rewinds() |
||
41 | { |
||
42 | $this->extract()->shouldReturn(['a1', 'b1', 'c1']); |
||
43 | $this->rewind(); |
||
44 | $this->extract()->shouldReturn(['a1', 'b1', 'c1']); |
||
45 | } |
||
46 | } |
||
47 |