Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add unit tests.

  • Loading branch information...
commit a46655c90f18c47dfb3c7e3c9acb344b722474bf 1 parent dd7c846
@chdemko chdemko authored realityking committed
View
44 tests/suite/joomla/application/component/JControllerTest.php
@@ -195,7 +195,49 @@ public function testExecute()
public function testGetInstance()
{
// Remove the following lines when you implement this test.
- $this->markTestIncomplete('This test has not been implemented yet.');
+ $controller = $this->getMock('JController', null, array(), '', false);
+ $className = get_class($controller);
+ $_SERVER['REQUEST_METHOD'] = 'get';
+ JRequest::setVar('format', 'json');
+ try
+ {
+ $className::getInstance('MyPrefix', array('base_path' => __DIR__ . '/_data/component1'));
+ }
+ catch (Exception $e)
+ {
+ $this->assertEquals(
+ $e->getMessage(),
+ 'JLIB_APPLICATION_ERROR_INVALID_CONTROLLER_CLASS',
+ 'Line:'.__LINE__.' File _data/component1/controller.json.php must be found.'
+ );
+ }
+ JRequest::setVar('format', 'xml');
+ try
+ {
+ $className::getInstance('MyPrefix', array('base_path' => __DIR__ . '/_data/component1'));
+ }
+ catch (Exception $e)
+ {
+ $this->assertEquals(
+ $e->getMessage(),
+ 'JLIB_APPLICATION_ERROR_INVALID_CONTROLLER',
+ 'Line:'.__LINE__.' File _data/component1/controller.xml.php and _data/component1/controller.php must not be found.'
+ );
+ }
+ JRequest::setVar('format', 'xml');
+ try
+ {
+ $className::getInstance('MyPrefix', array('base_path' => __DIR__ . '/_data/component2'));
+ }
+ catch (Exception $e)
+ {
+ $this->assertEquals(
+ $e->getMessage(),
+ 'JLIB_APPLICATION_ERROR_INVALID_CONTROLLER_CLASS',
+ 'Line:'.__LINE__.' File _data/component2/controller.php must be found.'
+ );
+ }
+ $this->markTestIncomplete('This test is not been complete yet.');
}
/**
View
0  tests/suite/joomla/application/component/_data/component1/controller.json.php
No changes.
View
0  tests/suite/joomla/application/component/_data/component2/controller.php
No changes.
Please sign in to comment.
Something went wrong with that request. Please try again.