Skip to content

Commit

Permalink
Merge 26281b9 into eb7d515
Browse files Browse the repository at this point in the history
  • Loading branch information
rvanlaak committed Oct 24, 2019
2 parents eb7d515 + 26281b9 commit 463c696
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 34 deletions.
13 changes: 5 additions & 8 deletions src/Micrometa/Tests/AbstractTestBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,18 @@ abstract class AbstractTestBase extends TestCase
*
* @var string
*/
protected static $fixture;
protected static $fixture = __DIR__.DIRECTORY_SEPARATOR.'Fixture'.DIRECTORY_SEPARATOR;

/**
* Logger
*
* @var LoggerInterface
*/
protected static $logger;
private static $logger;

/**
* Setup
*/
public static function setUpBeforeClass()
protected static function getLogger() : LoggerInterface
{
self::$fixture = __DIR__.DIRECTORY_SEPARATOR.'Fixture'.DIRECTORY_SEPARATOR;
self::$logger = new ExceptionLogger();
return self::$logger ?? self::$logger = new ExceptionLogger();
}

/**
Expand Down
24 changes: 5 additions & 19 deletions src/Micrometa/Tests/Application/ExtractorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,6 @@
*/
class ExtractorTest extends AbstractTestBase
{
/**
* Microformats tests root path
*
* @var string
*/
protected static $microformatsTests;

/**
* Setup before all tests
*/
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
self::$microformatsTests = \ComposerLocator::getPath('mf2/tests').DIRECTORY_SEPARATOR.'tests'.
DIRECTORY_SEPARATOR.'microformats-v2'.DIRECTORY_SEPARATOR;
}

/**
* Test the RDFa Lite 1.1 extraction
*/
Expand All @@ -82,7 +65,7 @@ public function testRdfaLiteExtraction()
$this->assertInstanceOf(\DOMDocument::class, $rdfaLiteDom);

// Create an RDFa Lite 1.1 parser
$rdfaLiteParser = new RdfaLite($rdfaLiteUri, self::$logger);
$rdfaLiteParser = new RdfaLite($rdfaLiteUri, self::getLogger());
$this->assertEquals($rdfaLiteUri, $rdfaLiteParser->getUri());

// Create an extractor service
Expand Down Expand Up @@ -121,8 +104,11 @@ public function testMicrodataExtraction()
*/
public function testMicroformatsExtraction()
{
$microformatsTests = \ComposerLocator::getPath('mf2/tests').DIRECTORY_SEPARATOR.'tests'.
DIRECTORY_SEPARATOR.'microformats-v2'.DIRECTORY_SEPARATOR;

$this->getAndTestMicroformatsExtractionBase(
self::$microformatsTests.'h-product'.DIRECTORY_SEPARATOR.'aggregate.html'
$microformatsTests.'h-product'.DIRECTORY_SEPARATOR.'aggregate.html'
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Micrometa/Tests/Infrastructure/ParserFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function testParserFactory()
{
$formats = Microformats::FORMAT | Microdata::FORMAT | JsonLD::FORMAT | RdfaLite::FORMAT | LinkType::FORMAT;
$uri = 'http://localhost/example.html';
$parsers = ParserFactory::createParsersFromFormats($formats, Http::createFromString($uri), self::$logger);
$parsers = ParserFactory::createParsersFromFormats($formats, Http::createFromString($uri), self::getLogger());

/**
* @var int $parserFormat
Expand Down
12 changes: 6 additions & 6 deletions src/Micrometa/Tests/Infrastructure/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class ParserTest extends AbstractTestBase
public function testLanguageJsonLDParser()
{
list($uri, $dom) = $this->getUriFixture('json-ld/jsonld-languages.html');
$parser = new JsonLD($uri, self::$logger);
$parser = new JsonLD($uri, self::getLogger());
$items = $parser->parseDom($dom)->getItems();
$this->assertTrue(is_array($items));
$this->assertEquals(1, count($items));
Expand Down Expand Up @@ -112,7 +112,7 @@ public function testInvalidJsonLDParser()
public function testMicroformatsParser()
{
list($uri, $dom) = $this->getUriFixture('microformats/entry.html');
$parser = new Microformats($uri, self::$logger);
$parser = new Microformats($uri, self::getLogger());
$items = $parser->parseDom($dom)->getItems();
$this->assertTrue(is_array($items));
$this->assertEquals(1, count($items));
Expand All @@ -126,7 +126,7 @@ public function testMicroformatsParser()
public function testNestedMicroformatsParser()
{
list($uri, $dom) = $this->getUriFixture('microformats/nested-events.html');
$parser = new Microformats($uri, self::$logger);
$parser = new Microformats($uri, self::getLogger());
$items = $parser->parseDom($dom)->getItems();
$this->assertTrue(is_array($items));
$this->assertEquals(1, count($items));
Expand All @@ -141,7 +141,7 @@ public function testNestedMicroformatsParser()
public function testMicrodataParser()
{
list($uri, $dom) = $this->getUriFixture('html-microdata/article-microdata.html');
$parser = new Microdata($uri, self::$logger);
$parser = new Microdata($uri, self::getLogger());
$items = $parser->parseDom($dom)->getItems();
$this->assertTrue(is_array($items));
$this->assertEquals(1, count($items));
Expand All @@ -156,7 +156,7 @@ public function testMicrodataParser()
public function testRdfaLiteParser()
{
list($uri, $dom) = $this->getUriFixture('rdfa-lite/article-rdfa-lite.html');
$parser = new RdfaLite($uri, self::$logger);
$parser = new RdfaLite($uri, self::getLogger());
$items = $parser->parseDom($dom)->getItems();
$this->assertTrue(is_array($items));
$this->assertEquals(1, count($items));
Expand All @@ -171,7 +171,7 @@ public function testRdfaLiteParser()
public function testLinkTypeParser()
{
list($uri, $dom) = $this->getUriFixture('link-type/valid-test.html');
$parser = new LinkType($uri, self::$logger);
$parser = new LinkType($uri, self::getLogger());
$items = $parser->parseDom($dom)->getItems();
$this->assertTrue(is_array($items));
$this->assertEquals(4, count($items));
Expand Down

0 comments on commit 463c696

Please sign in to comment.