Răsfoiți Sursa

refactor: simplify tests

rugk 11 luni în urmă
părinte
comite
f76704a88c
1 a modificat fișierele cu 16 adăugiri și 20 ștergeri
  1. 16 20
      tst/YourlsProxyTest.php

+ 16 - 20
tst/YourlsProxyTest.php

@@ -58,15 +58,15 @@ class YourlsProxyTest extends TestCase
     }
 
     public function providerInvalidUrl() {
-        return array(
-            array(''),
-            array(' '),
-            array('foo'),
-            array('https://'),
-            array('https://example.com'), // missing path and query parameter,
-            array('https://example.com/'), // missing query parameter
-            array('https://example.com?paste=something'), // missing path parameter
-        );
+        return [
+            [''],
+            [' '],
+            ['foo'],
+            ['https://'],
+            ['https://example.com'], // missing path and query parameter,
+            ['https://example.com/'], // missing query parameter
+            ['https://example.com?paste=something'] // missing path parameter
+        ];
     }
 
     /**
@@ -81,7 +81,8 @@ class YourlsProxyTest extends TestCase
         $this->assertTrue($yourls->isError());
         $this->assertEquals($yourls->getError(), 'Trying to shorten a URL that isn\'t pointing at our instance.');
     }
-/**
+
+    /**
      * @dataProvider providerForeignUrl
      */
     public function testForeignUrl($url)
@@ -90,18 +91,13 @@ class YourlsProxyTest extends TestCase
         $this->assertTrue($yourls->isError());
         $this->assertEquals($yourls->getError(), 'Trying to shorten a URL that isn\'t pointing at our instance.');
     }
+
     public function providerForeignUrl() {
-        return array(
+        return [
             ['ftp://example.com/?n=np'], // wrong protocol
-            ['https://other.example.com/?foo#bar'] // wrong domain
-        );
-    }
-
-    public function testSneakyForeignUrl()
-    {
-        $yourls = new YourlsProxy($this->_conf, 'https://other.example.com/?q=https://example.com/?foo#bar');
-        $this->assertTrue($yourls->isError());
-        $this->assertEquals($yourls->getError(), 'Trying to shorten a URL that isn\'t pointing at our instance.');
+            ['https://other.example.com/?foo#bar'], // wrong domain
+            ['https://other.example.com/?q=https://example.com/?foo#bar'] // domain included inside string
+        ];
     }
 
     public function testYourlsError()