Skip to content

Commit

Permalink
Unittest improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Hackwar committed Jan 3, 2015
1 parent 2ae969b commit a4f443c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
Expand Up @@ -162,11 +162,23 @@ public function testPreprocess()
$query = array('option' => 'com_content', 'view' => 'categories', 'id' => '42', 'Itemid' => '99');
$this->object->preprocess($query);
$this->assertEquals(array('option' => 'com_content', 'view' => 'categories', 'id' => '42', 'Itemid' => '99'), $query);

// Check if a query with existing Itemid that is the current active menu-item is correctly searched
$query = array('option' => 'com_content', 'view' => 'categories', 'id' => '14', 'Itemid' => '49');
$this->object->preprocess($query);
$this->assertEquals(array('option' => 'com_content', 'view' => 'categories', 'id' => '14', 'Itemid' => '48'), $query);

// Test if the default Itemid is used if everything else fails
$router = $this->object->get('router');
$router->menu->active = null;
$query = array();
$this->object->preprocess($query);
$this->assertEquals(array('Itemid' => '47'), $query);

// Test if the correct default item is used based on the language
$query = array('lang' => 'en-GB');
$this->object->preprocess($query);
$this->assertEquals(array('lang' => 'en-GB', 'Itemid' => '51'), $query);
}

/**
Expand Down
Expand Up @@ -23,6 +23,13 @@ class MockJComponentRouterRulesMenuMenuObject
*/
protected $items = array();

/**
* Active menuitem
*
* @var integer
*/
public $active = 49;

/**
* Constructor for this object
*
Expand Down Expand Up @@ -163,7 +170,7 @@ public function getItems($attributes, $values)
*/
public function getActive()
{
return $this->items[49];
return (isset($this->items[$this->active]) ? $this->items[$this->active] : null);
}

/**
Expand All @@ -176,12 +183,12 @@ public function getActive()
*/
public function getDefault($language = '*')
{
if ($language = '*')
if ($language == '*')
{
return $this->items[47];
}

if ($language = 'en-GB')
if ($language == 'en-GB')
{
return $this->items[51];
}
Expand Down

0 comments on commit a4f443c

Please sign in to comment.