xref: /plugin/struct/_test/mock/CSVPageImporter.php (revision b6dc4fd903b97544c51b2bfdcecd66d1d0e87b18)
117dbef8aSMichael Große<?php
217dbef8aSMichael Große
317dbef8aSMichael Große
417dbef8aSMichael Großenamespace dokuwiki\plugin\struct\test\mock;
517dbef8aSMichael Große
617dbef8aSMichael Große
717dbef8aSMichael Großeclass CSVPageImporter extends \dokuwiki\plugin\struct\meta\CSVPageImporter
817dbef8aSMichael Große{
917dbef8aSMichael Große
1017dbef8aSMichael Große    /** @var \Generator */
1117dbef8aSMichael Große    protected $testData;
1217dbef8aSMichael Große
1317dbef8aSMichael Große    public function setTestData(array $testData)
1417dbef8aSMichael Große    {
1517dbef8aSMichael Große        $this->testData = $this->testDataGenerator($testData);
1617dbef8aSMichael Große
1717dbef8aSMichael Große    }
1817dbef8aSMichael Große
1917dbef8aSMichael Große    protected function openFile($file)
2017dbef8aSMichael Große    {
2117dbef8aSMichael Große    }
2217dbef8aSMichael Große
2317dbef8aSMichael Große    protected function getLine()
2417dbef8aSMichael Große    {
2517dbef8aSMichael Große        $current = $this->testData->current();
2617dbef8aSMichael Große        $this->testData->next();
2717dbef8aSMichael Große        return $current;
2817dbef8aSMichael Große    }
2917dbef8aSMichael Große
3017dbef8aSMichael Große    protected function testDataGenerator($testData)
3117dbef8aSMichael Große    {
3217dbef8aSMichael Große        foreach ($testData as $line) {
3317dbef8aSMichael Große            yield $line;
3417dbef8aSMichael Große        }
3517dbef8aSMichael Große
36*b6dc4fd9SMichael Große        yield false;
3717dbef8aSMichael Große    }
3817dbef8aSMichael Große}
39