Skip to content
This repository has been archived by the owner on Nov 26, 2017. It is now read-only.

Commit

Permalink
Add unit tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
chdemko authored and realityking committed Nov 21, 2011
1 parent dd7c846 commit a46655c
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
44 changes: 43 additions & 1 deletion tests/suite/joomla/application/component/JControllerTest.php
Expand Up @@ -195,7 +195,49 @@ public function testExecute()
public function testGetInstance() public function testGetInstance()
{ {
// Remove the following lines when you implement this test. // 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.');
} }


/** /**
Expand Down
Empty file.

0 comments on commit a46655c

Please sign in to comment.