svn: /pear/pear-core/trunk/tests/PEAR_PackageFile_v2_Validator/ test_analyzeSourceCode.phpt test_analyzeSourceCode_test1.phpt test_analyzeSourceCode_test2.phpt test_analyzeSourceCode_test3.phpt test_analyzeSourceCode_test4.phpt test_analyzeSourceCode_test5.phpt
[email protected] (Helgi Þormar Þorbjörnsson) Sun, 27 Feb 2011 17:38:12 +0000
| Newsgroups | php.pear.cvs,php.pear.core |
|---|---|
| Message-ID | <[email protected]> |
dufuz Sun, 27 Feb 2011 17:38:12 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=308725
Log:
Split the analyzeSoureCode tests into multiple tests.
Changed paths:
D pear/pear-core/trunk/tests/PEAR_PackageFile_v2_Validator/test_analyzeSourceCode.phpt
A pear/pear-core/trunk/tests/PEAR_PackageFile_v2_Validator/test_analyzeSourceCode_test1.phpt
A pear/pear-core/trunk/tests/PEAR_PackageFile_v2_Validator/test_analyzeSourceCode_test2.phpt
A pear/pear-core/trunk/tests/PEAR_PackageFile_v2_Validator/test_analyzeSourceCode_test3.phpt
A pear/pear-core/trunk/tests/PEAR_PackageFile_v2_Validator/test_analyzeSourceCode_test4.phpt
A pear/pear-core/trunk/tests/PEAR_PackageFile_v2_Validator/test_analyzeSourceCode_test5.phpt
svn-diffs-308725.txt
(text/x-diff, 12.7 KB)
Deleted: pear/pear-core/trunk/tests/PEAR_PackageFile_v2_Validator/test_analyzeSourceCode.phpt
===================================================================
--- pear/pear-core/trunk/tests/PEAR_PackageFile_v2_Validator/test_analyzeSourceCode.phpt 2011-02-27 15:12:01 UTC (rev 308724)
+++ pear/pear-core/trunk/tests/PEAR_PackageFile_v2_Validator/test_analyzeSourceCode.phpt 2011-02-27 17:38:12 UTC (rev 308725)
@@ -1,167 +0,0 @@
---TEST--
-PEAR_PackageFile_Parser_v2_Validator->analyzeSourceCode test
---SKIPIF--
-<?php
-if (!getenv('PHP_PEAR_RUNTESTS')) {
- echo 'skip';
-}
-if (!function_exists('token_get_all')) {
- echo 'skip';
-}
-?>
---FILE--
-<?php
-require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'setup.php.inc';
-
-require_once 'PEAR/PackageFile/v2/Validator.php';
-$validator = new PEAR_PackageFile_v2_Validator;
-$validator->_stack = new PEAR_ErrorStack('PEAR_PackageFile_v2', false, null);
-
-$phpunit->assertFalse($validator->analyzeSourceCode('=+"\\//452'), 'invalid filename');
-
-$testdir = $statedir;
-@mkdir($testdir);
-
-$test1 = '
-<?php
-::error();
-?>
-';
-$fp = fopen($testdir . DIRECTORY_SEPARATOR . 'test1.php', 'w');
-fwrite($fp, $test1);
-fclose($fp);
-
-$ret = $validator->analyzeSourceCode($testdir . DIRECTORY_SEPARATOR . 'test1.php');
-$phpunit->assertErrors(array(
- array('package' => 'PEAR_PackageFile_v2', 'message' =>
- 'Parser error: invalid PHP found in file "' . $testdir . DIRECTORY_SEPARATOR . 'test1.php"')),
- 'invalid php');
-$phpunit->assertFalse($ret, 'wrong return value, invalid php in file');
-unlink($testdir . DIRECTORY_SEPARATOR . 'test1.php');
-
-$test3 = '
-<?php
-class test
-{
- class test2 {
- }
-}
-?>
-';
-$fp = fopen($testdir . DIRECTORY_SEPARATOR . 'test3.php', 'w');
-fwrite($fp, $test3);
-fclose($fp);
-
-$ret = $validator->analyzeSourceCode($testdir . DIRECTORY_SEPARATOR . 'test3.php');
-$phpunit->assertErrors(array(
- array('package' => 'PEAR_PackageFile_v2', 'message' =>
- 'Parser error: invalid PHP found in file "' . $testdir . DIRECTORY_SEPARATOR . 'test3.php"')),
- 'more invalid php');
-$phpunit->assertFalse($ret, 'wrong return value, 2nd invalid PHP test');
-unlink($testdir . DIRECTORY_SEPARATOR . 'test3.php');
-
-$test4 = '
-<?php
-function test()
-{
- class test2 {
- }
-}
-?>
-';
-$fp = fopen($testdir . DIRECTORY_SEPARATOR . 'test4.php', 'w');
-fwrite($fp, $test4);
-fclose($fp);
-
-$ret = $validator->analyzeSourceCode($testdir . DIRECTORY_SEPARATOR . 'test4.php');
-$phpunit->assertErrors(array(
- array('package' => 'PEAR_PackageFile_v2', 'message' =>
- 'Parser error: invalid PHP found in file "' . $testdir . DIRECTORY_SEPARATOR . 'test4.php"')),
- '3rd invalid php');
-$phpunit->assertFalse($ret, 'wrong return value, 3rd invalid PHP test');
-unlink($testdir . DIRECTORY_SEPARATOR . 'test4.php');
-
-$test5 = '
-<?php
-function test()
-{
-}
-
-if (trytofool) {
- function fool()
- {
- }
-}
-class test2 {
- function test2() {
- parent::unused();
- Greg::classes();
- $a = new Pierre;
- }
-}
-
-class blah extends test2 {
- /**
- * @nodep Stig
- */
- function blah()
- {
- Stig::rules();
- }
-}
-?>
-';
-$fp = fopen($testdir . DIRECTORY_SEPARATOR . 'test5.php', 'w');
-fwrite($fp, $test5);
-fclose($fp);
-
-$ret = $validator->analyzeSourceCode($testdir . DIRECTORY_SEPARATOR . 'test5.php');
-$phpunit->assertNoErrors('1st valid PHP');
-$phpunit->showall();
-$phpunit->assertEquals(array (
- 'source_file' => $testdir . DIRECTORY_SEPARATOR . 'test5.php',
- 'declared_classes' =>
- array (
- 0 => 'test2',
- 1 => 'blah',
- ),
- 'declared_interfaces' =>
- array (
- ),
- 'declared_methods' =>
- array (
- 'test2' =>
- array (
- 0 => 'test2',
- ),
- 'blah' =>
- array (
- 0 => 'blah',
- ),
- ),
- 'declared_functions' =>
- array (
- 0 => 'test',
- 1 => 'fool',
- ),
- 'used_classes' =>
- array (
- 0 => 'Greg',
- 1 => 'Pierre',
- ),
- 'inheritance' =>
- array (
- 'blah' => 'test2',
- ),
- 'implements' =>
- array (
- ),
-), $ret, 'wrong return value, 1st valid PHP test');
-echo 'tests done';
-?>
---CLEAN--
-<?php
-require_once dirname(__FILE__) . '/teardown.php.inc';
-?>
---EXPECT--
-tests done
Added: pear/pear-core/trunk/tests/PEAR_PackageFile_v2_Validator/test_analyzeSourceCode_test1.phpt
===================================================================
--- pear/pear-core/trunk/tests/PEAR_PackageFile_v2_Validator/test_analyzeSourceCode_test1.phpt (rev 0)
+++ pear/pear-core/trunk/tests/PEAR_PackageFile_v2_Validator/test_analyzeSourceCode_test1.phpt 2011-02-27 17:38:12 UTC (rev 308725)
@@ -0,0 +1,29 @@
+--TEST--
+PEAR_PackageFile_Parser_v2_Validator->analyzeSourceCode test
+--SKIPIF--
+<?php
+if (!getenv('PHP_PEAR_RUNTESTS')) {
+ echo 'skip';
+}
+if (!function_exists('token_get_all')) {
+ echo 'skip';
+}
+?>
+--FILE--
+<?php
+require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'setup.php.inc';
+
+require_once 'PEAR/PackageFile/v2/Validator.php';
+$validator = new PEAR_PackageFile_v2_Validator;
+$validator->_stack = new PEAR_ErrorStack('PEAR_PackageFile_v2', false, null);
+
+$phpunit->assertFalse($validator->analyzeSourceCode('=+"\\//452'), 'invalid filename');
+
+echo 'tests done';
+?>
+--CLEAN--
+<?php
+require_once dirname(__FILE__) . '/teardown.php.inc';
+?>
+--EXPECT--
+tests done
Added: pear/pear-core/trunk/tests/PEAR_PackageFile_v2_Validator/test_analyzeSourceCode_test2.phpt
===================================================================
--- pear/pear-core/trunk/tests/PEAR_PackageFile_v2_Validator/test_analyzeSourceCode_test2.phpt (rev 0)
+++ pear/pear-core/trunk/tests/PEAR_PackageFile_v2_Validator/test_analyzeSourceCode_test2.phpt 2011-02-27 17:38:12 UTC (rev 308725)
@@ -0,0 +1,51 @@
+--TEST--
+PEAR_PackageFile_Parser_v2_Validator->analyzeSourceCode test
+--SKIPIF--
+<?php
+if (!getenv('PHP_PEAR_RUNTESTS')) {
+ echo 'skip';
+}
+if (!function_exists('token_get_all')) {
+ echo 'skip';
+}
+?>
+--FILE--
+<?php
+require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'setup.php.inc';
+
+require_once 'PEAR/PackageFile/v2/Validator.php';
+$validator = new PEAR_PackageFile_v2_Validator;
+$validator->_stack = new PEAR_ErrorStack('PEAR_PackageFile_v2', false, null);
+
+$testdir = $statedir;
+@mkdir($testdir);
+
+$test3 = '
+<?php
+class test
+{
+ class test2 {
+ }
+}
+?>
+';
+$fp = fopen($testdir . DIRECTORY_SEPARATOR . 'test3.php', 'w');
+fwrite($fp, $test3);
+fclose($fp);
+
+$ret = $validator->analyzeSourceCode($testdir . DIRECTORY_SEPARATOR . 'test3.php');
+$phpunit->assertErrors(array(
+ array('package' => 'PEAR_PackageFile_v2', 'message' =>
+ 'Parser error: invalid PHP found in file "' . $testdir . DIRECTORY_SEPARATOR . 'test3.php"')),
+ 'more invalid php');
+$phpunit->assertFalse($ret, 'wrong return value, 2nd invalid PHP test');
+unlink($testdir . DIRECTORY_SEPARATOR . 'test3.php');
+
+echo 'tests done';
+?>
+--CLEAN--
+<?php
+require_once dirname(__FILE__) . '/teardown.php.inc';
+?>
+--EXPECT--
+tests done
Added: pear/pear-core/trunk/tests/PEAR_PackageFile_v2_Validator/test_analyzeSourceCode_test3.phpt
===================================================================
--- pear/pear-core/trunk/tests/PEAR_PackageFile_v2_Validator/test_analyzeSourceCode_test3.phpt (rev 0)
+++ pear/pear-core/trunk/tests/PEAR_PackageFile_v2_Validator/test_analyzeSourceCode_test3.phpt 2011-02-27 17:38:12 UTC (rev 308725)
@@ -0,0 +1,51 @@
+--TEST--
+PEAR_PackageFile_Parser_v2_Validator->analyzeSourceCode test
+--SKIPIF--
+<?php
+if (!getenv('PHP_PEAR_RUNTESTS')) {
+ echo 'skip';
+}
+if (!function_exists('token_get_all')) {
+ echo 'skip';
+}
+?>
+--FILE--
+<?php
+require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'setup.php.inc';
+
+require_once 'PEAR/PackageFile/v2/Validator.php';
+$validator = new PEAR_PackageFile_v2_Validator;
+$validator->_stack = new PEAR_ErrorStack('PEAR_PackageFile_v2', false, null);
+
+$testdir = $statedir;
+@mkdir($testdir);
+
+$test3 = '
+<?php
+class test
+{
+ class test2 {
+ }
+}
+?>
+';
+$fp = fopen($testdir . DIRECTORY_SEPARATOR . 'test3.php', 'w');
+fwrite($fp, $test3);
+fclose($fp);
+
+$ret = $validator->analyzeSourceCode($testdir . DIRECTORY_SEPARATOR . 'test3.php');
+$phpunit->assertErrors(array(
+ array('package' => 'PEAR_PackageFile_v2', 'message' =>
+ 'Parser error: invalid PHP found in file "' . $testdir . DIRECTORY_SEPARATOR . 'test3.php"')),
+ 'more invalid php');
+$phpunit->assertFalse($ret, 'wrong return value, 2nd invalid PHP test');
+unlink($testdir . DIRECTORY_SEPARATOR . 'test3.php');
+
+echo 'tests done';
+?>
+--CLEAN--
+<?php
+require_once dirname(__FILE__) . '/teardown.php.inc';
+?>
+--EXPECT--
+tests done
Added: pear/pear-core/trunk/tests/PEAR_PackageFile_v2_Validator/test_analyzeSourceCode_test4.phpt
===================================================================
--- pear/pear-core/trunk/tests/PEAR_PackageFile_v2_Validator/test_analyzeSourceCode_test4.phpt (rev 0)
+++ pear/pear-core/trunk/tests/PEAR_PackageFile_v2_Validator/test_analyzeSourceCode_test4.phpt 2011-02-27 17:38:12 UTC (rev 308725)
@@ -0,0 +1,51 @@
+--TEST--
+PEAR_PackageFile_Parser_v2_Validator->analyzeSourceCode test
+--SKIPIF--
+<?php
+if (!getenv('PHP_PEAR_RUNTESTS')) {
+ echo 'skip';
+}
+if (!function_exists('token_get_all')) {
+ echo 'skip';
+}
+?>
+--FILE--
+<?php
+require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'setup.php.inc';
+
+require_once 'PEAR/PackageFile/v2/Validator.php';
+$validator = new PEAR_PackageFile_v2_Validator;
+$validator->_stack = new PEAR_ErrorStack('PEAR_PackageFile_v2', false, null);
+
+$testdir = $statedir;
+@mkdir($testdir);
+
+$test4 = '
+<?php
+function test()
+{
+ class test2 {
+ }
+}
+?>
+';
+$fp = fopen($testdir . DIRECTORY_SEPARATOR . 'test4.php', 'w');
+fwrite($fp, $test4);
+fclose($fp);
+
+$ret = $validator->analyzeSourceCode($testdir . DIRECTORY_SEPARATOR . 'test4.php');
+$phpunit->assertErrors(array(
+ array('package' => 'PEAR_PackageFile_v2', 'message' =>
+ 'Parser error: invalid PHP found in file "' . $testdir . DIRECTORY_SEPARATOR . 'test4.php"')),
+ '3rd invalid php');
+$phpunit->assertFalse($ret, 'wrong return value, 3rd invalid PHP test');
+unlink($testdir . DIRECTORY_SEPARATOR . 'test4.php');
+
+echo 'tests done';
+?>
+--CLEAN--
+<?php
+require_once dirname(__FILE__) . '/teardown.php.inc';
+?>
+--EXPECT--
+tests done
Added: pear/pear-core/trunk/tests/PEAR_PackageFile_v2_Validator/test_analyzeSourceCode_test5.phpt
===================================================================
--- pear/pear-core/trunk/tests/PEAR_PackageFile_v2_Validator/test_analyzeSourceCode_test5.phpt (rev 0)
+++ pear/pear-core/trunk/tests/PEAR_PackageFile_v2_Validator/test_analyzeSourceCode_test5.phpt 2011-02-27 17:38:12 UTC (rev 308725)
@@ -0,0 +1,107 @@
+--TEST--
+PEAR_PackageFile_Parser_v2_Validator->analyzeSourceCode test
+--SKIPIF--
+<?php
+if (!getenv('PHP_PEAR_RUNTESTS')) {
+ echo 'skip';
+}
+if (!function_exists('token_get_all')) {
+ echo 'skip';
+}
+?>
+--FILE--
+<?php
+require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'setup.php.inc';
+
+require_once 'PEAR/PackageFile/v2/Validator.php';
+$validator = new PEAR_PackageFile_v2_Validator;
+$validator->_stack = new PEAR_ErrorStack('PEAR_PackageFile_v2', false, null);
+
+$testdir = $statedir;
+@mkdir($testdir);
+
+$test5 = '
+<?php
+function test()
+{
+}
+
+if (trytofool) {
+ function fool()
+ {
+ }
+}
+class test2 {
+ function test2() {
+ parent::unused();
+ Greg::classes();
+ $a = new Pierre;
+ }
+}
+
+class blah extends test2 {
+ /**
+ * @nodep Stig
+ */
+ function blah()
+ {
+ Stig::rules();
+ }
+}
+?>
+';
+$fp = fopen($testdir . DIRECTORY_SEPARATOR . 'test5.php', 'w');
+fwrite($fp, $test5);
+fclose($fp);
+
+$ret = $validator->analyzeSourceCode($testdir . DIRECTORY_SEPARATOR . 'test5.php');
+$phpunit->assertNoErrors('1st valid PHP');
+$phpunit->showall();
+$phpunit->assertEquals(array (
+ 'source_file' => $testdir . DIRECTORY_SEPARATOR . 'test5.php',
+ 'declared_classes' =>
+ array (
+ 0 => 'test2',
+ 1 => 'blah',
+ ),
+ 'declared_interfaces' =>
+ array (
+ ),
+ 'declared_methods' =>
+ array (
+ 'test2' =>
+ array (
+ 0 => 'test2',
+ ),
+ 'blah' =>
+ array (
+ 0 => 'blah',
+ ),
+ ),
+ 'declared_functions' =>
+ array (
+ 0 => 'test',
+ 1 => 'fool',
+ ),
+ 'used_classes' =>
+ array (
+ 0 => 'Greg',
+ 1 => 'Pierre',
+ ),
+ 'inheritance' =>
+ array (
+ 'blah' => 'test2',
+ ),
+ 'implements' =>
+ array (
+ ),
+), $ret, 'wrong return value, 1st valid PHP test');
+
+echo 'tests done';
+?>
+--CLEAN--
+<?php
+require_once dirname(__FILE__) . '/teardown.php.inc';
+?>
+--EXPECT--
+tests done