svn: /pear/pear-core/trunk/tests/ PEAR_Installer/test_bug18362.phpt System/test_parseArgs_array.phpt System/test_parseArgs_quoted.phpt

[email protected] (Helgi Þormar Þorbjörnsson) Mon, 04 Jul 2011 23:21:39 +0000
Newsgroups php.pear.cvs,php.pear.core
Message-ID <[email protected]>
--a9eb7b2998af7cde7ea4af4bb4d7757816c92546
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit

dufuz                                    Mon, 04 Jul 2011 23:21:39 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=312917

Log:
Add a test for bug #18362 and #18440 - accompanying System::_parseArgs tests

Bugs: http://pear.php.net/bugs/18362 (unknown) 
      http://pear.php.net/bugs/18440 (unknown) 
      
Changed paths:
    A   pear/pear-core/trunk/tests/PEAR_Installer/test_bug18362.phpt
    A   pear/pear-core/trunk/tests/System/test_parseArgs_array.phpt
    A   pear/pear-core/trunk/tests/System/test_parseArgs_quoted.phpt

Added: pear/pear-core/trunk/tests/PEAR_Installer/test_bug18362.phpt
===================================================================
--- pear/pear-core/trunk/tests/PEAR_Installer/test_bug18362.phpt	                        (rev 0)
+++ pear/pear-core/trunk/tests/PEAR_Installer/test_bug18362.phpt	2011-07-04 23:21:39 UTC (rev 312917)
@@ -0,0 +1,38 @@
+--TEST--
+Bug #18362: A whitespace TEMP_DIR path breaks install/upgrade functionality
+--SKIPIF--
+<?php
+if (!getenv('PHP_PEAR_RUNTESTS')) {
+    echo 'skip';
+}
+?>
+--FILE--
+<?php
+require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'setup.php.inc';
+
+$path = $config->get('temp_dir') . DIRECTORY_SEPARATOR . 'spaced tmp dir';
+mkdir($path);
+$config->set('temp_dir', $path);
+
+$c1 = dirname(__FILE__)  . DIRECTORY_SEPARATOR . 'packages'. DIRECTORY_SEPARATOR . 'Foobar-1.4.0a1.tgz';
+$dp = &new test_PEAR_Downloader($fakelog, array(), $config);
+$phpunit->assertNoErrors('after create');
+$result = $dp->download(array($c1));
+
+$installer->sortPackagesForInstall($result);
+$installer->setDownloadedPackages($result);
+$phpunit->assertNoErrors('set of downloaded packages');
+$installer->setOptions($dp->getOptions());
+$phpunit->assertEquals($fakelog->getLog(), array(), 'Problem creating spaced tmp directory');
+
+$ret = $installer->install($result[0], $dp->getOptions());
+$phpunit->assertNoErrors('after install');
+
+echo 'tests done';
+?>
+--CLEAN--
+<?php
+require_once dirname(__FILE__) . '/teardown.php.inc';
+?>
+--EXPECT--
+tests done

Added: pear/pear-core/trunk/tests/System/test_parseArgs_array.phpt
===================================================================
--- pear/pear-core/trunk/tests/System/test_parseArgs_array.phpt	                        (rev 0)
+++ pear/pear-core/trunk/tests/System/test_parseArgs_array.phpt	2011-07-04 23:21:39 UTC (rev 312917)
@@ -0,0 +1,69 @@
+--TEST--
+System::_parseArgs with quoted values
+--SKIPIF--
+<?php
+if (!getenv('PHP_PEAR_RUNTESTS')) {
+    echo 'skip ';
+}
+?>
+--FILE--
+<?php
+error_reporting(1803);
+require_once 'System.php';
+
+$opts = System::_parseArgs(array('-t R:\applications\PHP 5.3\tmp', '-d', 'pear'), 't:d');
+var_dump($opts);
+
+$opts = System::_parseArgs(array('-t /tmp/pear install/temp', '-d', 'pear'), 't:d');
+var_dump($opts);
+
+?>
+--EXPECT--
+array(2) {
+  [0]=>
+  array(2) {
+    [0]=>
+    array(2) {
+      [0]=>
+      string(1) "t"
+      [1]=>
+      string(28) " R:\applications\PHP 5.3\tmp"
+    }
+    [1]=>
+    array(2) {
+      [0]=>
+      string(1) "d"
+      [1]=>
+      NULL
+    }
+  }
+  [1]=>
+  array(1) {
+    [0]=>
+    string(4) "pear"
+  }
+}
+array(2) {
+  [0]=>
+  array(2) {
+    [0]=>
+    array(2) {
+      [0]=>
+      string(1) "t"
+      [1]=>
+      string(23) " /tmp/pear install/temp"
+    }
+    [1]=>
+    array(2) {
+      [0]=>
+      string(1) "d"
+      [1]=>
+      NULL
+    }
+  }
+  [1]=>
+  array(1) {
+    [0]=>
+    string(4) "pear"
+  }
+}
\ No newline at end of file

Added: pear/pear-core/trunk/tests/System/test_parseArgs_quoted.phpt
===================================================================
--- pear/pear-core/trunk/tests/System/test_parseArgs_quoted.phpt	                        (rev 0)
+++ pear/pear-core/trunk/tests/System/test_parseArgs_quoted.phpt	2011-07-04 23:21:39 UTC (rev 312917)
@@ -0,0 +1,127 @@
+--TEST--
+System::_parseArgs with quoted values
+--SKIPIF--
+<?php
+if (!getenv('PHP_PEAR_RUNTESTS')) {
+    echo 'skip ';
+}
+?>
+--FILE--
+<?php
+error_reporting(1803);
+require_once 'System.php';
+
+$args = '-t \'R:\applications\PHP 5.3\tmp\' -d pear';
+$opts = System::_parseArgs($args, 't:d');
+var_dump($opts);
+
+$args = '-t "R:\applications\PHP 5.3\tmp" -d pear';
+$opts = System::_parseArgs($args, 't:d');
+var_dump($opts);
+
+$args = '-t \'/tmp/pear install/temp\' -d pear';
+$opts = System::_parseArgs($args, 't:d');
+var_dump($opts);
+
+$args = '-t "/tmp/pear install/temp" -d pear';
+$opts = System::_parseArgs($args, 't:d');
+var_dump($opts);
+
+?>
+--EXPECT--
+array(2) {
+  [0]=>
+  array(2) {
+    [0]=>
+    array(2) {
+      [0]=>
+      string(1) "t"
+      [1]=>
+      string(27) "R:\applications\PHP 5.3\tmp"
+    }
+    [1]=>
+    array(2) {
+      [0]=>
+      string(1) "d"
+      [1]=>
+      NULL
+    }
+  }
+  [1]=>
+  array(1) {
+    [0]=>
+    string(4) "pear"
+  }
+}
+array(2) {
+  [0]=>
+  array(2) {
+    [0]=>
+    array(2) {
+      [0]=>
+      string(1) "t"
+      [1]=>
+      string(27) "R:\applications\PHP 5.3\tmp"
+    }
+    [1]=>
+    array(2) {
+      [0]=>
+      string(1) "d"
+      [1]=>
+      NULL
+    }
+  }
+  [1]=>
+  array(1) {
+    [0]=>
+    string(4) "pear"
+  }
+}
+array(2) {
+  [0]=>
+  array(2) {
+    [0]=>
+    array(2) {
+      [0]=>
+      string(1) "t"
+      [1]=>
+      string(22) "/tmp/pear install/temp"
+    }
+    [1]=>
+    array(2) {
+      [0]=>
+      string(1) "d"
+      [1]=>
+      NULL
+    }
+  }
+  [1]=>
+  array(1) {
+    [0]=>
+    string(4) "pear"
+  }
+}
+array(2) {
+  [0]=>
+  array(2) {
+    [0]=>
+    array(2) {
+      [0]=>
+      string(1) "t"
+      [1]=>
+      string(22) "/tmp/pear install/temp"
+    }
+    [1]=>
+    array(2) {
+      [0]=>
+      string(1) "d"
+      [1]=>
+      NULL
+    }
+  }
+  [1]=>
+  array(1) {
+    [0]=>
+    string(4) "pear"
+  }
+}
\ No newline at end of file

--a9eb7b2998af7cde7ea4af4bb4d7757816c92546--