Skip to content

Commit

Permalink
Merge branch 'j4test_updates2' of github.com:Hackwar/joomla-cms into …
Browse files Browse the repository at this point in the history
…j4test_integration

# Conflicts:
#	composer.lock
  • Loading branch information
Hackwar committed Jun 4, 2019
2 parents 3c374da + 95c8740 commit b752380
Show file tree
Hide file tree
Showing 14 changed files with 64 additions and 57 deletions.
Expand Up @@ -30,7 +30,7 @@ class WritableContainerLoaderTest extends UnitTestCase
*
* @return void
*/
protected function setUp()
protected function setUp():void
{
$this->container = $this->createMock(ContainerInterface::class);
}
Expand Down Expand Up @@ -76,14 +76,13 @@ public function testTheLoaderRetrievesACommand()
);
}

/**
* @expectedException \Symfony\Component\Console\Exception\CommandNotFoundException
*/
public function testTheLoaderDoesNotRetrieveAnUnknownCommand()
{
$commandName = 'test:loader';
$serviceId = 'test.loader';

$this->expectException(\Symfony\Component\Console\Exception\CommandNotFoundException::class);

$this->container->expects($this->once())
->method('has')
->with($serviceId)
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Libraries/Cms/Environment/BrowserTest.php
Expand Up @@ -36,7 +36,7 @@ class BrowserTest extends UnitTestCase
*
* @return void
*/
protected function setUp()
protected function setUp():void
{
$this->browser = new Browser;

Expand All @@ -48,7 +48,7 @@ protected function setUp()
*
* @return void
*/
protected function tearDown()
protected function tearDown():void
{
unset($this->browser);

Expand Down
10 changes: 5 additions & 5 deletions tests/Unit/Libraries/Cms/Feed/FeedEntryTest.php
Expand Up @@ -38,7 +38,7 @@ class FeedEntryTest extends UnitTestCase
* @see \PHPUnit\Framework\TestCase::setUp()
* @since 3.1.4
*/
protected function setUp()
protected function setUp():void
{
parent::setUp();

Expand All @@ -53,7 +53,7 @@ protected function setUp()
* @see \PHPUnit\Framework\TestCase::tearDown()
* @since 3.1.4
*/
protected function tearDown()
protected function tearDown():void
{
unset($this->feedEntry);

Expand Down Expand Up @@ -141,11 +141,11 @@ public function testSetAuthorWithPerson()
*
* @return void
*
* @expectedException InvalidArgumentException
* @since 3.1.4
*/
public function testSetAuthorWithInvalidAuthor()
{
$this->expectException(InvalidArgumentException::class);
$this->feedEntry->author = 'Jack Sprat';
}

Expand All @@ -154,11 +154,11 @@ public function testSetAuthorWithInvalidAuthor()
*
* @return void
*
* @expectedException InvalidArgumentException
* @since 3.1.4
*/
public function testSetSourceWithInvalidSource()
{
$this->expectException(InvalidArgumentException::class);
$this->feedEntry->source = 'Outer Space';
}

Expand All @@ -167,11 +167,11 @@ public function testSetSourceWithInvalidSource()
*
* @return void
*
* @expectedException InvalidArgumentException
* @since 3.1.4
*/
public function testSetCategoriesWithInvalidProperty()
{
$this->expectException(InvalidArgumentException::class);
$this->feedEntry->categories = 'Can\'t touch this';
}

Expand Down
13 changes: 5 additions & 8 deletions tests/Unit/Libraries/Cms/Feed/FeedFactoryTest.php
Expand Up @@ -32,7 +32,7 @@ class FeedFactoryTest extends UnitTestCase
/**
* Setup the tests.
*/
protected function setUp()
protected function setUp():void
{
parent::setUp();

Expand All @@ -42,7 +42,7 @@ protected function setUp()
/**
* Method to tear down whatever was set up before the test.
*/
protected function tearDown()
protected function tearDown():void
{
unset($this->feedFactory);

Expand Down Expand Up @@ -86,21 +86,19 @@ public function testRegisterParser()

/**
* Tests FeedFactory::registerParser()
*
* @expectedException InvalidArgumentException
*/
public function testRegisterParserWithInvalidClass()
{
$this->expectException(InvalidArgumentException::class);
$this->feedFactory->registerParser('does-not-exist', 'NotExistingClass');
}

/**
* Tests FeedFactory::registerParser()
*
* @expectedException InvalidArgumentException
*/
public function testRegisterParserWithInvalidTag()
{
$this->expectException(InvalidArgumentException::class);
$parseMock = $this->createMock(FeedParser::class);
$this->feedFactory->registerParser('42tag', get_class($parseMock));
}
Expand All @@ -127,11 +125,10 @@ public function testFetchFeedParser()

/**
* Tests FeedFactory::_fetchFeedParser()
*
* @expectedException LogicException
*/
public function testFetchFeedParserWithInvalidTag()
{
$this->expectException(\LogicException::class);
$xmlReaderMock = $this->createMock(XMLReader::class);

// Use reflection to test private method
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Libraries/Cms/Feed/FeedLinkTest.php
Expand Up @@ -27,11 +27,11 @@ class FeedLinkTest extends UnitTestCase
*
* @return void
*
* @expectedException InvalidArgumentException
* @since 3.1.4
*/
public function testConstructWithInvalidLength()
{
$this->expectException(InvalidArgumentException::class);
new FeedLink('URI', 'self', 'application/x-pdf', 'en-GB', 'My Link', 'foobar');
}
}
20 changes: 16 additions & 4 deletions tests/Unit/Libraries/Cms/Feed/FeedParserTest.php
Expand Up @@ -122,9 +122,9 @@ public function testParseDetectsUnregisteredNamespace()
$parser = new FeedParserStub($xmlReader);
$parser->parse();

$this->assertAttributeNotEmpty( 'namespaces', $parser);
$this->assertArrayHasKey($prefix, static::readAttribute($parser, 'namespaces'));
$this->assertInstanceOf(FeedParserStubUnregistered::class, static::readAttribute($parser, 'namespaces')[$prefix]);
$this->assertNotEmpty($parser->getNamespaces());
$this->assertArrayHasKey($prefix, $parser->getNamespaces());
$this->assertInstanceOf(FeedParserStubUnregistered::class, $parser->getNamespaces()[$prefix]);

// Cleanup
$xmlReader->close();
Expand Down Expand Up @@ -201,7 +201,7 @@ public function testRegisterNamespace()
$returnedParser = $parser->registerNamespace($prefix, $namespaceMock);

$this->assertInstanceOf(FeedParserStub::class, $returnedParser);
$this->assertAttributeEquals([$prefix => $namespaceMock], 'namespaces', $parser);
$this->assertEquals([$prefix => $namespaceMock], $parser->getNamespaces());
}

/**
Expand Down Expand Up @@ -445,6 +445,18 @@ public function getHandleCustomCalledWith(): array
return $this->handleCustomCalledWith;
}

/**
* Getter for the namespaces
*
* @return array
*
* @since 4.0
*/
public function getNamespaces(): array
{
return $this->namespaces;
}

/**
* Getter for the handle custom called with flag
*
Expand Down
12 changes: 6 additions & 6 deletions tests/Unit/Libraries/Cms/Feed/FeedTest.php
Expand Up @@ -38,7 +38,7 @@ class FeedTest extends UnitTestCase
*
* @since 3.1.4
*/
protected function setUp()
protected function setUp():void
{
parent::setUp();

Expand All @@ -52,7 +52,7 @@ protected function setUp()
*
* @since 3.1.4
*/
protected function tearDown()
protected function tearDown():void
{
unset($this->feed);

Expand Down Expand Up @@ -176,11 +176,11 @@ public function testSetAuthorWithPerson()
*
* @return void
*
* @expectedException InvalidArgumentException
* @since 3.1.4
*/
public function testSetAuthorWithInvalidAuthor()
{
$this->expectException(InvalidArgumentException::class);
$this->feed->author = 'Jack Sprat';
}

Expand All @@ -189,11 +189,11 @@ public function testSetAuthorWithInvalidAuthor()
*
* @return void
*
* @expectedException InvalidArgumentException
* @since 3.1.4
*/
public function testSetCategoriesWithInvalidProperty()
{
$this->expectException(InvalidArgumentException::class);
$this->feed->categories = 'Can\'t touch this';
}

Expand All @@ -202,11 +202,11 @@ public function testSetCategoriesWithInvalidProperty()
*
* @return void
*
* @expectedException InvalidArgumentException
* @since 3.1.4
*/
public function testSetContributorsWithInvalidProperty()
{
$this->expectException(InvalidArgumentException::class);
$this->feed->contributors = 'Can\'t touch this';
}

Expand Down Expand Up @@ -436,11 +436,11 @@ public function testOffsetGet()
*
* @return void
*
* @expectedException InvalidArgumentException
* @since 3.1.4
*/
public function testOffsetSetWithString()
{
$this->expectException(InvalidArgumentException::class);
$this->feed->offsetSet(1, 'My string');
}

Expand Down
8 changes: 6 additions & 2 deletions tests/Unit/Libraries/Cms/Feed/Parser/AtomParserTest.php
Expand Up @@ -324,8 +324,10 @@ public function testInitialiseSetsDefaultVersion()
$method = $reflectionClass->getMethod('initialise');
$method->setAccessible(true);
$method->invoke($atomParser);
$attribute = $reflectionClass->getProperty('version');
$attribute->setAccessible(true);

$this->assertAttributeEquals('1.0', 'version', $atomParser);
$this->assertEquals('1.0', $attribute->getValue($atomParser));
}

/**
Expand All @@ -348,8 +350,10 @@ public function testInitialiseSetsOldVersion()
$method = $reflectionClass->getMethod('initialise');
$method->setAccessible(true);
$method->invoke($atomParser);
$attribute = $reflectionClass->getProperty('version');
$attribute->setAccessible(true);

$this->assertAttributeEquals('0.3', 'version', $atomParser);
$this->assertEquals('0.3', $attribute->getValue($atomParser));
}

/**
Expand Down
4 changes: 3 additions & 1 deletion tests/Unit/Libraries/Cms/Feed/Parser/RssParserTest.php
Expand Up @@ -559,8 +559,10 @@ public function testInitialiseSetsVersion()
$method = $reflectionClass->getMethod('initialise');
$method->setAccessible(true);
$method->invoke($rssParser);
$attribute = $reflectionClass->getProperty('version');
$attribute->setAccessible(true);

$this->assertAttributeEquals($version, 'version', $rssParser);
$this->assertEquals($version, $attribute->getValue($rssParser));
}

/**
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/Libraries/Cms/Layout/BaseLayoutTest.php
Expand Up @@ -24,7 +24,7 @@ class BaseLayoutTest extends UnitTestCase
* Sets up the test by instantiating BaseLayout
* This method is called before a test is executed.
*/
protected function setUp()
protected function setUp():void
{
$this->baseLayout = new BaseLayout;

Expand All @@ -34,7 +34,7 @@ protected function setUp()
/**
* This method is called after a test is executed.
*/
protected function tearDown()
protected function tearDown():void
{
unset($this->baseLayout);

Expand Down Expand Up @@ -185,7 +185,7 @@ public function testAddDebugMessageToTheQueue()
*/
public function testRetrievingTheListOfDebugMessagesIsAnArray()
{
$this->assertInternalType('array', $this->baseLayout->getDebugMessages());
$this->assertIsArray($this->baseLayout->getDebugMessages());
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Libraries/Cms/Mail/MailTest.php
Expand Up @@ -33,7 +33,7 @@ class MailTest extends UnitTestCase
*
* @return void
*/
protected function setUp()
protected function setUp():void
{
parent::setUp();

Expand All @@ -45,7 +45,7 @@ protected function setUp()
*
* @return void
*/
protected function tearDown()
protected function tearDown():void
{
unset($this->mail);

Expand Down
11 changes: 3 additions & 8 deletions tests/Unit/Libraries/Cms/Object/CMSObjectTest.php
Expand Up @@ -167,11 +167,7 @@ public function testGetErrors()
{
$object->setError($error);
}
$this->assertAttributeEquals(
$object->getErrors(),
'_errors',
$object
);

$this->assertEquals(
$errors,
$object->getErrors(),
Expand Down Expand Up @@ -225,10 +221,9 @@ public function testSetError()
{
$object = new CMSObject;
$object->setError('A Test Error');
$this->assertAttributeEquals(
$this->assertEquals(
array('A Test Error'),
'_errors',
$object
$object->getErrors()
);
}
}
4 changes: 1 addition & 3 deletions tests/Unit/Libraries/Cms/Toolbar/ToolbarTest.php
Expand Up @@ -174,11 +174,9 @@ public function testRenderButton()
$this->assertEquals($renderedButton, $toolbar->renderButton($button));
}

/**
* @expectedException \UnexpectedValueException
*/
public function testRenderButtonThrowsUnexpectedValueException()
{
$this->expectException(\UnexpectedValueException::class);
$button = ['Separator', 'spacer'];
$toolbarFactoryMock = $this->createMock(ToolbarFactoryInterface::class);
$toolbarFactoryMock
Expand Down

0 comments on commit b752380

Please sign in to comment.