mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
[ticket/10631] Some cleanup of the test cases
The acp test case was not actually validating things correctly. Now is does PHPBB3-10631
This commit is contained in:
parent
f05a175e39
commit
a9b4f2a190
2 changed files with 109 additions and 69 deletions
|
@ -119,59 +119,40 @@ class acp_test extends phpbb_functional_test_case
|
|||
{
|
||||
$crawler = $this->request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=details&ext_name=foo&sid=' . $this->sid);
|
||||
|
||||
$validation = array(
|
||||
'DISPLAY_NAME' => 'phpBB Foo Extension',
|
||||
'CLEAN_NAME' => 'foo/example',
|
||||
'DESCRIPTION' => 'An example/sample extension to be used for testing purposes in phpBB Development.',
|
||||
'VERSION' => '1.0.0',
|
||||
'TIME' => '2012-02-15 01:01:01',
|
||||
'LICENCE' => 'GPL-2.0',
|
||||
'PHPBB_VERSION' => '3.1.0-dev',
|
||||
'PHP_VERSION' => '>=5.3',
|
||||
'AUTHOR_NAME' => 'Nathan Guse',
|
||||
'AUTHOR_EMAIL' => 'email@phpbb.com',
|
||||
'AUTHOR_HOMEPAGE' => 'http://lithiumstudios.org',
|
||||
'AUTHOR_ROLE' => 'N/A',
|
||||
);
|
||||
|
||||
for ($i = 0; $i < $crawler->filter('dl')->count(); $i++)
|
||||
{
|
||||
$text = $crawler->filter('dl')->eq($i)->text();
|
||||
|
||||
switch (true)
|
||||
$match = false;
|
||||
|
||||
foreach ($validation as $language_key => $expected)
|
||||
{
|
||||
case (strpos($text, $this->lang('DISPLAY_NAME')) === 0):
|
||||
$this->assertContains('phpBB Foo Extension', $text);
|
||||
break;
|
||||
if (strpos($text, $this->lang($language_key)) === 0)
|
||||
{
|
||||
$match = true;
|
||||
|
||||
case (strpos($text, $this->lang('CLEAN_NAME')) === 0):
|
||||
$this->assertContains('foo/example', $text);
|
||||
break;
|
||||
$this->assertContains($expected, $text);
|
||||
}
|
||||
}
|
||||
|
||||
case (strpos($text, $this->lang('DESCRIPTION')) === 0):
|
||||
$this->assertContains('An example/sample extension to be used for testing purposes in phpBB Development.', $text);
|
||||
break;
|
||||
|
||||
case (strpos($text, $this->lang('VERSION')) === 0):
|
||||
$this->assertContains('1.0.0', $text);
|
||||
break;
|
||||
|
||||
case (strpos($text, $this->lang('TIME')) === 0):
|
||||
$this->assertContains('2012-02-15 01:01:01', $text);
|
||||
break;
|
||||
|
||||
case (strpos($text, $this->lang('LICENCE')) === 0):
|
||||
$this->assertContains('GNU GPL v2', $text);
|
||||
break;
|
||||
|
||||
case (strpos($text, $this->lang('PHPBB_VERSION')) === 0):
|
||||
$this->assertContains('3.1.0-dev', $text);
|
||||
break;
|
||||
|
||||
case (strpos($text, $this->lang('PHP_VERSION')) === 0):
|
||||
$this->assertContains('>=5.3', $text);
|
||||
break;
|
||||
|
||||
case (strpos($text, $this->lang('AUTHOR_NAME')) === 0):
|
||||
$this->assertContains('Nathan Guse', $text);
|
||||
break;
|
||||
|
||||
case (strpos($text, $this->lang('AUTHOR_EMAIL')) === 0):
|
||||
$this->assertContains('email@phpbb.com', $text);
|
||||
break;
|
||||
|
||||
case (strpos($text, $this->lang('AUTHOR_HOMEPAGE')) === 0):
|
||||
$this->assertContains('http://lithiumstudios.org', $text);
|
||||
break;
|
||||
|
||||
case (strpos($text, $this->lang('AUTHOR_ROLE')) === 0):
|
||||
$this->assertContains('N/A', $text);
|
||||
break;
|
||||
if (!$match)
|
||||
{
|
||||
$this->fail('Unexpected field: "' . $text . '"');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ class metadata_manager_test extends phpbb_database_test_case
|
|||
$this->assertEquals($metadata, $json);
|
||||
}
|
||||
|
||||
public function test_validator()
|
||||
public function test_validator_non_existant()
|
||||
{
|
||||
$ext_name = 'validator';
|
||||
|
||||
|
@ -103,37 +103,57 @@ class metadata_manager_test extends phpbb_database_test_case
|
|||
try
|
||||
{
|
||||
$manager->validate('name');
|
||||
|
||||
$this->fail('Exception not triggered');
|
||||
}
|
||||
catch(phpbb_extension_exception $e)
|
||||
{
|
||||
$this->assertEquals((string) $e, 'Required meta field \'name\' has not been set.');
|
||||
}
|
||||
catch(phpbb_extension_exception $e) {}
|
||||
$this->assertEquals((string) $e, 'Required meta field \'name\' has not been set.');
|
||||
|
||||
try
|
||||
{
|
||||
$manager->validate('type');
|
||||
|
||||
$this->fail('Exception not triggered');
|
||||
}
|
||||
catch(phpbb_extension_exception $e)
|
||||
{
|
||||
$this->assertEquals((string) $e, 'Required meta field \'type\' has not been set.');
|
||||
}
|
||||
catch(phpbb_extension_exception $e) {}
|
||||
$this->assertEquals((string) $e, 'Required meta field \'type\' has not been set.');
|
||||
|
||||
try
|
||||
{
|
||||
$manager->validate('licence');
|
||||
|
||||
$this->fail('Exception not triggered');
|
||||
}
|
||||
catch(phpbb_extension_exception $e)
|
||||
{
|
||||
$this->assertEquals((string) $e, 'Required meta field \'licence\' has not been set.');
|
||||
}
|
||||
catch(phpbb_extension_exception $e) {}
|
||||
$this->assertEquals((string) $e, 'Required meta field \'licence\' has not been set.');
|
||||
|
||||
try
|
||||
{
|
||||
$manager->validate('version');
|
||||
|
||||
$this->fail('Exception not triggered');
|
||||
}
|
||||
catch(phpbb_extension_exception $e)
|
||||
{
|
||||
$this->assertEquals((string) $e, 'Required meta field \'version\' has not been set.');
|
||||
}
|
||||
catch(phpbb_extension_exception $e) {}
|
||||
$this->assertEquals((string) $e, 'Required meta field \'version\' has not been set.');
|
||||
|
||||
try
|
||||
{
|
||||
$manager->validate_authors();
|
||||
|
||||
$this->fail('Exception not triggered');
|
||||
}
|
||||
catch(phpbb_extension_exception $e)
|
||||
{
|
||||
$this->assertEquals((string) $e, 'Required meta field \'authors\' has not been set.');
|
||||
}
|
||||
catch(phpbb_extension_exception $e) {}
|
||||
$this->assertEquals((string) $e, 'Required meta field \'authors\' has not been set.');
|
||||
|
||||
$manager->merge_metadata(array(
|
||||
'authors' => array(
|
||||
|
@ -144,10 +164,21 @@ class metadata_manager_test extends phpbb_database_test_case
|
|||
try
|
||||
{
|
||||
$manager->validate_authors();
|
||||
}
|
||||
catch(phpbb_extension_exception $e) {}
|
||||
$this->assertEquals((string) $e, 'Required meta field \'author name\' has not been set.');
|
||||
|
||||
$this->fail('Exception not triggered');
|
||||
}
|
||||
catch(phpbb_extension_exception $e)
|
||||
{
|
||||
$this->assertEquals((string) $e, 'Required meta field \'author name\' has not been set.');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function test_validator_invalid()
|
||||
{
|
||||
$ext_name = 'validator';
|
||||
|
||||
$manager = $this->get_metadata_manager($ext_name);
|
||||
|
||||
// Invalid data
|
||||
$manager->set_metadata(array(
|
||||
|
@ -160,31 +191,53 @@ class metadata_manager_test extends phpbb_database_test_case
|
|||
try
|
||||
{
|
||||
$manager->validate('name');
|
||||
|
||||
$this->fail('Exception not triggered');
|
||||
}
|
||||
catch(phpbb_extension_exception $e)
|
||||
{
|
||||
$this->assertEquals((string) $e, 'Meta field \'name\' is invalid.');
|
||||
}
|
||||
catch(phpbb_extension_exception $e) {}
|
||||
$this->assertEquals((string) $e, 'Meta field \'name\' is invalid.');
|
||||
|
||||
try
|
||||
{
|
||||
$manager->validate('type');
|
||||
|
||||
$this->fail('Exception not triggered');
|
||||
}
|
||||
catch(phpbb_extension_exception $e)
|
||||
{
|
||||
$this->assertEquals((string) $e, 'Meta field \'type\' is invalid.');
|
||||
}
|
||||
catch(phpbb_extension_exception $e) {}
|
||||
$this->assertEquals((string) $e, 'Meta field \'type\' is invalid.');
|
||||
|
||||
try
|
||||
{
|
||||
$manager->validate('licence');
|
||||
|
||||
$this->fail('Exception not triggered');
|
||||
}
|
||||
catch(phpbb_extension_exception $e)
|
||||
{
|
||||
$this->assertEquals((string) $e, 'Meta field \'licence\' is invalid.');
|
||||
}
|
||||
catch(phpbb_extension_exception $e) {}
|
||||
$this->assertEquals((string) $e, 'Meta field \'licence\' is invalid.');
|
||||
|
||||
try
|
||||
{
|
||||
$manager->validate('version');
|
||||
}
|
||||
catch(phpbb_extension_exception $e) {}
|
||||
$this->assertEquals((string) $e, 'Meta field \'version\' is invalid.');
|
||||
|
||||
$this->fail('Exception not triggered');
|
||||
}
|
||||
catch(phpbb_extension_exception $e)
|
||||
{
|
||||
$this->assertEquals((string) $e, 'Meta field \'version\' is invalid.');
|
||||
}
|
||||
}
|
||||
|
||||
public function test_validator_valid()
|
||||
{
|
||||
$ext_name = 'validator';
|
||||
|
||||
$manager = $this->get_metadata_manager($ext_name);
|
||||
|
||||
// Valid data
|
||||
$manager->set_metadata(array(
|
||||
|
@ -202,8 +255,14 @@ class metadata_manager_test extends phpbb_database_test_case
|
|||
{
|
||||
$this->fail($e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function test_validator_requirements()
|
||||
{
|
||||
$ext_name = 'validator';
|
||||
|
||||
$manager = $this->get_metadata_manager($ext_name);
|
||||
// Too high of requirements
|
||||
$manager->merge_metadata(array(
|
||||
'require' => array(
|
||||
|
|
Loading…
Add table
Reference in a new issue