From 7f34b91d61b220d3757ee2bb7a3d2309a462ece8 Mon Sep 17 00:00:00 2001 From: Maks3w Date: Fri, 1 May 2015 10:05:06 +0200 Subject: [PATCH 1/5] [test] Replace assertTrue(file_exists) with assertFileExists --- test/Compress/RarTest.php | 10 +++++----- test/Compress/ZipTest.php | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/test/Compress/RarTest.php b/test/Compress/RarTest.php index b5b76a33..4772d0df 100644 --- a/test/Compress/RarTest.php +++ b/test/Compress/RarTest.php @@ -265,11 +265,11 @@ public function testRarCompressDirectory() $base = dirname(__DIR__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . '_compress' . DIRECTORY_SEPARATOR . 'Compress' . DIRECTORY_SEPARATOR; - $this->assertTrue(file_exists($base)); - $this->assertTrue(file_exists($base . 'zipextracted.txt')); - $this->assertTrue(file_exists($base . 'First' . DIRECTORY_SEPARATOR . 'zipextracted.txt')); - $this->assertTrue(file_exists($base . 'First' . DIRECTORY_SEPARATOR . - 'Second' . DIRECTORY_SEPARATOR . 'zipextracted.txt')); + $this->assertFileExists($base); + $this->assertFileExists($base . 'zipextracted.txt'); + $this->assertFileExists($base . 'First' . DIRECTORY_SEPARATOR . 'zipextracted.txt'); + $this->assertFileExists($base . 'First' . DIRECTORY_SEPARATOR . + 'Second' . DIRECTORY_SEPARATOR . 'zipextracted.txt'); $content = file_get_contents(dirname(__DIR__) . '/_files/Compress/zipextracted.txt'); $this->assertEquals('compress me', $content); } diff --git a/test/Compress/ZipTest.php b/test/Compress/ZipTest.php index f81953e3..a25ccced 100644 --- a/test/Compress/ZipTest.php +++ b/test/Compress/ZipTest.php @@ -249,11 +249,11 @@ public function testZipCompressDirectory() . DIRECTORY_SEPARATOR, $content); $base = $this->tmp . DIRECTORY_SEPARATOR . '_compress' . DIRECTORY_SEPARATOR . 'Compress' . DIRECTORY_SEPARATOR; - $this->assertTrue(file_exists($base)); - $this->assertTrue(file_exists($base . 'zipextracted.txt')); - $this->assertTrue(file_exists($base . 'First' . DIRECTORY_SEPARATOR . 'zipextracted.txt')); - $this->assertTrue(file_exists($base . 'First' . DIRECTORY_SEPARATOR . - 'Second' . DIRECTORY_SEPARATOR . 'zipextracted.txt')); + $this->assertFileExists($base); + $this->assertFileExists($base . 'zipextracted.txt'); + $this->assertFileExists($base . 'First' . DIRECTORY_SEPARATOR . 'zipextracted.txt'); + $this->assertFileExists($base . 'First' . DIRECTORY_SEPARATOR . + 'Second' . DIRECTORY_SEPARATOR . 'zipextracted.txt'); $content = file_get_contents($this->tmp . '/Compress/zipextracted.txt'); $this->assertEquals('compress me', $content); } From fc66ee1ced8598374ab01cfc72aaf9fd31b9b0ef Mon Sep 17 00:00:00 2001 From: Maks3w Date: Fri, 1 May 2015 11:36:34 +0200 Subject: [PATCH 2/5] [test] Replace assertTrue(empty) with assertEmpty --- test/PregReplaceTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/PregReplaceTest.php b/test/PregReplaceTest.php index c8251e0e..ca1e3133 100644 --- a/test/PregReplaceTest.php +++ b/test/PregReplaceTest.php @@ -63,7 +63,7 @@ public function testPatternAccessorsWork() public function testReplacementIsEmptyByDefault() { $replacement = $this->filter->getReplacement(); - $this->assertTrue(empty($replacement)); + $this->assertEmpty($replacement); } public function testReplacementAccessorsWork() From 4416597e260514fd7120517c5b90854e86d350d0 Mon Sep 17 00:00:00 2001 From: Maks3w Date: Fri, 1 May 2015 11:43:39 +0200 Subject: [PATCH 3/5] [test] Replace assertFalse(empty) with assertEmpty --- test/Encrypt/OpensslTest.php | 2 +- test/StripTagsTest.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/Encrypt/OpensslTest.php b/test/Encrypt/OpensslTest.php index db49eced..81c423e7 100644 --- a/test/Encrypt/OpensslTest.php +++ b/test/Encrypt/OpensslTest.php @@ -232,7 +232,7 @@ public function testMultipleOptionsAtInitiation() 'passphrase' => $passphrase, 'private' => __DIR__ . '/../_files/privatekey_pass.pem')); $public = $filter->getPublicKey(); - $this->assertFalse(empty($public)); + $this->assertNotEmpty($public); $this->assertEquals($passphrase, $filter->getPassphrase()); } diff --git a/test/StripTagsTest.php b/test/StripTagsTest.php index 9aada826..50b695fc 100644 --- a/test/StripTagsTest.php +++ b/test/StripTagsTest.php @@ -441,7 +441,7 @@ public function testFilterIsoChars() $input = 'äöüäöü'; $input = iconv("UTF-8", "ISO-8859-1", $input); $output = $filter($input); - $this->assertFalse(empty($output)); + $this->assertNotEmpty($output); } /** @@ -457,7 +457,7 @@ public function testFilterIsoCharsInComment() $input = 'äöüäöü'; $input = iconv("UTF-8", "ISO-8859-1", $input); $output = $filter($input); - $this->assertFalse(empty($output)); + $this->assertNotEmpty($output); } /** From 1615f57129a75bfc47c7545ef328d2370ebbe813 Mon Sep 17 00:00:00 2001 From: Maks3w Date: Fri, 1 May 2015 10:18:15 +0200 Subject: [PATCH 4/5] [test] Replace assertTrue(instanceof) with assertInstanceOf --- test/CompressTest.php | 2 +- test/HtmlEntitiesTest.php | 4 ++-- test/InflectorTest.php | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/test/CompressTest.php b/test/CompressTest.php index 0683b120..6d54c265 100644 --- a/test/CompressTest.php +++ b/test/CompressTest.php @@ -167,7 +167,7 @@ public function testGetAdapter() { $filter = new CompressFilter('bz2'); $adapter = $filter->getAdapter(); - $this->assertTrue($adapter instanceof \Zend\Filter\Compress\CompressionAlgorithmInterface); + $this->assertInstanceOf('Zend\Filter\Compress\CompressionAlgorithmInterface', $adapter); $this->assertEquals('Bz2', $filter->getAdapterName()); } diff --git a/test/HtmlEntitiesTest.php b/test/HtmlEntitiesTest.php index 72348179..e6e6be52 100644 --- a/test/HtmlEntitiesTest.php +++ b/test/HtmlEntitiesTest.php @@ -128,7 +128,7 @@ public function testSetDoubleQuote() public function testFluentInterface() { $instance = $this->_filter->setCharSet('UTF-8')->setQuoteStyle(ENT_QUOTES)->setDoubleQuote(false); - $this->assertTrue($instance instanceof HtmlEntitiesFilter); + $this->assertInstanceOf('Zend\Filter\HtmlEntities', $instance); } /** @@ -251,7 +251,7 @@ public function testRaisesExceptionIfEncodingMismatchDetectedAndFinalStringIsEmp $result = $this->_filter->filter($string); $this->fail('Expected exception from single non-utf-8 character'); } catch (\Exception $e) { - $this->assertTrue($e instanceof Exception\DomainException); + $this->assertInstanceOf('Zend\Filter\Exception\DomainException', $e); } } diff --git a/test/InflectorTest.php b/test/InflectorTest.php index 2a80c072..9bb9e97d 100644 --- a/test/InflectorTest.php +++ b/test/InflectorTest.php @@ -44,7 +44,7 @@ public function setUp() public function testGetPluginManagerReturnsFilterManagerByDefault() { $broker = $this->inflector->getPluginManager(); - $this->assertTrue($broker instanceof FilterPluginManager); + $this->assertInstanceOf('Zend\Filter\FilterPluginManager', $broker); } public function testSetPluginManagerAllowsSettingAlternatePluginManager() @@ -91,7 +91,7 @@ public function testSetFilterRuleWithStringRuleCreatesRuleEntryAndFilterObject() $rules = $this->inflector->getRules('controller'); $this->assertEquals(1, count($rules)); $filter = $rules[0]; - $this->assertTrue($filter instanceof \Zend\Filter\FilterInterface); + $this->assertInstanceOf('Zend\Filter\FilterInterface', $filter); } public function testSetFilterRuleWithFilterObjectCreatesRuleEntryWithFilterObject() @@ -103,7 +103,7 @@ public function testSetFilterRuleWithFilterObjectCreatesRuleEntryWithFilterObjec $rules = $this->inflector->getRules('controller'); $this->assertEquals(1, count($rules)); $received = $rules[0]; - $this->assertTrue($received instanceof \Zend\Filter\FilterInterface); + $this->assertInstanceOf('Zend\Filter\FilterInterface', $received); $this->assertSame($filter, $received); } @@ -118,8 +118,8 @@ public function testAddFilterRuleAppendsRuleEntries() $this->inflector->setFilterRule('controller', array('PregReplace', 'Alpha')); $rules = $this->inflector->getRules('controller'); $this->assertEquals(2, count($rules)); - $this->assertTrue($rules[0] instanceof \Zend\Filter\FilterInterface); - $this->assertTrue($rules[1] instanceof \Zend\Filter\FilterInterface); + $this->assertInstanceOf('Zend\Filter\FilterInterface', $rules[0]); + $this->assertInstanceOf('Zend\Filter\FilterInterface', $rules[1]); } public function testSetStaticRuleCreatesScalarRuleEntry() @@ -200,7 +200,7 @@ public function testGetRule() } $this->inflector->setFilterRule(':controller', array('Alpha', 'StringToLower')); - $this->assertTrue($this->inflector->getRule('controller', 1) instanceof \Zend\Filter\StringToLower); + $this->assertInstanceOf('Zend\Filter\StringToLower', $this->inflector->getRule('controller', 1)); $this->assertFalse($this->inflector->getRule('controller', 2)); } From 9642037b9f5361e68f27edfd32c0adb61cb0d3be Mon Sep 17 00:00:00 2001 From: Maks3w Date: Fri, 1 May 2015 14:17:07 +0200 Subject: [PATCH 5/5] [test] Replace assertTrue(count(foo) > 0) with assertNotEmpty(foo) --- test/HtmlEntitiesTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/HtmlEntitiesTest.php b/test/HtmlEntitiesTest.php index e6e6be52..d0ff5a49 100644 --- a/test/HtmlEntitiesTest.php +++ b/test/HtmlEntitiesTest.php @@ -209,7 +209,7 @@ public function testCorrectsForEncodingMismatch() $result = $this->_filter->filter($string); restore_error_handler(); - $this->assertTrue(strlen($result) > 0); + $this->assertGreaterThan(0, strlen($result)); } /**