Browse Source

Add negative asserts

euromark 11 years ago
parent
commit
d3de877a0b

+ 1 - 1
tests/Fixture/AssertHtmlTestCase.php

@@ -4,7 +4,7 @@ namespace Cake\Test\Fixture;
 use Cake\TestSuite\TestCase;
 
 /**
- * This class helps in indirectly testing the functionalities of CakeTestCase::assertHtml
+ * This class helps in indirectly testing the functionalities of TestCase::assertHtml
  *
  */
 class AssertHtmlTestCase extends TestCase {

+ 25 - 0
tests/Fixture/AssertIntegrationTestCase.php

@@ -0,0 +1,25 @@
+<?php
+namespace Cake\Test\Fixture;
+
+use Cake\Network\Response;
+use Cake\TestSuite\IntegrationTestCase;
+
+/**
+ * This class helps in indirectly testing the functionalities of IntegrationTestCase
+ *
+ */
+class AssertIntegrationTestCase extends IntegrationTestCase {
+
+/**
+ * testBadAssertNoRedirect
+ *
+ * @return void
+ */
+	public function testBadAssertNoRedirect() {
+		$this->_response = new Response();
+		$this->_response->header('Location', 'http://localhost/tasks/index');
+
+		$this->assertNoRedirect();
+	}
+
+}

+ 14 - 0
tests/TestCase/TestSuite/IntegrationTestCaseTest.php

@@ -20,6 +20,7 @@ use Cake\Network\Response;
 use Cake\Routing\DispatcherFactory;
 use Cake\Routing\Router;
 use Cake\TestSuite\IntegrationTestCase;
+use Cake\Test\Fixture\AssertIntegrationTestCase;
 
 /**
  * Self test of the IntegrationTestCase
@@ -183,6 +184,19 @@ class IntegrationTestCaseTest extends IntegrationTestCase {
 	}
 
 /**
+ * Test the location header assertion.
+ *
+ * @return void
+ */
+	public function testAssertNoRedirectFail() {
+		$test = new AssertIntegrationTestCase('testBadAssertNoRedirect');
+		$result = $test->run();
+		ob_start();
+		$this->assertFalse($result->wasSuccessful());
+		$this->assertEquals(1, $result->failureCount());
+	}
+
+/**
  * Test the header assertion.
  *
  * @return void