Skip to content

Instantly share code, notes, and snippets.

@jlainezs
Last active August 29, 2015 14:01
Show Gist options
  • Save jlainezs/9b8f88211aac8ccd786b to your computer and use it in GitHub Desktop.
Save jlainezs/9b8f88211aac8ccd786b to your computer and use it in GitHub Desktop.
Unit test configuration for the administration side of a Joomla! component
<?php
error_reporting(E_ALL);
define('_JEXEC', 1);
define('JPATH_BASE','*** where is joomla installed ? ***');
define('JOOMLA_ADMIN', JPATH_BASE . 'administrator'); // want to test admin side
$_SERVER['HTTP_HOST'] = 'localhost';
$_SERVER['REQUEST_METHOD'] = 'GET';
include_once JOOMLA_ADMIN . '/includes/defines.php';
require_once JPATH_ADMINISTRATOR . '/includes/framework.php';
$app = JFactory::getApplication('administrator');
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="bootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
verbose="true">
</phpunit>
<?php
class SampleTest extends \PHPUnit_Framework_TestCase {
public function thisIsASample(){
JModelLegacy::addIncludePath("*** WHERE TO LOOK FOR MODELS? **** ");
$model = JModelLegacy::getInstance('*** A MODEL ***','*** THE PREFIX ***');
$someVar = $model->someMethod();
$this->assertNotEmpty($someVar);
}
}
@jlainezs
Copy link
Author

Execute using:

$ phpunit .

(Note the DOT at the end of line)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment