unfold url tests
authorMichael Wallner <mike@php.net>
Wed, 9 Jul 2014 14:42:24 +0000 (16:42 +0200)
committerMichael Wallner <mike@php.net>
Wed, 9 Jul 2014 14:42:24 +0000 (16:42 +0200)
phpunit/UrlTest.php [deleted file]
tests/url002.phpt [new file with mode: 0644]
tests/url003.phpt [new file with mode: 0644]
tests/url004.phpt [new file with mode: 0644]
tests/url005.phpt [new file with mode: 0644]

diff --git a/phpunit/UrlTest.php b/phpunit/UrlTest.php
deleted file mode 100644 (file)
index dcf3b4f..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-<?php
-
-class UrlTest extends PHPUnit_Framework_TestCase {
-       protected $url; 
-       function setUp() {
-               $this->url = "http://user:pass@www.example.com:8080/path/file.ext".
-                       "?foo=bar&more[]=1&more[]=2#hash";
-    }
-
-       function testStandard() {
-               $this->assertEquals($this->url, (string) new http\Url($this->url));
-               
-               $url = new http\Url($this->url, 
-                       array("path" => "changed", "query" => "foo=&added=this"), 
-                       http\Url::JOIN_PATH |
-                       http\Url::JOIN_QUERY |
-                       http\Url::STRIP_AUTH |
-                       http\Url::STRIP_FRAGMENT
-               );
-
-               $this->assertEquals("http", $url->scheme);
-               $this->assertEmpty($url->user);
-               $this->assertEmpty($url->pass);
-               $this->assertEquals("www.example.com", $url->host);
-               $this->assertEquals(8080, $url->port);
-               $this->assertEquals("/path/changed", $url->path);
-               $this->assertEquals("more%5B0%5D=1&more%5B1%5D=2&added=this", $url->query);
-        $this->assertEmpty($url->fragment);
-    }
-
-    function testMod() {
-        $tmp = new http\Url($this->url);
-        $mod = $tmp->mod(array("query" => "set=1"), http\Url::REPLACE);
-        $this->assertNotEquals($tmp->toArray(), $mod->toArray());
-        $this->assertEquals("set=1", $mod->query);
-        $this->assertEquals("new_fragment", $tmp->mod("#new_fragment")->fragment);
-    }
-
-    function testStrings() {
-        $url = new http\Url($this->url);
-        $this->assertEquals((string) $url, (string) new http\Url((string) $url));
-    }
-
-    function testArrays() {
-        $url = new http\Url($this->url);
-               $url2 = new http\Url($url->toArray());
-        $this->assertEquals($url->toArray(), $url2->toArray());
-    }
-}
diff --git a/tests/url002.phpt b/tests/url002.phpt
new file mode 100644 (file)
index 0000000..2b31ee9
--- /dev/null
@@ -0,0 +1,45 @@
+--TEST--
+url properties
+--SKIPIF--
+<?php
+include "skipif";
+?>
+--FILE--
+<?php
+echo "Test\n";
+$u = "http://user:pass@www.example.com:8080/path/file.ext".
+                       "?foo=bar&more[]=1&more[]=2#hash";
+
+var_dump($u === (string) new http\Url($u));
+
+$url = new http\Url($u, 
+       array("path" => "changed", "query" => "foo=&added=this"), 
+       http\Url::JOIN_PATH |
+       http\Url::JOIN_QUERY |
+       http\Url::STRIP_AUTH |
+       http\Url::STRIP_FRAGMENT
+);
+
+var_dump($url->scheme);
+var_dump($url->user);
+var_dump($url->pass);
+var_dump($url->host);
+var_dump($url->port);
+var_dump($url->path);
+var_dump($url->query);
+var_dump($url->fragment);
+
+?>
+DONE
+--EXPECT--
+Test
+bool(true)
+string(4) "http"
+NULL
+NULL
+string(15) "www.example.com"
+int(8080)
+string(13) "/path/changed"
+string(38) "more%5B0%5D=1&more%5B1%5D=2&added=this"
+NULL
+DONE
diff --git a/tests/url003.phpt b/tests/url003.phpt
new file mode 100644 (file)
index 0000000..b2def7f
--- /dev/null
@@ -0,0 +1,27 @@
+--TEST--
+url modification
+--SKIPIF--
+<?php
+include "skipif.inc";
+?>
+--FILE--
+<?php
+echo "Test\n";
+
+$u = "http://user:pass@www.example.com:8080/path/file.ext".
+                       "?foo=bar&more[]=1&more[]=2#hash";
+
+$tmp = new http\Url($u);
+$mod = $tmp->mod(array("query" => "set=1"), http\Url::REPLACE);
+var_dump($tmp->toArray() != $mod->toArray());
+var_dump("set=1" === $mod->query);
+var_dump("new_fragment" === $tmp->mod("#new_fragment")->fragment);
+
+?>
+DONE
+--EXPECT--
+Test
+bool(true)
+bool(true)
+bool(true)
+DONE
diff --git a/tests/url004.phpt b/tests/url004.phpt
new file mode 100644 (file)
index 0000000..c3055da
--- /dev/null
@@ -0,0 +1,22 @@
+--TEST--
+url as string
+--SKIPIF--
+<?php
+include "skipif.inc";
+?>
+--FILE--
+<?php
+echo "Test\n";
+
+$u = "http://user:pass@www.example.com:8080/path/file.ext".
+                       "?foo=bar&more[]=1&more[]=2#hash";
+
+$url = new http\Url($u);
+var_dump((string) $url == (string) new http\Url((string) $url));
+
+?>
+DONE
+--EXPECT--
+Test
+bool(true)
+DONE
diff --git a/tests/url005.phpt b/tests/url005.phpt
new file mode 100644 (file)
index 0000000..f9b6965
--- /dev/null
@@ -0,0 +1,22 @@
+--TEST--
+url as array
+--SKIPIF--
+<?php
+include "skipif.inc";
+?>
+--FILE--
+<?php
+echo "Test\n";
+
+$u = "http://user:pass@www.example.com:8080/path/file.ext".
+                       "?foo=bar&more[]=1&more[]=2#hash";
+
+$url = new http\Url($u);
+$url2 = new http\Url($url->toArray());
+var_dump($url->toArray() === $url2->toArray());
+?>
+DONE
+--EXPECT--
+Test
+bool(true)
+DONE