Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge pull request zendframework/zendframework#7476 from Maks3w/hotix…
Browse files Browse the repository at this point in the history
…/remove-evil-assertBoolean-not-boolean-values

[test] Remove evil assert boolean for not boolean values
  • Loading branch information
weierophinney committed May 4, 2015
154 parents 328d367 + 86b970c + 5dccc42 + 4c2d087 + 15d7ad3 + 43d486b + de6c4f3 + c04ecdf + 7b52962 + 9e9b7fb + 9654dc2 + 77fcf26 + a8d7175 + 2df1fa2 + 2eea980 + 5e212bf + 099a852 + b4fea29 + ca1f464 + 23d6321 + 296e43e + d444a38 + 3db95a1 + 981d623 + 0a2e3ae + af23c99 + 80f5165 + 78d16a9 + 6bc4f23 + ece1d99 + 0b9ced2 + 9d50bff + 476d115 + c660c64 + 23e480a + 2d1a86f + bcd3a85 + d46ca8d + 236d691 + 0c0ae53 + 16da5d7 + 1c4489e + a57bb3d + c14d67b + b241e8d + 10c9e19 + 33f9f3b + 4585cfe + d06b3a5 + 371eaa8 + c9fbe3f + 77552c9 + 5883d28 + 518460f + 63a6a3b + f21d820 + 5b80282 + 8d4f7c0 + 3428c24 + 50a5cf9 + 0fcf91c + ffd0e6c + 90cc750 + 4c0cba4 + 9e64972 + 3a86f54 + f4931d8 + 9c496b9 + f36d38f + 1b580df + dab01ce + bc6e247 + 96739b6 + e1b5376 + 1c7183f + 0e68ed1 + 5b3198f + 929c939 + f7e2963 + 611c83e + 1d9e7ae + eae64aa + 1f3f9e7 + b2d7401 + 2f1d9d3 + de6b908 + c73007c + 9565c63 + bc2a6d0 + 264d24f + c9c493c + 3992e0d + 5225965 + 0de9a5c + 867db21 + 34fe2aa + 6ec2723 + e576e38 + cbc0283 + d007f6e + db4f03e + f8f7897 + 4cb349f + f5287db + e7abf4a + b1e5a28 + 6c77a16 + d3f730c + 9abb387 + c0b8c0d + f8bc057 + 4f32b4b + aa46231 + 52390dd + aed5127 + d6219ab + cc8aa50 + 3796880 + 3460327 + 6371934 + bdc1874 + 540ba2f + c5fa53c + c1cd9d0 + e861d7a + bfa4749 + 5ec28c8 + 5078786 + 9d152ef + 3376d96 + 2851abb + 8728f2a + e5443b4 + 6b3466e + 435b7e1 + 3abf077 + 3e7551c + 0af2391 + 60c43e9 + d3bdecf + 7b55dd6 + e705b54 + 6d56b35 + 8383390 + 5642b61 + 85af0e4 + 4bef446 + 1de66d7 + 2cfd916 + 297bb66 + 7bb614c + b49dbbb + 55d21d8 + 4fd4bd6 commit 6018a47
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 56 deletions.
2 changes: 1 addition & 1 deletion test/ClassFileLocatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function testIterationShouldInjectNamespacesInFileInfo()
$locator = new ClassFileLocator(__DIR__);
foreach ($locator as $file) {
$namespaces = $file->getNamespaces();
$this->assertTrue(count($namespaces) > 0);
$this->assertNotEmpty($namespaces);
}
}

Expand Down
80 changes: 40 additions & 40 deletions test/Transfer/Adapter/AbstractTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function testAdapterShouldAllowAddingValidatorViaPluginManager()
{
$this->adapter->addValidator('Count', false, array('min' => 1, 'max' => 1));
$test = $this->adapter->getValidator('Count');
$this->assertTrue($test instanceof FileValidator\Count);
$this->assertInstanceOf('Zend\Validator\File\Count', $test);
}

