1 | <?php |
||
55 | class ThingTest extends \PHPUnit_Framework_TestCase |
||
56 | { |
||
57 | /** |
||
58 | * schema.org vocabulary |
||
59 | * |
||
60 | * @var Vocabulary |
||
61 | */ |
||
62 | protected static $schemaOrgVocabulary; |
||
63 | |||
64 | /** |
||
65 | * Setup all tests |
||
66 | */ |
||
67 | public static function setUpBeforeClass() |
||
68 | { |
||
69 | self::$schemaOrgVocabulary = new Vocabulary(VocabularyTest::SCHEMA_ORG_URI); |
||
70 | } |
||
71 | |||
72 | /** |
||
73 | * Test the instantiation of a minimum thing |
||
74 | */ |
||
75 | public function testMinimumThing() |
||
76 | { |
||
77 | $type = new Type('Person', self::$schemaOrgVocabulary); |
||
78 | $thing = new Thing($type); |
||
79 | $this->assertInstanceOf(Thing::class, $thing); |
||
80 | $this->assertEquals([$type], $thing->getTypes()); |
||
81 | $this->assertNull($thing->getResourceId()); |
||
82 | $this->assertInstanceOf(PropertyListInterface::class, $thing->getProperties()); |
||
83 | $this->assertEquals(0, count($thing->getProperties())); |
||
84 | } |
||
85 | |||
86 | /** |
||
87 | * Test the resource ID |
||
88 | */ |
||
89 | public function testResourceId() |
||
90 | { |
||
91 | $type = new Type('Person', self::$schemaOrgVocabulary); |
||
92 | $thing = new Thing($type, 'bob'); |
||
93 | $this->assertInstanceOf(Thing::class, $thing); |
||
94 | $this->assertEquals('bob', $thing->getResourceId()); |
||
95 | } |
||
96 | |||
97 | /** |
||
98 | * Test the thing instantiation with an invalid type |
||
99 | * |
||
100 | * @expectedException \Jkphl\RdfaLiteMicrodata\Domain\Exceptions\RuntimeException |
||
101 | * @expectedExceptionCode 1487435964 |
||
102 | */ |
||
103 | public function testInvalidTypeThing() |
||
107 | |||
108 | /** |
||
109 | * Test the instantiation of an anonymous thing |
||
110 | */ |
||
111 | public function testAnonymousThing() |
||
117 | |||
118 | /** |
||
119 | * Test adding a property |
||
120 | */ |
||
121 | public function testAddProperty() |
||
138 | |||
139 | /** |
||
140 | * Validate all properties |
||
141 | * |
||
142 | * @param ThingInterface $thing Thing |
||
143 | * @param VocabularyInterface $vocabulary Vocabulary |
||
144 | */ |
||
145 | protected function validateProperties(ThingInterface $thing, VocabularyInterface $vocabulary) |
||
153 | |||
154 | /** |
||
155 | * Validate a single property |
||
156 | * |
||
157 | * @param ThingInterface $thing Thing |
||
158 | * @param VocabularyInterface $vocabulary Vocabulary |
||
159 | * @param PropertyInterface $property1 First property |
||
160 | * @param PropertyInterface $property2 Second property |
||
161 | */ |
||
162 | protected function validateProperty( |
||
173 | |||
174 | /** |
||
175 | * Test getting an invalid property name |
||
176 | * |
||
177 | * @expectedException \Jkphl\RdfaLiteMicrodata\Domain\Exceptions\OutOfBoundsException |
||
178 | * @expectedExceptionCode 1486849016 |
||
179 | */ |
||
180 | public function testGetInvalidPropertyName() |
||
187 | } |
||
188 |