2
0
Просмотр исходного кода

Merge r25204 to 1.12 release branch

git-svn-id: http://framework.zend.com/svn/framework/standard/branches/release-1.12@25205 44c647ce-9c0f-0410-b52a-842ac1e357ba
frosch 13 лет назад
Родитель
Сommit
6395715f94

+ 2 - 2
library/Zend/Test/PHPUnit/Constraint/ResponseHeader.php

@@ -347,7 +347,7 @@ class Zend_Test_PHPUnit_Constraint_ResponseHeader extends PHPUnit_Framework_Cons
 
         $contents = str_replace($header . ': ', '', $fullHeader);
 
-        return (strstr($contents, $match));
+        return (strstr($contents, $match) !== false);
     }
 
     /**
@@ -366,7 +366,7 @@ class Zend_Test_PHPUnit_Constraint_ResponseHeader extends PHPUnit_Framework_Cons
 
         $contents = str_replace($header . ': ', '', $fullHeader);
 
-        return (!strstr($contents, $match));
+        return (strstr($contents, $match) === false);
     }
 
     /**

+ 32 - 0
tests/Zend/Test/PHPUnit/ControllerTestCaseTest.php

@@ -822,6 +822,38 @@ class Zend_Test_PHPUnit_ControllerTestCaseTest extends PHPUnit_Framework_TestCas
         $this->testCase->assertRedirectTo('/login');
         $this->assertNotEquals('action body', $this->testCase->getResponse()->getBody());
     }
+
+    /**
+     * @group ZF-12492
+     * @internal Since header value is being cast into a string, we should only
+     * need to check 0 and 0.0
+     */
+    public function testHeaderAssertionShouldDoNothingForValidComparisonWithZeroForValue()
+    {
+        $this->testCase->getResponse()->setHeader('Expires', '0', true);
+        $this->testCase->assertResponseCode(200);
+        $this->testCase->assertNotResponseCode(500);
+        $this->testCase->assertHeader('Expires');
+        $this->testCase->assertNotHeader('X-Bogus');
+        $this->testCase->assertHeaderContains('Expires', '0');
+        $this->testCase->assertNotHeaderContains('Expires', 'my-bar');
+        $this->testCase->assertHeaderRegex('Expires', '#^\d#i');
+        $this->testCase->assertNotHeaderRegex(
+            'Expires', '#^[a-z-]+/[a-z-]+$#i'
+        );
+
+        $this->testCase->getResponse()->setHeader('Expires', '0.0', true);
+        $this->testCase->assertResponseCode(200);
+        $this->testCase->assertNotResponseCode(500);
+        $this->testCase->assertHeader('Expires');
+        $this->testCase->assertNotHeader('X-Bogus');
+        $this->testCase->assertHeaderContains('Expires', '0.0');
+        $this->testCase->assertNotHeaderContains('Expires', 'my-bar');
+        $this->testCase->assertHeaderRegex('Expires', '#^\d+#i');
+        $this->testCase->assertNotHeaderRegex(
+            'Expires', '#^[a-z-]+/[a-z-]+$#i'
+        );
+    }
     
     /**
      * Data provider for testRedirectWorksAsExpectedFromHookMethodsInFrontControllerPlugin