public function testAdapterhShouldRaiseExceptionWhenAddingInvalidValidatorType()
Expand All @@ -90,16 +90,16 @@ public function testAdapterShouldAllowAddingMultipleValidatorsAtOnceUsingBothIns
);
$this->adapter->addValidators($validators);
$test = $this->adapter->getValidators();
$this->assertTrue(is_array($test));
$this->assertInternalType('array', $test);
$this->assertEquals(4, count($test), var_export($test, 1));
$count = array_shift($test);
$this->assertTrue($count instanceof FileValidator\Count);
$this->assertInstanceOf('Zend\Validator\File\Count', $count);
$exists = array_shift($test);
$this->assertTrue($exists instanceof FileValidator\Exists);
$this->assertInstanceOf('Zend\Validator\File\Exists', $exists);
$size = array_shift($test);
$this->assertTrue($size instanceof FileValidator\Upload);
$this->assertInstanceOf('Zend\Validator\File\Upload', $size);
$ext = array_shift($test);
$this->assertTrue($ext instanceof FileValidator\Extension);
$this->assertInstanceOf('Zend\Validator\File\Extension', $ext);
$orig = array_pop($validators);
$this->assertSame($orig, $ext);
}
Expand All @@ -115,7 +115,7 @@ public function testAdapterShouldAllowPullingValidatorsByFile()
$validators = $this->adapter->getValidators('foo');
$this->assertEquals(1, count($validators));
$validator = array_shift($validators);
$this->assertTrue($validator instanceof Validator\Between);
$this->assertInstanceOf('Zend\Validator\Between', $validator);
}

public function testCallingSetValidatorsOnAdapterShouldOverwriteExistingValidators()
Expand All @@ -134,24 +134,24 @@ public function testAdapterShouldAllowRetrievingValidatorInstancesByClassName()
{
$this->testAdapterShouldAllowAddingMultipleValidatorsAtOnceUsingBothInstancesAndPluginLoader();
$ext = $this->adapter->getValidator('Zend\Validator\File\Extension');
$this->assertTrue($ext instanceof FileValidator\Extension);
$this->assertInstanceOf('Zend\Validator\File\Extension', $ext);
}

public function testAdapterShouldAllowRetrievingValidatorInstancesByPluginName()
{
$this->testAdapterShouldAllowAddingMultipleValidatorsAtOnceUsingBothInstancesAndPluginLoader();
$count = $this->adapter->getValidator('Count');
$this->assertTrue($count instanceof FileValidator\Count);
$this->assertInstanceOf('Zend\Validator\File\Count', $count);
}

public function testAdapterShouldAllowRetrievingAllValidatorsAtOnce()
{
$this->testAdapterShouldAllowAddingMultipleValidatorsAtOnceUsingBothInstancesAndPluginLoader();
$validators = $this->adapter->getValidators();
$this->assertTrue(is_array($validators));
$this->assertInternalType('array', $validators);
$this->assertEquals(4, count($validators));
foreach ($validators as $validator) {
$this->assertTrue($validator instanceof Validator\ValidatorInterface);
$this->assertInstanceOf('Zend\Validator\ValidatorInterface', $validator);
}
}

Expand Down Expand Up @@ -187,7 +187,7 @@ public function testAdapterShouldAllowRemovingAllValidatorsAtOnce()
$this->testAdapterShouldAllowAddingMultipleValidatorsAtOnceUsingBothInstancesAndPluginLoader();
$this->adapter->clearValidators();
$validators = $this->adapter->getValidators();
$this->assertTrue(is_array($validators));
$this->assertInternalType('array', $validators);
$this->assertEquals(0, count($validators));
}

