xref: /plugin/struct/_test/mock/CSVPageImporter.php (revision 17dbef8af8e73f5c6a6bdbfcb629a48d85005bd7)
1*17dbef8aSMichael Große<?php
2*17dbef8aSMichael Große
3*17dbef8aSMichael Große
4*17dbef8aSMichael Großenamespace dokuwiki\plugin\struct\test\mock;
5*17dbef8aSMichael Große
6*17dbef8aSMichael Große
7*17dbef8aSMichael Großeclass CSVPageImporter extends \dokuwiki\plugin\struct\meta\CSVPageImporter
8*17dbef8aSMichael Große{
9*17dbef8aSMichael Große
10*17dbef8aSMichael Große    /** @var \Generator */
11*17dbef8aSMichael Große    protected $testData;
12*17dbef8aSMichael Große
13*17dbef8aSMichael Große    public function setTestData(array $testData)
14*17dbef8aSMichael Große    {
15*17dbef8aSMichael Große        $this->testData = $this->testDataGenerator($testData);
16*17dbef8aSMichael Große
17*17dbef8aSMichael Große    }
18*17dbef8aSMichael Große
19*17dbef8aSMichael Große    protected function openFile($file)
20*17dbef8aSMichael Große    {
21*17dbef8aSMichael Große    }
22*17dbef8aSMichael Große
23*17dbef8aSMichael Große    protected function getLine()
24*17dbef8aSMichael Große    {
25*17dbef8aSMichael Große        if (!$this->testData->valid()) {
26*17dbef8aSMichael Große            return $this->testData->getReturn();
27*17dbef8aSMichael Große        }
28*17dbef8aSMichael Große        $current = $this->testData->current();
29*17dbef8aSMichael Große        $this->testData->next();
30*17dbef8aSMichael Große        return $current;
31*17dbef8aSMichael Große    }
32*17dbef8aSMichael Große
33*17dbef8aSMichael Große    protected function testDataGenerator($testData)
34*17dbef8aSMichael Große    {
35*17dbef8aSMichael Große        foreach ($testData as $line) {
36*17dbef8aSMichael Große            yield $line;
37*17dbef8aSMichael Große        }
38*17dbef8aSMichael Große
39*17dbef8aSMichael Große        return false;
40*17dbef8aSMichael Große    }
41*17dbef8aSMichael Große}
42