diff options
| author | Oleg Pudeyev <oleg@bsdpower.com> | 2013-05-08 08:17:39 -0400 |
|---|---|---|
| committer | Oleg Pudeyev <oleg@bsdpower.com> | 2013-05-08 08:17:39 -0400 |
| commit | 1a062c506412f4046a336701c8d4d53d45eac954 (patch) | |
| tree | b13cc239fd244e3cb4b86c4ed2d3e90792666d94 /tests/functional | |
| parent | d84617bb794229b2a93602aae99a6fd1963c3dbb (diff) | |
| parent | 54680b9709ab2288408cbb0ddc7737e93d41de18 (diff) | |
| download | forums-1a062c506412f4046a336701c8d4d53d45eac954.tar forums-1a062c506412f4046a336701c8d4d53d45eac954.tar.gz forums-1a062c506412f4046a336701c8d4d53d45eac954.tar.bz2 forums-1a062c506412f4046a336701c8d4d53d45eac954.tar.xz forums-1a062c506412f4046a336701c8d4d53d45eac954.zip | |
Merge PR #1308 branch 'nickvergessen/ticket/11450' into develop
# By Joas Schilling
# Via Joas Schilling
* nickvergessen/ticket/11450:
[ticket/11450] Limit scopes of filters and add better docs
[ticket/11450] Use helpers to copy/remove files
[ticket/11450] Move mocked class into mock/metadata_manager.php
[ticket/11450] Add new line at end of file
[ticket/11450] Fix tests class name
[ticket/11450] Require db_tools file to be included
[ticket/11450] Add test for unexisting composer.json
[ticket/11450] Test the extensions details page in ACP Customise Tab
[ticket/11450] Fix all instances of phpbb_extension_metadata_manager
[ticket/11450] Fix doc blocks and add missing class var $config
[ticket/11450] Sort parameters alphabetically
[ticket/11450] Remove unused $db and $phpEx from metadata_manager construct()
Diffstat (limited to 'tests/functional')
| -rw-r--r-- | tests/functional/fixtures/ext/foo/bar/composer.json | 23 | ||||
| -rw-r--r-- | tests/functional/metadata_manager_test.php | 111 |
2 files changed, 134 insertions, 0 deletions
diff --git a/tests/functional/fixtures/ext/foo/bar/composer.json b/tests/functional/fixtures/ext/foo/bar/composer.json new file mode 100644 index 0000000000..067a9d38eb --- /dev/null +++ b/tests/functional/fixtures/ext/foo/bar/composer.json @@ -0,0 +1,23 @@ +{ + "name": "foo/bar", + "type": "phpbb3-extension", + "description": "Testing extensions", + "homepage": "", + "version": "1.0.0", + "time": "2013-03-21 01:01:01", + "licence": "GPL-2.0", + "authors": [{ + "name": "Joas Schilling", + "username": "nickvergessen", + "email": "nickvergessen@phpbb.com", + "homepage": "http://www.phpbb.com", + "role": "Developer" + }], + "require": { + "php": ">=5.3", + "phpbb": ">=3.1.0-dev" + }, + "extra": { + "display-name": "phpBB 3.1 Extension Testing" + } +} diff --git a/tests/functional/metadata_manager_test.php b/tests/functional/metadata_manager_test.php new file mode 100644 index 0000000000..0125886e04 --- /dev/null +++ b/tests/functional/metadata_manager_test.php @@ -0,0 +1,111 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2013 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +require_once dirname(__FILE__) . '/../../phpBB/includes/db/db_tools.php'; + +/** +* @group functional +*/ +class phpbb_functional_metadata_manager_test extends phpbb_functional_test_case +{ + protected $phpbb_extension_manager; + + static private $helpers; + + static protected $fixtures = array( + 'foo/bar/', + ); + + /** + * This should only be called once before the tests are run. + * This is used to copy the fixtures to the phpBB install + */ + static public function setUpBeforeClass() + { + global $phpbb_root_path; + parent::setUpBeforeClass(); + + self::$helpers = new phpbb_test_case_helpers(self); + + if (!file_exists($phpbb_root_path . 'ext/foo/bar/')) + { + self::$helpers->makedirs($phpbb_root_path . 'ext/foo/bar/'); + } + + foreach (self::$fixtures as $fixture) + { + self::$helpers->copy_dir(dirname(__FILE__) . '/fixtures/ext/' . $fixture, $phpbb_root_path . 'ext/' . $fixture); + } + } + + /** + * This should only be called once after the tests are run. + * This is used to remove the fixtures from the phpBB install + */ + static public function tearDownAfterClass() + { + global $phpbb_root_path; + + foreach (self::$fixtures as $fixture) + { + self::$helpers->empty_dir($phpbb_root_path . 'ext/' . $fixture); + } + self::$helpers->empty_dir($phpbb_root_path . 'ext/foo/'); + } + + public function setUp() + { + parent::setUp(); + + $this->phpbb_extension_manager = $this->get_extension_manager(); + + $this->purge_cache(); + $this->phpbb_extension_manager->enable('foo/bar'); + + $this->login(); + $this->admin_login(); + $this->add_lang('acp/extensions'); + } + + public function test_extensions_list() + { + $crawler = $this->request('GET', 'adm/index.php?i=acp_extensions&mode=main&sid=' . $this->sid); + $this->assert_response_success(); + + $this->assertContains($this->lang('EXTENSIONS_EXPLAIN'), $crawler->filter('#main')->text()); + $this->assertContains('phpBB 3.1 Extension Testing', $crawler->filter('#main')->text()); + $this->assertContains('Details', $crawler->filter('#main')->text()); + } + + public function test_extensions_details() + { + $crawler = $this->request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=details&ext_name=foo%2Fbar&sid=' . $this->sid); + $this->assert_response_success(); + + // Test whether the details are displayed + $this->assertContains($this->lang('CLEAN_NAME'), $crawler->filter('#main')->text()); + $this->assertContains('foo/bar', $crawler->filter('#meta_name')->text()); + + $this->assertContains($this->lang('PHP_VERSION'), $crawler->filter('#main')->text()); + $this->assertContains('>=5.3', $crawler->filter('#require_php')->text()); + // Details should be html escaped + // However, text() only returns the displayed text, so HTML Special Chars are decoded. + // So we test this directly on the content of the response. + $this->assertContains('<p id="require_php">>=5.3</p>', $this->client->getResponse()->getContent()); + } + + public function test_extensions_details_notexists() + { + $crawler = $this->request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=details&ext_name=not%2Fexists&sid=' . $this->sid); + $this->assert_response_success(); + + // Error message because the files do not exist + $this->assertContains('The required file does not exist:', $crawler->filter('#main')->text()); + } +} |
