1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Sportic\Timing\RaceTecClient\Tests\Parsers; |
4
|
|
|
|
5
|
|
|
use PHPUnit\Framework\TestCase; |
6
|
|
|
use Sportic\Timing\RaceTecClient\Scrapers\AbstractScraper; |
7
|
|
|
use Sportic\Timing\RaceTecClient\Parsers\EventPage as EventPageParser; |
8
|
|
|
use Symfony\Component\DomCrawler\Crawler; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Class AbstractPageTest |
12
|
|
|
* @package Sportic\Timing\RaceTecClient\Tests\Scrapers |
13
|
|
|
*/ |
14
|
|
|
abstract class AbstractPageTest extends TestCase |
15
|
|
|
{ |
16
|
|
|
protected static $parameters; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* @var EventPageParser |
20
|
|
|
*/ |
21
|
|
|
protected static $parser; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @var array |
25
|
|
|
*/ |
26
|
|
|
protected static $parametersParsed; |
27
|
|
|
|
28
|
|
|
public static function setUpBeforeClass() |
29
|
|
|
{ |
30
|
|
|
self::$parameters = unserialize( |
31
|
|
|
file_get_contents(TEST_FIXTURE_PATH . DS . 'Parsers' . DS . static::getSerializedFile()) |
32
|
|
|
); |
33
|
|
|
|
34
|
|
|
$scrapper = static::getNewScraper(); |
35
|
|
|
|
36
|
|
|
$crawler = new Crawler(null, $scrapper->getCrawlerUri()); |
37
|
|
|
$crawler->addContent( |
38
|
|
|
file_get_contents( |
39
|
|
|
TEST_FIXTURE_PATH . DS . 'Parsers' . DS . static::getHtmlFile() |
40
|
|
|
), |
41
|
|
|
'text/html;charset=utf-8' |
42
|
|
|
); |
43
|
|
|
|
44
|
|
|
self::$parser = static::getNewParser(); |
|
|
|
|
45
|
|
|
self::$parser->setScraper($scrapper); |
|
|
|
|
46
|
|
|
self::$parser->setCrawler($crawler); |
|
|
|
|
47
|
|
|
|
48
|
|
|
self::$parametersParsed = self::$parser->getContent(); |
|
|
|
|
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @return string |
53
|
|
|
*/ |
54
|
|
|
abstract protected static function getSerializedFile(); |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @return string |
58
|
|
|
*/ |
59
|
|
|
abstract protected static function getHtmlFile(); |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @return AbstractScraper |
63
|
|
|
*/ |
64
|
|
|
abstract protected static function getNewScraper(); |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @return AbstractScraper |
68
|
|
|
*/ |
69
|
|
|
abstract protected static function getNewParser(); |
70
|
|
|
} |
71
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..