summaryrefslogtreecommitdiffstats
path: root/rescue/tree/usr
diff options
context:
space:
mode:
authorMystery Man <unknown@mandriva.org>2001-06-11 13:49:39 +0000
committerMystery Man <unknown@mandriva.org>2001-06-11 13:49:39 +0000
commit16bde8b3d7027aba56051fbf557b7735eb2ee6aa (patch)
tree0d8736af65eea4a83b8445ee8e2a6d0c951aea67 /rescue/tree/usr
parent0a121a8ecd6de894c14d60daf9da2022ec47405c (diff)
downloaddrakx-topic/rp-pppoe.tar
drakx-topic/rp-pppoe.tar.gz
drakx-topic/rp-pppoe.tar.bz2
drakx-topic/rp-pppoe.tar.xz
drakx-topic/rp-pppoe.zip
This commit was manufactured by cvs2svn to create branch 'rp-pppoe'.topic/rp-pppoe
Diffstat (limited to 'rescue/tree/usr')
-rw-r--r--rescue/tree/usr/lib/CVS.0
1 files changed, 0 insertions, 0 deletions
diff --git a/rescue/tree/usr/lib/CVS. b/rescue/tree/usr/lib/CVS.
deleted file mode 100644
index e69de29bb..000000000
--- a/rescue/tree/usr/lib/CVS.
+++ /dev/null
' href='#n221'>221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439
<?php
/**
*
* @package testing
* @copyright (c) 2011 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/

class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
{
	protected $class_loader;
	protected $extension_manager;

	protected $cache;
	protected $config;
	protected $db;
	protected $phpbb_root_path;
	protected $phpEx;
	protected $template;
	protected $user;

	public function getDataSet()
	{
		return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/extensions.xml');
	}

	protected function setUp()
	{
		parent::setUp();

		$this->cache = new phpbb_mock_cache();
		$this->config = new \phpbb\config\config(array(
			'version'		=> '3.1.0',
		));
		$this->db = $this->new_dbal();
		$this->db_tools = new \phpbb\db\tools($this->db);
		$this->phpbb_root_path = dirname(__FILE__) . '/';
		$this->phpEx = 'php';
		$this->user = new \phpbb\user();
		$this->table_prefix = 'phpbb_';

		$this->template = new \phpbb\template\twig\twig(
			new \phpbb\path_helper(
				new \phpbb\symfony_request(
					new phpbb_mock_request()
				),
				new \phpbb\filesystem(),
				$this->phpbb_root_path,
				$this->phpEx
			),
			$this->config,
			$this->user,
			new \phpbb\template\context()
		);

		$this->migrator = new \phpbb\db\migrator(
			$this->config,
			$this->db,
			$this->db_tools,
			'phpbb_migrations',
			$this->phpbb_root_path,
			'php',
			$this->table_prefix,
			array(),
			new \phpbb\db\migration\helper()
		);
		$container = new phpbb_mock_container_builder();
		$container->set('migrator', $migrator);

		$this->extension_manager = new \phpbb\extension\manager(
			$container,
			$this->db,
			$this->config,
			new \phpbb\filesystem(),
			'phpbb_ext',
			$this->phpbb_root_path,
			$this->phpEx,
			$this->cache
		);
	}

	// Should fail from missing composer.json
	public function test_bar()
	{
		$ext_name = 'vendor3/bar';

		$manager = $this->get_metadata_manager($ext_name);

		try
		{
			$manager->get_metadata();
		}
		catch(\phpbb\extension\exception $e){}

		$this->assertEquals((string) $e, 'The required file does not exist: ' . $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
	public function test_foo()
	{
		$ext_name = 'vendor2/foo';

		$manager = $this->get_metadata_manager($ext_name);

		try
		{
			$metadata = $manager->get_metadata();
		}
		catch(\phpbb\extension\exception $e)
		{
			$this->fail($e);
		}

		$json = json_decode(file_get_contents($this->phpbb_root_path . 'ext/vendor2/foo/composer.json'), true);

		$this->assertEquals($metadata, $json);
	}

	public function test_validator_non_existant()
	{
		$ext_name = 'validator';

		$manager = $this->get_metadata_manager($ext_name);

		// Non-existant data
		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.');
		}

		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.');
		}

		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.');
		}

		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.');
		}

		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.');
		}

		$manager->merge_metadata(array(
			'authors'	=> array(
				array(),
			),
		));

		try
		{
			$manager->validate_authors();

			$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(
			'name'		=> 'asdf',
			'type'		=> 'asdf',
			'licence'	=> '',
			'version'	=> '',
		));

		try
		{
			$manager->validate('name');

			$this->fail('Exception not triggered');
		}
		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.');
		}

		try
		{
			$manager->validate('licence');

			$this->fail('Exception not triggered');
		}
		catch(\phpbb\extension\exception $e)
		{
			$this->assertEquals((string) $e, 'Meta field \'licence\' is invalid.');
		}

		try
		{
			$manager->validate('version');

			$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(
			'name'		=> 'test/foo',
			'type'		=> 'phpbb-extension',
			'licence'	=> 'GPL v2',
			'version'	=> '1.0.0',
		));

		try
		{
			$this->assertEquals(true, $manager->validate('enable'));
		}
		catch(\phpbb\extension\exception $e)
		{
			$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(
				'php'		=> '10.0.0',
				'phpbb/phpbb'		=> '3.2.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 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);
		}
	}

	/**
	* Get an instance of the metadata manager
	*
	* @param string $ext_name
	* @return phpbb_mock_metadata_manager
	*/
	private function get_metadata_manager($ext_name)
	{
		return new phpbb_mock_metadata_manager(
			$ext_name,
			$this->config,
			$this->extension_manager,
			$this->template,
			$this->phpbb_root_path
		);
	}
}