1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-06-04 13:35:13 +02:00

Merge pull request #2673 from nickvergessen/ticket/12783

Ticket/12783 Move require:phpbb/phpbb to extra:phpbb/phpbb in Extensions composer.json files

* nickvergessen/ticket/12783:
  [ticket/12783] Move phpbb requirement to extra->soft-require
  [ticket/12783] Correctly use dataProviders and mark tests as incomplete
  [ticket/12783] Move phpbb/phpbb require version to extra
This commit is contained in:
Tristan Darricau 2014-07-03 14:23:49 +02:00
commit 0232fcc22a
7 changed files with 143 additions and 239 deletions

View File

@ -306,7 +306,7 @@ class metadata_manager
*/
public function validate_require_phpbb()
{
if (!isset($this->metadata['require']['phpbb/phpbb']))
if (!isset($this->metadata['extra']['soft-require']['phpbb/phpbb']))
{
return false;
}
@ -369,7 +369,7 @@ class metadata_manager
'META_REQUIRE_PHP' => (isset($this->metadata['require']['php'])) ? htmlspecialchars($this->metadata['require']['php']) : '',
'META_REQUIRE_PHP_FAIL' => !$this->validate_require_php(),
'META_REQUIRE_PHPBB' => (isset($this->metadata['require']['phpbb/phpbb'])) ? htmlspecialchars($this->metadata['require']['phpbb/phpbb']) : '',
'META_REQUIRE_PHPBB' => (isset($this->metadata['extra']['soft-require']['phpbb/phpbb'])) ? htmlspecialchars($this->metadata['extra']['soft-require']['phpbb/phpbb']) : '',
'META_REQUIRE_PHPBB_FAIL' => !$this->validate_require_phpbb(),
'META_DISPLAY_NAME' => (isset($this->metadata['extra']['display-name'])) ? htmlspecialchars($this->metadata['extra']['display-name']) : '',

View File

@ -13,10 +13,12 @@
"role": "N/A"
}],
"require": {
"php": ">=5.3",
"phpbb/phpbb": "3.1.*@dev"
"php": ">=5.3"
},
"extra": {
"display-name": "phpBB BarFoo Extension"
"display-name": "phpBB BarFoo Extension",
"soft-require": {
"phpbb/phpbb": "3.1.*@dev"
}
}
}

View File

@ -13,10 +13,12 @@
"role": "N/A"
}],
"require": {
"php": ">=5.3",
"phpbb/phpbb": "3.1.*@dev"
"php": ">=5.3"
},
"extra": {
"display-name": "phpBB Moo Extension"
"display-name": "phpBB Moo Extension",
"soft-require": {
"phpbb/phpbb": "3.1.*@dev"
}
}
}

View File

@ -12,10 +12,12 @@
"role": "N/A"
}],
"require": {
"php": ">=5.3",
"phpbb/phpbb": "3.1.*@dev"
"php": ">=5.3"
},
"extra": {
"display-name": "phpBB Bar Extension"
"display-name": "phpBB Bar Extension",
"soft-require": {
"phpbb/phpbb": "3.1.*@dev"
}
}
}

View File

@ -12,10 +12,12 @@
"role": "N/A"
}],
"require": {
"php": ">=5.3",
"phpbb/phpbb": "3.1.*@dev"
"php": ">=5.3"
},
"extra": {
"display-name": "phpBB Foo Extension"
"display-name": "phpBB Foo Extension",
"soft-require": {
"phpbb/phpbb": "3.1.*@dev"
}
}
}

View File