Expand Down Expand Up @@ -216,31 +216,31 @@ public function testValidationShouldThrowExceptionForNonexistentFile()
public function testErrorMessagesShouldBeEmptyByDefault()
{
$messages = $this->adapter->getMessages();
$this->assertTrue(is_array($messages));
$this->assertInternalType('array', $messages);
$this->assertEquals(0, count($messages));
}

public function testErrorMessagesShouldBePopulatedAfterInvalidTransfer()
{
$this->testValidationShouldReturnFalseForInvalidTransfer();
$messages = $this->adapter->getMessages();
$this->assertTrue(is_array($messages));
$this->assertFalse(empty($messages));
$this->assertInternalType('array', $messages);
$this->assertNotEmpty($messages);
}

public function testErrorCodesShouldBeNullByDefault()
{
$errors = $this->adapter->getErrors();
$this->assertTrue(is_array($errors));
$this->assertInternalType('array', $errors);
$this->assertEquals(0, count($errors));
}

public function testErrorCodesShouldBePopulatedAfterInvalidTransfer()
{
$this->testValidationShouldReturnFalseForInvalidTransfer();
$errors = $this->adapter->getErrors();
$this->assertTrue(is_array($errors));
$this->assertFalse(empty($errors));
$this->assertInternalType('array', $errors);
$this->assertNotEmpty($errors);
}

public function testAdapterShouldLazyLoadFilterPluginManager()
Expand All @@ -261,7 +261,7 @@ public function testAdapterShouldAllowAddingFilterViaPluginManager()
{
$this->adapter->addFilter('StringTrim');
$test = $this->adapter->getFilter('StringTrim');
$this->assertTrue($test instanceof Filter\StringTrim);
$this->assertInstanceOf('Zend\Filter\StringTrim', $test);
}


Expand All @@ -283,12 +283,12 @@ public function testAdapterShouldAllowAddingMultipleFiltersAtOnceUsingBothInstan
);
$this->adapter->addFilters($filters);
$test = $this->adapter->getFilters();
$this->assertTrue(is_array($test));
$this->assertInternalType('array', $test);
$this->assertEquals(3, count($test), var_export($test, 1));
$count = array_shift($test);
$this->assertTrue($count instanceof Word\SeparatorToCamelCase);
$this->assertInstanceOf('Zend\Filter\Word\SeparatorToCamelCase', $count);
$size = array_shift($test);
$this->assertTrue($size instanceof Filter\Boolean);
$this->assertInstanceOf('Zend\Filter\Boolean', $size);
$ext = array_shift($test);
$orig = array_pop($filters);
$this->assertSame($orig, $ext);
Expand All @@ -305,7 +305,7 @@ public function testAdapterShouldAllowPullingFiltersByFile()
$filters = $this->adapter->getFilters('foo');
$this->assertEquals(1, count($filters));
$filter = array_shift($filters);
$this->assertTrue($filter instanceof Filter\Boolean);
$this->assertInstanceOf('Zend\Filter\Boolean', $filter);
}

public function testCallingSetFiltersOnAdapterShouldOverwriteExistingFilters()
Expand All @@ -324,24 +324,24 @@ public function testAdapterShouldAllowRetrievingFilterInstancesByClassName()
{
$this->testAdapterShouldAllowAddingMultipleFiltersAtOnceUsingBothInstancesAndPluginLoader();
$ext = $this->adapter->getFilter('Zend\Filter\BaseName');
$this->assertTrue($ext instanceof Filter\BaseName);
$this->assertInstanceOf('Zend\Filter\BaseName', $ext);
}

public function testAdapterShouldAllowRetrievingFilterInstancesByPluginName()
{
$this->testAdapterShouldAllowAddingMultipleFiltersAtOnceUsingBothInstancesAndPluginLoader();
$count = $this->adapter->getFilter('Boolean');
$this->assertTrue($count instanceof Filter\Boolean);
$this->assertInstanceOf('Zend\Filter\Boolean', $count);
}

