Skip to content

Commit

Permalink
[ticket/10586] trying to get tests to work
Browse files Browse the repository at this point in the history
PHPBB3-10586
  • Loading branch information
imkingdavid committed Mar 19, 2012
1 parent 7d1e4bc commit 76e6195
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
28 changes: 16 additions & 12 deletions tests/functional/extension_controller_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*/
class phpbb_functional_extension_controller_test extends phpbb_functional_test_case
{
protected $phpbb_extension_manager;
/**
* This should only be called once before the tests are run.
* This is used to copy the fixtures to the phpBB install
Expand Down Expand Up @@ -76,17 +77,23 @@ public static function tearDownAfterClass()
// and port it into here instead of writing it from scratch
}

public function setUp()
{
parent::setUp();
$this->phpbb_extension_manager = !($this->phpbb_extension_manager instanceof phpbb_extension_manager) ? $this->get_ext_manager() : $this->phpbb_extension_manager;
$this->cache->purge('_ext');
}

/**
* Check an extension at ./ext/foobar/ which should have the class
* phpbb_ext_foobar_controller
*/
public function test_foobar()
{
$phpbb_extension_manager = $this->get_ext_manager();
$phpbb_extension_manager->enable('foobar');
$this->phpbb_extension_manager->enable('foobar');
$crawler = $this->request('GET', 'index.php?ext=foobar');
$this->assertContains("This is for testing purposes.", $crawler->filter('#page-body')->text());
$phpbb_extension_manager->purge('foobar');
$this->phpbb_extension_manager->purge('foobar');
}

/**
Expand All @@ -95,11 +102,10 @@ public function test_foobar()
*/
public function test_foo_bar()
{
$phpbb_extension_manager = $this->get_ext_manager();
$phpbb_extension_manager->enable('foo/bar');
$this->phpbb_extension_manager->enable('foo/bar');
$crawler = $this->request('GET', 'index.php?ext=foo/bar');
$this->assertContains("This is for testing purposes.", $crawler->filter('#page-body')->text());
$phpbb_extension_manager->purge('foo/bar');
$this->phpbb_extension_manager->purge('foo/bar');
}

/**
Expand All @@ -108,11 +114,10 @@ public function test_foo_bar()
*/
public function test_error_class_name()
{
$phpbb_extension_manager = $this->get_ext_manager();
$phpbb_extension_manager->enable('error/class');
$this->phpbb_extension_manager->enable('error/class');
$crawler = $this->request('GET', 'index.php?ext=error/class');
$this->assertContains("The extension error/class is missing a controller class and cannot be accessed through the front-end.", $crawler->filter('#message')->text());
$phpbb_extension_manager->purge('error/class');
$this->phpbb_extension_manager->purge('error/class');
}

/**
Expand All @@ -121,11 +126,10 @@ public function test_error_class_name()
*/
public function test_error_class_type()
{
$phpbb_extension_manager = $this->get_ext_manager();
$phpbb_extension_manager->enable('error/classtype');
$this->phpbb_extension_manager->enable('error/classtype');
$crawler = $this->request('GET', 'index.php?ext=error/classtype');
$this->assertContains("The extension controller class phpbb_ext_error_classtype_controller is not an instance of the phpbb_extension_controller_interface.", $crawler->filter('#message')->text());
$phpbb_extension_manager->purge('error/classtype');
$this->phpbb_extension_manager->purge('error/classtype');
}

/**
Expand Down
5 changes: 3 additions & 2 deletions tests/test_framework/phpbb_functional_test_case.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class phpbb_functional_test_case extends phpbb_test_case
protected $client;
protected $root_url;

protected $cache = null;
protected $db = null;

static protected $config = array();
Expand Down Expand Up @@ -88,8 +89,8 @@ protected function get_db()
protected function get_ext_manager()
{
global $phpbb_root_path, $phpEx;

return new phpbb_extension_manager($this->get_db(), self::$config['table_prefix'] . 'ext', $phpbb_root_path, ".$phpEx", new phpbb_cache_driver_file);
$this->cache = ($this->cache instanceof phpbb_cache_driver_null) ? $this->cache : new phpbb_cache_driver_null;
return new phpbb_extension_manager($this->get_db(), self::$config['table_prefix'] . 'ext', $phpbb_root_path, ".$phpEx", $this->cache);
}

protected function install_board()
Expand Down

0 comments on commit 76e6195

Please sign in to comment.