Permalink
Browse files

upgrade PHPUnit require statements (#19159)

git-svn-id: http://svn.php.net/repository/pear/packages/Payment_DTA/trunk@321535 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
1 parent c274829 commit 287af25b00052a02f5b41e17e2eb68305b6fc480 @mschuett mschuett committed Dec 29, 2011
Showing with 40 additions and 19 deletions.
  1. +3 −0 package.xml
  2. +12 −4 tests/AllTests.php
  3. +2 −5 tests/DTABaseTest.php
  4. +2 −5 tests/DTATest.php
  5. +2 −5 tests/DTAZVTest.php
  6. +19 −0 tests/helper.inc
View
@@ -85,6 +85,9 @@
<file baseinstalldir="Payment" md5sum="8181fc7a6404c7db18a6f0b3c5ac0e8a" name="tests/DTABaseTest.php" role="test" />
<file baseinstalldir="Payment" md5sum="d868fd034d18f5675cccd8341a80ba0e" name="tests/DTATest.php" role="test" />
<file baseinstalldir="Payment" md5sum="d7dfa58def53b11c8028d01592cebffb" name="tests/DTAZVTest.php" role="test" />
+ <file baseinstalldir="Payment" name="tests/helper.inc" role="test">
+ <tasks:replace from="@php_dir@" to="php_dir" type="pear-config" />
+ </file>
<file baseinstalldir="Payment" md5sum="50505cb3e53732d2edaf91b80c195b20" name="DTA.php" role="php">
<tasks:replace from="@package_version@" to="version" type="package-info" />
</file>
View
@@ -1,9 +1,17 @@
<?php
-if (!defined('PHPUnit_MAIN_METHOD')) {
- define('PHPUnit_MAIN_METHOD', 'Payment_DTA_AllTests::main');
+
+// Keep tests from running twice when calling this file directly via PHPUnit.
+$call_main = false;
+if (strpos($_SERVER['argv'][0], 'phpunit') === false) {
+ // Called via php, not PHPUnit. Pass the request to PHPUnit.
+ if (!defined('PHPUnit_MAIN_METHOD')) {
+ /** The test's main method name */
+ define('PHPUnit_MAIN_METHOD', 'Payment_DTA_AllTests::main');
+ $call_main = true;
+ }
}
-require_once 'PHPUnit/TextUI/TestRunner.php';
+require_once dirname(__FILE__) . '/helper.inc';
require_once 'DTABaseTest.php';
require_once 'DTATest.php';
@@ -30,6 +38,6 @@ public static function suite()
}
// exec test suite
-if (PHPUnit_MAIN_METHOD == 'Payment_DTA_AllTests::main') {
+if ($call_main) {
Payment_DTA_AllTests::main();
}
@@ -1,9 +1,6 @@
<?php
-require_once 'PHPUnit/Framework.php';
-
-//make cvs testing work
-chdir(dirname(__FILE__) . '/../');
+require_once dirname(__FILE__) . '/helper.inc';
require_once 'DTABase.php';
/*
@@ -93,4 +90,4 @@ public function testGetStrInvalid()
$rc = $this->fixture->getStr($input, $offset, $length);
}
-}
+}
View
@@ -1,8 +1,6 @@
<?php
-require_once 'PHPUnit/Framework.php';
-//make cvs testing work
-chdir(dirname(__FILE__) . '/../');
+require_once dirname(__FILE__) . '/helper.inc';
require_once 'DTA.php';
class DTATest extends PHPUnit_Framework_TestCase
@@ -1012,8 +1010,7 @@ public function testIteratorElements()
$this->assertSame(strtoupper("A Receivers Name"), $value['receiver_name']);
$this->assertSame("16050000", $value['receiver_bank_code']);
$this->assertSame("3503007767", $value['receiver_account_number']);
- $this->assertType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY,
- $value['purposes']);
+ $this->assertInternalType('array', $value['purposes']);
// different values in addExchange() above
if ($key === 0) {
View
@@ -1,8 +1,6 @@
<?php
-require_once 'PHPUnit/Framework.php';
-//make cvs testing work
-chdir(dirname(__FILE__) . '/../');
+require_once dirname(__FILE__) . '/helper.inc';
require_once 'DTAZV.php';
class DTAZVTest extends PHPUnit_Framework_TestCase
@@ -699,8 +697,7 @@ public function testIteratorElements()
$this->assertSame(strtoupper("A Receivers Name"), $value['receiver_name']);
$this->assertSame("RZTIAT22263", $value['receiver_bank_code']);
$this->assertSame("DE21700519950000007229", $value['receiver_account_number']);
- $this->assertType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY,
- $value['purposes']);
+ $this->assertInternalType('array', $value['purposes']);
// different values in addExchange() above
if ($key === 0) {
View
@@ -0,0 +1,19 @@
+<?php
+
+if ($fp = @fopen('PHPUnit/Autoload.php', 'r', true)) {
+ require_once 'PHPUnit/Autoload.php';
+} elseif ($fp = @fopen('PHPUnit/Framework.php', 'r', true)) {
+ require_once 'PHPUnit/Framework.php';
+ require_once 'PHPUnit/TextUI/TestRunner.php';
+} else {
+ die('skip could not find PHPUnit');
+}
+fclose($fp);
+
+if ('@php_dir@' == '@'.'php_dir'.'@') {
+ // This package hasn't been installed.
+ // Adjust path to ensure includes find files in working directory.
+ set_include_path(dirname(dirname(__FILE__))
+ . PATH_SEPARATOR . dirname(__FILE__)
+ . PATH_SEPARATOR . get_include_path());
+}

0 comments on commit 287af25

Please sign in to comment.