public function testAdapterShouldAllowRetrievingAllFiltersAtOnce()
{
$this->testAdapterShouldAllowAddingMultipleFiltersAtOnceUsingBothInstancesAndPluginLoader();
$filters = $this->adapter->getFilters();
$this->assertTrue(is_array($filters));
$this->assertInternalType('array', $filters);
$this->assertEquals(3, count($filters));
foreach ($filters as $filter) {
$this->assertTrue($filter instanceof Filter\FilterInterface);
$this->assertInstanceOf('Zend\Filter\FilterInterface', $filter);
}
}

Expand Down Expand Up @@ -377,7 +377,7 @@ public function testAdapterShouldAllowRemovingAllFiltersAtOnce()
$this->testAdapterShouldAllowAddingMultipleFiltersAtOnceUsingBothInstancesAndPluginLoader();
$this->adapter->clearFilters();
$filters = $this->adapter->getFilters();
$this->assertTrue(is_array($filters));
$this->assertInternalType('array', $filters);
$this->assertEquals(0, count($filters));
}

Expand All @@ -386,7 +386,7 @@ public function testTransferDestinationShouldBeMutable()
$directory = __DIR__;
$this->adapter->setDestination($directory);
$destinations = $this->adapter->getDestination();
$this->assertTrue(is_array($destinations));
$this->assertInternalType('array', $destinations);
foreach ($destinations as $file => $destination) {
$this->assertEquals($directory, $destination);
}
Expand All @@ -402,10 +402,10 @@ public function testAdapterShouldAllowRetrievingDestinationsForAnArrayOfSpecifie
{
$this->adapter->setDestination(__DIR__);
$destinations = $this->adapter->getDestination(array('bar', 'baz'));
$this->assertTrue(is_array($destinations));
$this->assertInternalType('array', $destinations);
$directory = __DIR__;
foreach ($destinations as $file => $destination) {
$this->assertTrue(in_array($file, array('bar', 'baz')));
$this->assertContains($file, array('bar', 'baz'));
$this->assertEquals($directory, $destination);
}
}
Expand Down Expand Up @@ -484,7 +484,7 @@ public function testAdapterShouldAllowRetrievingAllFileNames()
. DIRECTORY_SEPARATOR . '_files';
$this->adapter->setDestination($path);
$files = $this->adapter->getFileName();
$this->assertTrue(is_array($files));
$this->assertInternalType('array', $files);
$this->assertEquals($path . DIRECTORY_SEPARATOR . 'bar.png', $files['bar']);
}

Expand All @@ -494,7 +494,7 @@ public function testAdapterShouldAllowRetrievingAllFileNamesWithoutPath()
. DIRECTORY_SEPARATOR . '_files';
$this->adapter->setDestination($path);
$files = $this->adapter->getFileName(null, false);
$this->assertTrue(is_array($files));
$this->assertInternalType('array', $files);
$this->assertEquals('bar.png', $files['bar']);
}

Expand All @@ -514,13 +514,13 @@ public function testIgnoreHashValue()
public function testEmptyTempDirectoryDetection()
{
$this->adapter->tmpDir = "";
$this->assertTrue(empty($this->adapter->tmpDir), "Empty temporary directory");
$this->assertEmpty($this->adapter->tmpDir, "Empty temporary directory");
}

public function testTempDirectoryDetection()
{
$this->adapter->getTmpDir();
$this->assertTrue(!empty($this->adapter->tmpDir), "Temporary directory filled");
$this->assertNotEmpty($this->adapter->tmpDir, "Temporary directory filled");
}

public function testTemporaryDirectoryAccessDetection()
Expand Down Expand Up @@ -592,7 +592,7 @@ public function testTransferDestinationAtNonExistingElement()
$this->assertEquals($directory, $this->adapter->getDestination('nonexisting'));

