1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
|
--TEST--
PEAR_PackageFile_Parser_v2->setPackage()
--SKIPIF--
<?php
if (!getenv('PHP_PEAR_RUNTESTS')) {
echo 'skip';
}
?>
--FILE--
<?php
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'setup.php.inc';
$pathtopackagexml = dirname(__FILE__) . DIRECTORY_SEPARATOR .
'Parser'. DIRECTORY_SEPARATOR .
'test_basicparse'. DIRECTORY_SEPARATOR . 'package2.xml';
$pf = $parser->parse(implode('', file($pathtopackagexml)), $pathtopackagexml);
$pfa = &$pf->getRW();
$pf = &$pfa;
$pf->flattenFilelist();
$phpunit->assertNoErrors('valid xml parse');
$phpunit->assertIsa('PEAR_PackageFile_v2', $pf, 'return of valid parse');
$phpunit->assertEquals('test', $pf->getName(), 'pre-set alias');
$phpunit->assertEquals('test', $pf->getPackage(), 'pre-set');
$pf->setPackage('hello');
$phpunit->assertEquals('hello', $pf->getName(), 'set alias failed');
$phpunit->assertEquals('hello', $pf->getPackage(), 'set failed');
$result = $pf->validate(PEAR_VALIDATE_NORMAL);
$phpunit->assertEquals(array(), $fakelog->getLog(), 'normal validate empty log');
$phpunit->assertNoErrors('after validation');
$result = $pf->validate(PEAR_VALIDATE_INSTALLING);
$phpunit->assertEquals(array(), $fakelog->getLog(), 'installing validate empty log');
$phpunit->assertNoErrors('after validation');
$result = $pf->validate(PEAR_VALIDATE_DOWNLOADING);
$phpunit->assertEquals(array(), $fakelog->getLog(), 'downloading validate empty log');
$phpunit->assertNoErrors('after validation');
$result = $pf->validate(PEAR_VALIDATE_PACKAGING);
$phpunit->assertErrors(array(
array('package' => 'PEAR_PackageFile_v2', 'message' => 'Channel validator warning: field "date" - Release Date "2004-10-10" is not today')
), 'after full packaging validation');
$phpunit->assertEquals(array (
0 =>
array (
0 => 1,
1 => 'Analyzing test/test.php',
),
1 =>
array (
0 => 1,
1 => 'Analyzing test/test2.php',
),
2 =>
array (
0 => 1,
1 => 'Analyzing test/test3.php',
),
), $fakelog->getLog(), 'packaging validate full log');
$pf2 = new PEAR_PackageFile_v2_rw;
$pf2->setPackage('bye');
$phpunit->assertEquals('bye', $pf2->getName(), 'set alias failed 2');
$phpunit->assertEquals('bye', $pf2->getPackage(), 'set failed 2');
$phpunit->assertEquals(array (
'name' => 'bye',
'attribs' =>
array (
'version' => '2.0',
'xmlns' => 'http://pear.php.net/dtd/package-2.0',
'xmlns:tasks' => 'http://pear.php.net/dtd/tasks-1.0',
'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
'xsi:schemaLocation' => 'http://pear.php.net/dtd/tasks-1.0
http://pear.php.net/dtd/tasks-1.0.xsd
http://pear.php.net/dtd/package-2.0
http://pear.php.net/dtd/package-2.0.xsd',
),
), $pf2->getArray(), 'verify atts');
echo 'tests done';
?>
--CLEAN--
<?php
require_once dirname(__FILE__) . '/teardown.php.inc';
?>
--EXPECT--
tests done
|