Reporter = $this->getMock('CakeHtmlReporter'); } /** * tearDown * * @return void */ public function tearDown() { parent::tearDown(); unset($this->Result); unset($this->Reporter); } /** * testAssertGoodTags * * @return void */ public function testAssertTagsQuotes() { $test = new AssertTagsTestCase('testAssertTagsQuotes'); $result = $test->run(); $this->assertEquals(0, $result->errorCount()); $this->assertTrue($result->wasSuccessful()); $this->assertEquals(0, $result->failureCount()); $input = 'My link'; $pattern = array( 'a' => array('href' => '/test.html', 'class' => 'active'), 'My link', '/a' ); $this->assertTrue($test->assertTags($input, $pattern), 'Double quoted attributes %s'); $input = "My link"; $pattern = array( 'a' => array('href' => '/test.html', 'class' => 'active'), 'My link', '/a' ); $this->assertTrue($test->assertTags($input, $pattern), 'Single quoted attributes %s'); $input = "My link"; $pattern = array( 'a' => array('href' => 'preg:/.*\.html/', 'class' => 'active'), 'My link', '/a' ); $this->assertTrue($test->assertTags($input, $pattern), 'Single quoted attributes %s'); $input = "Text"; $pattern = array( 'assertTrue($test->assertTags($input, $pattern), 'Tags with no attributes'); $input = "Text"; $pattern = array( 'span' => array('class'), 'assertTrue($test->assertTags($input, $pattern), 'Test attribute presence'); } /** * testNumericValuesInExpectationForAssertTags * * @return void */ public function testNumericValuesInExpectationForAssertTags() { $test = new AssertTagsTestCase('testNumericValuesInExpectationForAssertTags'); $result = $test->run(); $this->assertEquals(0, $result->errorCount()); $this->assertTrue($result->wasSuccessful()); $this->assertEquals(0, $result->failureCount()); } /** * testBadAssertTags * * @return void */ public function testBadAssertTags() { $test = new AssertTagsTestCase('testBadAssertTags'); $result = $test->run(); $this->assertEquals(0, $result->errorCount()); $this->assertFalse($result->wasSuccessful()); $this->assertEquals(1, $result->failureCount()); $test = new AssertTagsTestCase('testBadAssertTags2'); $result = $test->run(); $this->assertEquals(0, $result->errorCount()); $this->assertFalse($result->wasSuccessful()); $this->assertEquals(1, $result->failureCount()); } /** * testLoadFixtures * * @return void */ public function testLoadFixtures() { $test = new FixturizedTestCase('testFixturePresent'); $manager = $this->getMock('CakeFixtureManager'); $manager->fixturize($test); $test->fixtureManager = $manager; $manager->expects($this->once())->method('load'); $manager->expects($this->once())->method('unload'); $result = $test->run(); $this->assertEquals(0, $result->errorCount()); $this->assertTrue($result->wasSuccessful()); $this->assertEquals(0, $result->failureCount()); } /** * testLoadFixturesOnDemand * * @return void */ public function testLoadFixturesOnDemand() { $test = new FixturizedTestCase('testFixtureLoadOnDemand'); $test->autoFixtures = false; $manager = $this->getMock('CakeFixtureManager'); $manager->fixturize($test); $test->fixtureManager = $manager; $manager->expects($this->once())->method('loadSingle'); $result = $test->run(); $this->assertEquals(0, $result->errorCount()); } /** * testLoadFixturesOnDemand * * @return void */ public function testUnoadFixturesAfterFailure() { $test = new FixturizedTestCase('testFixtureLoadOnDemand'); $test->autoFixtures = false; $manager = $this->getMock('CakeFixtureManager'); $manager->fixturize($test); $test->fixtureManager = $manager; $manager->expects($this->once())->method('loadSingle'); $result = $test->run(); $this->assertEquals(0, $result->errorCount()); } /** * testThrowException * * @return void */ public function testThrowException() { $test = new FixturizedTestCase('testThrowException'); $test->autoFixtures = false; $manager = $this->getMock('CakeFixtureManager'); $manager->fixturize($test); $test->fixtureManager = $manager; $manager->expects($this->once())->method('unload'); $result = $test->run(); $this->assertEquals(1, $result->errorCount()); } /** * testSkipIf * * @return void */ public function testSkipIf() { $test = new FixturizedTestCase('testSkipIfTrue'); $result = $test->run(); $this->assertEquals(1, $result->skippedCount()); $test = new FixturizedTestCase('testSkipIfFalse'); $result = $test->run(); $this->assertEquals(0, $result->skippedCount()); } /** * Test that CakeTestCase::setUp() backs up values. * * @return void */ public function testSetupBackUpValues() { $this->assertArrayHasKey('debug', $this->_configure); $this->assertArrayHasKey('Plugin', $this->_pathRestore); } /** * test assertTextNotEquals() * * @return void */ public function testAssertTextNotEquals() { $one = "\r\nOne\rTwooo"; $two = "\nOne\nTwo"; $this->assertTextNotEquals($one, $two); } /** * test assertTextEquals() * * @return void */ public function testAssertTextEquals() { $one = "\r\nOne\rTwo"; $two = "\nOne\nTwo"; $this->assertTextEquals($one, $two); } /** * test assertTextStartsWith() * * @return void */ public function testAssertTextStartsWith() { $stringDirty = "some\nstring\r\nwith\rdifferent\nline endings!"; $stringClean = "some\nstring\nwith\ndifferent\nline endings!"; $this->assertStringStartsWith("some\nstring", $stringDirty); $this->assertStringStartsNotWith("some\r\nstring\r\nwith", $stringDirty); $this->assertStringStartsNotWith("some\nstring\nwith", $stringDirty); $this->assertTextStartsWith("some\nstring\nwith", $stringDirty); $this->assertTextStartsWith("some\r\nstring\r\nwith", $stringDirty); } /** * test assertTextStartsNotWith() * * @return void */ public function testAssertTextStartsNotWith() { $stringDirty = "some\nstring\r\nwith\rdifferent\nline endings!"; $stringClean = "some\nstring\nwith\ndifferent\nline endings!"; $this->assertTextStartsNotWith("some\nstring\nwithout", $stringDirty); } /** * test assertTextEndsWith() * * @return void */ public function testAssertTextEndsWith() { $stringDirty = "some\nstring\r\nwith\rdifferent\nline endings!"; $stringClean = "some\nstring\nwith\ndifferent\nline endings!"; $this->assertTextEndsWith("string\nwith\r\ndifferent\rline endings!", $stringDirty); $this->assertTextEndsWith("string\r\nwith\ndifferent\nline endings!", $stringDirty); } /** * test assertTextEndsNotWith() * * @return void */ public function testAssertTextEndsNotWith() { $stringDirty = "some\nstring\r\nwith\rdifferent\nline endings!"; $stringClean = "some\nstring\nwith\ndifferent\nline endings!"; $this->assertStringEndsNotWith("different\nline endings", $stringDirty); $this->assertTextEndsNotWith("different\rline endings", $stringDirty); } /** * test assertTextContains() * * @return void */ public function testAssertTextContains() { $stringDirty = "some\nstring\r\nwith\rdifferent\nline endings!"; $stringClean = "some\nstring\nwith\ndifferent\nline endings!"; $this->assertContains("different", $stringDirty); $this->assertNotContains("different\rline", $stringDirty); $this->assertTextContains("different\rline", $stringDirty); } /** * test assertTextNotContains() * * @return void */ public function testAssertTextNotContains() { $stringDirty = "some\nstring\r\nwith\rdifferent\nline endings!"; $stringClean = "some\nstring\nwith\ndifferent\nline endings!"; $this->assertTextNotContains("different\rlines", $stringDirty); } }