$this->setExpectedException('Zend\File\Transfer\Exception\InvalidArgumentException', 'not find');
$this->assertTrue(is_string($this->adapter->getDestination('reallynonexisting')));
$this->assertInternalType('string', $this->adapter->getDestination('reallynonexisting'));
}

/**
Expand Down Expand Up @@ -628,16 +628,16 @@ public function testAdapterShouldAllowAddingMultipleValidatorsAtOnceUsingBothIns
$test = $this->adapter->getValidators('foo');
$this->assertEquals(2, count($test));
$mimeType = array_shift($test);
$this->assertTrue($mimeType instanceof FileValidator\MimeType);
$this->assertInstanceOf('Zend\Validator\File\MimeType', $mimeType);
$filesSize = array_shift($test);
$this->assertTrue($filesSize instanceof FileValidator\FilesSize);
$this->assertInstanceOf('Zend\Validator\File\FilesSize', $filesSize);

$test = $this->adapter->getValidators('bar');
$this->assertEquals(2, count($test));
$filesSize = array_shift($test);
$this->assertTrue($filesSize instanceof FileValidator\Count);
$this->assertInstanceOf('Zend\Validator\File\Count', $filesSize);
$mimeType = array_shift($test);
$this->assertTrue($mimeType instanceof FileValidator\MimeType);
$this->assertInstanceOf('Zend\Validator\File\MimeType', $mimeType);

$test = $this->adapter->getValidators('baz');
$this->assertEquals(0, count($test));
Expand Down
30 changes: 15 additions & 15 deletions test/Transfer/Adapter/HttpTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function testAutoSetUploadValidator()
);
$this->adapter->setValidators($validators);
$test = $this->adapter->getValidator('Upload');
$this->assertTrue($test instanceof FileValidator\Upload);
$this->assertInstanceOf('Zend\Validator\File\Upload', $test);
}

public function testSendingFiles()
Expand Down Expand Up @@ -231,23 +231,23 @@ public function testUploadProgressAdapter()
$adapter = new AdapterProgressBar\Console();
$status = array('progress' => $adapter, 'session' => 'upload');
$status = HttpTestMockAdapter::getProgress($status);
$this->assertTrue(array_key_exists('total', $status));
$this->assertTrue(array_key_exists('current', $status));
$this->assertTrue(array_key_exists('rate', $status));
$this->assertTrue(array_key_exists('id', $status));
$this->assertTrue(array_key_exists('message', $status));
$this->assertTrue(array_key_exists('progress', $status));
$this->assertTrue($status['progress'] instanceof ProgressBar\ProgressBar);
$this->assertArrayHasKey('total', $status);
$this->assertArrayHasKey('current', $status);
$this->assertArrayHasKey('rate', $status);
$this->assertArrayHasKey('id', $status);
$this->assertArrayHasKey('message', $status);
$this->assertArrayHasKey('progress', $status);
$this->assertInstanceOf('Zend\ProgressBar\ProgressBar', $status['progress']);

$this->adapter->switchApcToUP();
$status = HttpTestMockAdapter::getProgress($status);
$this->assertTrue(array_key_exists('total', $status));
$this->assertTrue(array_key_exists('current', $status));
$this->assertTrue(array_key_exists('rate', $status));
$this->assertTrue(array_key_exists('id', $status));
$this->assertTrue(array_key_exists('message', $status));
$this->assertTrue(array_key_exists('progress', $status));
$this->assertTrue($status['progress'] instanceof ProgressBar\ProgressBar);
$this->assertArrayHasKey('total', $status);
$this->assertArrayHasKey('current', $status);
$this->assertArrayHasKey('rate', $status);
$this->assertArrayHasKey('id', $status);
$this->assertArrayHasKey('message', $status);
$this->assertArrayHasKey('progress', $status);
$this->assertInstanceOf('Zend\ProgressBar\ProgressBar', $status['progress']);
}

public function testValidationOfPhpExtendsFormError()
Expand Down

0 comments on commit 6018a47

Please sign in to comment.