@ -19,8 +19,11 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
protected $cache;
protected $config;
protected $db;
protected $db_tools;
protected $table_prefix;
protected $phpbb_root_path;
protected $phpEx;
protected $migrator;
protected $template;
protected $user;
@ -70,7 +73,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
new \phpbb\db\migration\helper()
);
$container = new phpbb_mock_container_builder();
$container->set('migrator', $migrator);
$container->set('migrator', $this->migrator);
$this->extension_manager = new \phpbb\extension\manager(
$container,
@ -96,9 +99,10 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
{
$manager->get_metadata();
}
catch(\phpbb\extension\exception $e){}
$this->assertEquals((string) $e, $this->user->lang('FILE_NOT_FOUND', $this->phpbb_root_path . $this->extension_manager->get_extension_path($ext_name) . 'composer.json'));
catch (\phpbb\extension\exception $e)
{
$this->assertEquals((string) $e, $this->user->lang('FILE_NOT_FOUND', $this->phpbb_root_path . $this->extension_manager->get_extension_path($ext_name) . 'composer.json'));
}
}
// Should be the same as a direct json_decode of the composer.json file
@ -112,7 +116,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
{
$metadata = $manager->get_metadata();
}
catch(\phpbb\extension\exception $e)
catch (\phpbb\extension\exception $e)
{
$this->fail($e);
}
@ -122,64 +126,42 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
$this->assertEquals($metadata, $json);
}
public function test_validator_non_existant()
public function validator_non_existing_data()
{
$ext_name = 'validator';
return array(
array('name'),
array('type'),
array('license'),
array('version'),
);
}
$manager = $this->get_metadata_manager($ext_name);
// Non-existant data
/**
* @dataProvider validator_non_existing_data
*/
public function test_validator_non_existing($field_name)
{
$manager = $this->get_metadata_manager('validator');
try
{
$manager->validate('name');
$manager->validate($field_name);
$this->fail('Exception not triggered');
}
catch(\phpbb\extension\exception $e)
{
$this->assertEquals((string) $e, $this->user->lang('META_FIELD_NOT_SET', 'name'));
}
try
{
$manager->validate('type');
$this->fail('Exception not triggered');
}
catch(\phpbb\extension\exception $e)
{
$this->assertEquals((string) $e, $this->user->lang('META_FIELD_NOT_SET', 'type'));
}
try
{
$manager->validate('license');
$this->fail('Exception not triggered');
}
catch(\phpbb\extension\exception $e)
{
$this->assertEquals((string) $e, $this->user->lang('META_FIELD_NOT_SET', 'license'));
}
try
{
$manager->validate('version');
$this->fail('Exception not triggered');
}
catch(\phpbb\extension\exception $e)
{
$this->assertEquals((string) $e, $this->user->lang('META_FIELD_NOT_SET', 'version'));
$this->assertEquals((string) $e, $this->user->lang('META_FIELD_NOT_SET', $field_name));
}
}
public function test_validator_non_existing_authors()
{
$manager = $this->get_metadata_manager('validator');
try
{
$manager->validate_authors();
$this->fail('Exception not triggered');
}
catch(\phpbb\extension\exception $e)
catch (\phpbb\extension\exception $e)
{
$this->assertEquals((string) $e, $this->user->lang('META_FIELD_NOT_SET', 'authors'));
}
@ -193,72 +175,44 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
try
{
$manager->validate_authors();
$this->fail('Exception not triggered');
}
catch(\phpbb\extension\exception $e)
catch (\phpbb\extension\exception $e)
{
$this->assertEquals((string) $e, $this->user->lang('META_FIELD_NOT_SET', 'author name'));
}
}
public function test_validator_invalid()
public function validator_invalid_data()
{
$ext_name = 'validator';
return array(
array('name', 'asdf'),
array('type', 'asdf'),
array('license', ''),
array('version', ''),
);
}
$manager = $this->get_metadata_manager($ext_name);
/**
* @dataProvider validator_invalid_data
*/
public function test_validator_invalid($field_name, $field_value)
{
$manager = $this->get_metadata_manager('validator');
// Invalid data
$manager->set_metadata(array(
'name' => 'asdf',
'type' => 'asdf',
'license' => '',
'version' => '',
$field_name => $field_value,
));
try
{
$manager->validate('name');
$manager->validate($field_name);
$this->fail('Exception not triggered');
}
catch(\phpbb\extension\exception $e)
{
$this->assertEquals((string) $e, $this->user->lang('META_FIELD_INVALID', 'name'));
}
try
{
$manager->validate('type');
$this->fail('Exception not triggered');
}
catch(\phpbb\extension\exception $e)
{
$this->assertEquals((string) $e, $this->user->lang('META_FIELD_INVALID', 'type'));
}
try
{
$manager->validate('license');
$this->fail('Exception not triggered');
}
catch(\phpbb\extension\exception $e)
{
$this->assertEquals((string) $e, $this->user->lang('META_FIELD_INVALID', 'license'));
}
try
{
$manager->validate('version');
$this->fail('Exception not triggered');
}
catch(\phpbb\extension\exception $e)
{
$this->assertEquals((string) $e, $this->user->lang('META_FIELD_INVALID', 'version'));
$this->assertEquals((string) $e, $this->user->lang('META_FIELD_INVALID', $field_name));
}
}
@ -286,143 +240,83 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
}
}
public function test_validator_requirements()
public function validator_requirements_data()
{
$ext_name = 'validator';
return array(
array(
'10.0.0',
'100.2.0',
false,
false,
'Versions are not compared at the moment',
),
array(
'5.3.0',
'3.1.0-beta',
true,
true,
),
array(
'>' . phpversion(),
'>3.1.0',
false,
false,
'Versions are not compared at the moment',
),
array(
'<' . phpversion(),
'<3.1.0',
false,
false,
'Versions are not compared at the moment',
),
array(
phpversion(),
'3.1.0',
true,
true,
),
array(
'>=' . phpversion(),
'>=3.1.0',
true,
true,
),
array(
'<=' . phpversion(),
'<=3.1.0',
true,
true,
),
);
}
/**
* @dataProvider validator_requirements_data
*/
public function test_validator_requirements($php_version, $phpbb_version, $expected_php, $expected_phpbb, $incomplete_reason = '')
{
if ($incomplete_reason)
{
$this->markTestIncomplete($incomplete_reason);
}
$ext_name = 'validator';
$manager = $this->get_metadata_manager($ext_name);
// Too high of requirements
$manager->merge_metadata(array(
'require' => array(
'php' => '10.0.0',
'phpbb/phpbb' => '3.2.0', // config is set to 3.1.0
'php' => $php_version,
),
'extra' => array(
'soft-require' => array(
'phpbb/phpbb' => $phpbb_version, // config is set to 3.1.0
),
),
));
try
{
//$this->assertEquals(false, $manager->validate_require_php());
//$this->assertEquals(false, $manager->validate_require_phpbb());
}
catch(\phpbb\extension\exception $e)
{
$this->fail($e);
}
// Too high of requirements
$manager->merge_metadata(array(
'require' => array(
'php' => '5.3.0',
'phpbb/phpbb' => '3.1.0-beta', // config is set to 3.1.0
),
));
try
{
$this->assertEquals(true, $manager->validate_require_php());
$this->assertEquals(true, $manager->validate_require_phpbb());
}
catch(\phpbb\extension\exception $e)
{
$this->fail($e);
}
// Too high of requirements
$manager->merge_metadata(array(
'require' => array(
'php' => '>' . phpversion(),
'phpbb/phpbb' => '>3.1.0', // config is set to 3.1.0
),
));
try
{
//$this->assertEquals(false, $manager->validate_require_php());
//$this->assertEquals(false, $manager->validate_require_phpbb());
}
catch(\phpbb\extension\exception $e)
{
$this->fail($e);
}
// Too high of current install
$manager->merge_metadata(array(
'require' => array(
'php' => '<' . phpversion(),
'phpbb/phpbb' => '<3.1.0', // config is set to 3.1.0
),
));
try
{
//$this->assertEquals(false, $manager->validate_require_php());
//$this->assertEquals(false, $manager->validate_require_phpbb());
}
catch(\phpbb\extension\exception $e)
{
$this->fail($e);
}
// Matching requirements
$manager->merge_metadata(array(
'require' => array(
'php' => phpversion(),
'phpbb/phpbb' => '3.1.0', // config is set to 3.1.0
),
));
try
{
$this->assertEquals(true, $manager->validate_require_php());
$this->assertEquals(true, $manager->validate_require_phpbb());
}
catch(\phpbb\extension\exception $e)
{
$this->fail($e);
}
// Matching requirements
$manager->merge_metadata(array(
'require' => array(
'php' => '>=' . phpversion(),
'phpbb/phpbb' => '>=3.1.0', // config is set to 3.1.0
),
));
try
{
$this->assertEquals(true, $manager->validate_require_php());
$this->assertEquals(true, $manager->validate_require_phpbb());
}
catch(\phpbb\extension\exception $e)
{
$this->fail($e);
}
// Matching requirements
$manager->merge_metadata(array(
'require' => array(
'php' => '<=' . phpversion(),
'phpbb/phpbb' => '<=3.1.0', // config is set to 3.1.0
),
));
try
{
$this->assertEquals(true, $manager->validate_require_php());
$this->assertEquals(true, $manager->validate_require_phpbb());
}
catch(\phpbb\extension\exception $e)
{
$this->fail($e);
}
$this->assertEquals($expected_php, $manager->validate_require_php());
$this->assertEquals($expected_phpbb, $manager->validate_require_phpbb());
}
/**

View File

@ -13,10 +13,12 @@
"role": "Developer"
}],
"require": {
"php": ">=5.3",
"phpbb/phpbb": "3.1.*@dev"
"php": ">=5.3"
},
"extra": {
"display-name": "phpBB 3.1 Extension Testing"
"display-name": "phpBB 3.1 Extension Testing",
"soft-require": {
"phpbb/phpbb": "3.1.*@dev"
}
}
}