1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* micrometa |
5
|
|
|
* |
6
|
|
|
* @category Jkphl |
7
|
|
|
* @package Jkphl\Micrometa |
8
|
|
|
* @subpackage Jkphl\Micrometa\Tests\Domain |
9
|
|
|
* @author Joschi Kuphal <[email protected]> / @jkphl |
10
|
|
|
* @copyright Copyright © 2017 Joschi Kuphal <[email protected]> / @jkphl |
11
|
|
|
* @license http://opensource.org/licenses/MIT The MIT License (MIT) |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
/*********************************************************************************** |
15
|
|
|
* The MIT License (MIT) |
16
|
|
|
* |
17
|
|
|
* Copyright © 2017 Joschi Kuphal <[email protected]> / @jkphl |
18
|
|
|
* |
19
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of |
20
|
|
|
* this software and associated documentation files (the "Software"), to deal in |
21
|
|
|
* the Software without restriction, including without limitation the rights to |
22
|
|
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of |
23
|
|
|
* the Software, and to permit persons to whom the Software is furnished to do so, |
24
|
|
|
* subject to the following conditions: |
25
|
|
|
* |
26
|
|
|
* The above copyright notice and this permission notice shall be included in all |
27
|
|
|
* copies or substantial portions of the Software. |
28
|
|
|
* |
29
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
30
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS |
31
|
|
|
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR |
32
|
|
|
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER |
33
|
|
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
34
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
35
|
|
|
***********************************************************************************/ |
36
|
|
|
|
37
|
|
|
namespace Jkphl\Micrometa\Tests\Ports; |
38
|
|
|
|
39
|
|
|
use Jkphl\Micrometa\Ports\Format; |
40
|
|
|
use Jkphl\Micrometa\Ports\Item\ItemObjectModelInterface; |
41
|
|
|
use Jkphl\Micrometa\Ports\Parser; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Parser tests |
45
|
|
|
* |
46
|
|
|
* @package Jkphl\Micrometa |
47
|
|
|
* @subpackage Jkphl\Micrometa\Tests |
48
|
|
|
*/ |
49
|
|
|
class ParserTest extends \PHPUnit_Framework_TestCase |
50
|
|
|
{ |
51
|
|
|
/** |
52
|
|
|
* Valid local test HTML document |
53
|
|
|
* |
54
|
|
|
* @var string |
55
|
|
|
*/ |
56
|
|
|
const VALID_HTML_URL = 'http://localhost:1349/valid-test.html'; |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Test the parser facade with a simple document without items |
60
|
|
|
*/ |
61
|
|
|
public function testLinkRelParser() |
62
|
|
|
{ |
63
|
|
|
$parser = new Parser(Format::LINK_REL); |
64
|
|
|
$itemObjectModel = $parser(self::VALID_HTML_URL); |
65
|
|
|
$this->assertInstanceOf(ItemObjectModelInterface::class, $itemObjectModel); |
66
|
|
|
$this->assertEquals(2, count($itemObjectModel->getItems())); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Test the parser facade |
71
|
|
|
*/ |
72
|
|
|
// public function testParser() |
73
|
|
|
// { |
74
|
|
|
// $microformatsHtml = \ComposerLocator::getPath('microformats/test').DIRECTORY_SEPARATOR.'tests'. |
75
|
|
|
// DIRECTORY_SEPARATOR.'microformats-v2'.DIRECTORY_SEPARATOR.'h-product'.DIRECTORY_SEPARATOR.'aggregate.html'; |
76
|
|
|
// $parser = new Parser(Format::MICROFORMATS); |
77
|
|
|
// $itemObjectModel = $parser(self::VALID_HTML_URL, file_get_contents($microformatsHtml), Format::ALL); |
78
|
|
|
// $this->assertInstanceOf(ItemObjectModelInterface::class, $itemObjectModel); |
79
|
|
|
// $this->assertEquals(1, count($itemObjectModel->getItems())); |
80
|
|
|
// $item = $itemObjectModel->getFirstItem(); |
81
|
|
|
// $this->assertInstanceOf(Item::class, $item); |
82
|
|
|
//// $this->assertTrue($item->isOfType('invalid', MicroformatsFactory::MF2_PROFILE_URI.'h-product')); |
83
|
|
|
// } |
84
|
|
|
} |
85
|
|
|
|