Skip to content

Commit

Permalink
Merge ccca462 into f093c49
Browse files Browse the repository at this point in the history
  • Loading branch information
rvanlaak committed Feb 13, 2020
2 parents f093c49 + ccca462 commit 2d93cb2
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 91 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"clue/graph-composer": "dev-master",
"mf2/tests": "@dev",
"mindplay/composer-locator": "^2.1",
"phpunit/phpunit": ">=7.0",
"phpunit/phpunit": "^8.5",
"php-coveralls/php-coveralls": "^2.1",
"squizlabs/php_codesniffer": "^3.3"
}
Expand Down
5 changes: 2 additions & 3 deletions src/Micrometa/Tests/Application/ItemFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,11 @@ public function testInvalidItemPropertyValueList()

/**
* Test an invalid language tagged property value
*
* @expectedException \Jkphl\Micrometa\Ports\Exceptions\RuntimeException
* @expectedExceptionCode 1495906369
*/
public function testInvalidLanguageTaggedPropertyValue()
{
$this->expectException('Jkphl\Micrometa\Ports\Exceptions\RuntimeException');
$this->expectExceptionCode('1495906369');
$itemFactory = new ItemFactory(0);
$rawItem = (object)[
'type' => ['test'],
Expand Down
10 changes: 4 additions & 6 deletions src/Micrometa/Tests/Domain/IriTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,11 @@ class IriTest extends AbstractTestBase
{
/**
* Test IRIs
*
* @expectedException \Jkphl\Micrometa\Domain\Exceptions\OutOfBoundsException
* @expectedExceptionCode 1495895152
*/
public function testIri()
{
$this->expectException('Jkphl\Micrometa\Domain\Exceptions\OutOfBoundsException');
$this->expectExceptionCode('1495895152');
$profile = md5(rand());
$name = md5(rand());
$iri = new Iri($profile, $name);
Expand All @@ -70,12 +69,11 @@ public function testIri()

/**
* Test IRI immutability
*
* @expectedException \Jkphl\Micrometa\Domain\Exceptions\ErrorException
* @expectedExceptionCode 1495895278
*/
public function testIriImmutability()
{
$this->expectException('Jkphl\Micrometa\Domain\Exceptions\ErrorException');
$this->expectExceptionCode('1495895278');
$iri = new Iri('', '');
$iri->profile = 'abc';
}
Expand Down
30 changes: 12 additions & 18 deletions src/Micrometa/Tests/Domain/ItemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,67 +197,61 @@ protected function str($str)

/**
* Test the item creation with an empty types list
*
* @expectedException \Jkphl\Micrometa\Domain\Exceptions\InvalidArgumentException
* @expectedExceptionCode 1490814631
*/
public function testEmptyTypesList()
{
$this->expectException('Jkphl\Micrometa\Domain\Exceptions\InvalidArgumentException');
$this->expectExceptionCode('1490814631');
new Item(null);
}

/**
* Test the item creation with an empty types list
*
* @expectedException \Jkphl\Micrometa\Domain\Exceptions\InvalidArgumentException
* @expectedExceptionCode 1488314667
*/
public function testEmptyTypeName()
{
$this->expectException('Jkphl\Micrometa\Domain\Exceptions\InvalidArgumentException');
$this->expectExceptionCode('1488314667');
new Item('');
}

/**
* Test the item creation with an empty property name
*
* @expectedException \Jkphl\Micrometa\Domain\Exceptions\InvalidArgumentException
* @expectedExceptionCode 1488314921
*/
public function testEmptyPropertyName()
{
$this->expectException('Jkphl\Micrometa\Domain\Exceptions\InvalidArgumentException');
$this->expectExceptionCode('1488314921');
new Item('type', [$this->prp('', 'value')]);
}

/**
* Test empty property value list
*
* @expectedException \Jkphl\Micrometa\Domain\Exceptions\InvalidArgumentException
* @expectedExceptionCode 1490814554
*/
public function testInvalidPropertyStructure()
{
$this->expectException('Jkphl\Micrometa\Domain\Exceptions\InvalidArgumentException');
$this->expectExceptionCode('1490814554');
new Item('type', [(object)['invalid' => 'structure']]);
}

/**
* Test the item creation with an invalid property value
*
* @expectedException \Jkphl\Micrometa\Domain\Exceptions\InvalidArgumentException
* @expectedExceptionCode 1488315339
*/
public function testInvalidPropertyValue()
{
$this->expectException('Jkphl\Micrometa\Domain\Exceptions\InvalidArgumentException');
$this->expectExceptionCode('1488315339');
new Item('type', [(object)['profile' => '', 'name' => 'test', 'values' => [123]]]);
}

/**
* Test the item creation with an invalid property value
*
* @expectedException \Jkphl\Micrometa\Domain\Exceptions\OutOfBoundsException
* @expectedExceptionCode 1488315604
*/
public function testUnknownPropertyName()
{
$this->expectException('Jkphl\Micrometa\Domain\Exceptions\OutOfBoundsException');
$this->expectExceptionCode('1488315604');
$item = new Item('type');
$item->getProperty('name');
}
Expand Down
15 changes: 6 additions & 9 deletions src/Micrometa/Tests/Domain/PropertyListTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,11 @@ class PropertyListTest extends AbstractTestBase
{
/**
* Test the property list
*
* @expectedException \Jkphl\Micrometa\Domain\Exceptions\ErrorException
* @expectedExceptionCode 1489784392
*/
public function testPropertyList()
{
$this->expectException('Jkphl\Micrometa\Domain\Exceptions\ErrorException');
$this->expectExceptionCode('1489784392');
$propertyList = new PropertyList();
$this->assertInstanceOf(PropertyList::class, $propertyList);
$this->assertEquals(0, count($propertyList));
Expand Down Expand Up @@ -139,25 +138,23 @@ protected function runUnprofiledPropertyTests(PropertyList $propertyList)

/**
* Test an unprofiled invalid property
*
* @expectedException \Jkphl\Micrometa\Domain\Exceptions\OutOfBoundsException
* @expectedExceptionCode 1488315604
*/
public function testUnprofiledInvalidProperty()
{
$this->expectException('Jkphl\Micrometa\Domain\Exceptions\OutOfBoundsException');
$this->expectExceptionCode('1488315604');
$propertyList = new PropertyList();
$this->assertInstanceOf(PropertyList::class, $propertyList);
$propertyList['invalid'];
}

/**
* Test an profiled invalid property
*
* @expectedException \Jkphl\Micrometa\Domain\Exceptions\OutOfBoundsException
* @expectedExceptionCode 1488315604
*/
public function testProfiledInvalidProperty()
{
$this->expectException('Jkphl\Micrometa\Domain\Exceptions\OutOfBoundsException');
$this->expectExceptionCode('1488315604');
$propertyList = new PropertyList();
$this->assertInstanceOf(PropertyList::class, $propertyList);
$propertyList->offsetGet((object)['name' => 'invalid', 'profile' => MicroformatsFactory::MF2_PROFILE_URI]);
Expand Down
14 changes: 6 additions & 8 deletions src/Micrometa/Tests/Infrastructure/LoggerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,26 +58,24 @@ public function testExceptionLogger()

/**
* Test the exception logger
*
* @expectedException \Jkphl\Micrometa\Ports\Exceptions\RuntimeException
* @expectedExceptionMessage CRITICAL
* @expectedExceptionCode 500
*/
public function testNoContextExceptionLogger()
{
$this->expectException('Jkphl\Micrometa\Ports\Exceptions\RuntimeException');
$this->expectExceptionCode('500');
$this->expectExceptionMessage('CRITICAL');
$logger = new ExceptionLogger();
$logger->critical('CRITICAL');
}

/**
* Test the exception logger with a context
*
* @expectedException \ErrorException
* @expectedExceptionMessage ERROR
* @expectedExceptionCode 1234
*/
public function testContextExceptionLogger()
{
$this->expectException('ErrorException');
$this->expectExceptionCode('1234');
$this->expectExceptionMessage('ERROR');
$exception = new \ErrorException('ERROR', 1234);
$logger = new ExceptionLogger();
$logger->critical('CRITICAL', ['exception' => $exception]);
Expand Down
17 changes: 7 additions & 10 deletions src/Micrometa/Tests/Infrastructure/ProfiledNameFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
* @package Jkphl\Micrometa
* @subpackage Jkphl\Micrometa\Tests
*/
class ProfiledNamesFactoryTest extends AbstractTestBase
class ProfiledNameFactoryTest extends AbstractTestBase
{
/**
* Test the profiled name factory
Expand Down Expand Up @@ -122,34 +122,31 @@ public function getProfiledNames()

/**
* Test an invalid profiled name object
*
* @expectedException \Jkphl\Micrometa\Ports\Exceptions\InvalidArgumentException
* @expectedExceptionCode 1489528854
*/
public function testInvalidObjectProfiledName()
{
$this->expectException('Jkphl\Micrometa\Ports\Exceptions\InvalidArgumentException');
$this->expectExceptionCode('1489528854');
ProfiledNamesFactory::createFromArguments([(object)['missing' => 'name']]);
}

/**
* Test an invalid profiled name array
*
* @expectedException \Jkphl\Micrometa\Ports\Exceptions\InvalidArgumentException
* @expectedExceptionCode 1491063221
*/
public function testInvalidArrayProfiledName()
{
$this->expectException('Jkphl\Micrometa\Ports\Exceptions\InvalidArgumentException');
$this->expectExceptionCode('1491063221');
ProfiledNamesFactory::createFromArguments([['invalid' => 'array']]);
}

/**
* Test an invalid profiled name sting
*
* @expectedException \Jkphl\Micrometa\Ports\Exceptions\InvalidArgumentException
* @expectedExceptionCode 1489528854
*/
public function testInvalidStringProfiledName()
{
$this->expectException('Jkphl\Micrometa\Ports\Exceptions\InvalidArgumentException');
$this->expectExceptionCode('1489528854');
ProfiledNamesFactory::createFromArguments(['']);
}
}
5 changes: 2 additions & 3 deletions src/Micrometa/Tests/Ports/ItemObjectModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,11 @@ class ItemObjectModelTest extends AbstractTestBase

/**
* Test the item object model
*
* @expectedException \Jkphl\Micrometa\Ports\Exceptions\OutOfBoundsException
* @expectedExceptionCode 1489268571
*/
public function testItemObjectModel()
{
$this->expectException('Jkphl\Micrometa\Ports\Exceptions\OutOfBoundsException');
$this->expectExceptionCode('1489268571');
$xml = '<html/>';
$dom = new \DOMDocument();
$dom->loadXML($xml);
Expand Down

0 comments on commit 2d93cb2

Please sign in to comment.