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

Commit 6018a47

Browse files
committed
Merge pull request zendframework/zendframework#7476 from Maks3w/hotix/remove-evil-assertBoolean-not-boolean-values
[test] Remove evil assert boolean for not boolean values
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

File tree

3 files changed

+56
-56
lines changed

3 files changed

+56
-56
lines changed

test/ClassFileLocatorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function testIterationShouldInjectNamespacesInFileInfo()
8383
$locator = new ClassFileLocator(__DIR__);
8484
foreach ($locator as $file) {
8585
$namespaces = $file->getNamespaces();
86-
$this->assertTrue(count($namespaces) > 0);
86+
$this->assertNotEmpty($namespaces);
8787
}
8888
}
8989

test/Transfer/Adapter/AbstractTest.php

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function testAdapterShouldAllowAddingValidatorViaPluginManager()
6868
{
6969
$this->adapter->addValidator('Count', false, array('min' => 1, 'max' => 1));
7070
$test = $this->adapter->getValidator('Count');
71-
$this->assertTrue($test instanceof FileValidator\Count);
71+
$this->assertInstanceOf('Zend\Validator\File\Count', $test);
7272
}
7373

7474
public function testAdapterhShouldRaiseExceptionWhenAddingInvalidValidatorType()
@@ -90,16 +90,16 @@ public function testAdapterShouldAllowAddingMultipleValidatorsAtOnceUsingBothIns
9090
);
9191
$this->adapter->addValidators($validators);
9292
$test = $this->adapter->getValidators();
93-
$this->assertTrue(is_array($test));
93+
$this->assertInternalType('array', $test);
9494
$this->assertEquals(4, count($test), var_export($test, 1));
9595
$count = array_shift($test);
96-
$this->assertTrue($count instanceof FileValidator\Count);
96+
$this->assertInstanceOf('Zend\Validator\File\Count', $count);
9797
$exists = array_shift($test);
98-
$this->assertTrue($exists instanceof FileValidator\Exists);
98+
$this->assertInstanceOf('Zend\Validator\File\Exists', $exists);
9999
$size = array_shift($test);
100-
$this->assertTrue($size instanceof FileValidator\Upload);
100+
$this->assertInstanceOf('Zend\Validator\File\Upload', $size);
101101
$ext = array_shift($test);
102-
$this->assertTrue($ext instanceof FileValidator\Extension);
102+
$this->assertInstanceOf('Zend\Validator\File\Extension', $ext);
103103
$orig = array_pop($validators);
104104
$this->assertSame($orig, $ext);
105105
}
@@ -115,7 +115,7 @@ public function testAdapterShouldAllowPullingValidatorsByFile()
115115
$validators = $this->adapter->getValidators('foo');
116116
$this->assertEquals(1, count($validators));
117117
$validator = array_shift($validators);
118-
$this->assertTrue($validator instanceof Validator\Between);
118+
$this->assertInstanceOf('Zend\Validator\Between', $validator);
119119
}
120120

121121
public function testCallingSetValidatorsOnAdapterShouldOverwriteExistingValidators()
@@ -134,24 +134,24 @@ public function testAdapterShouldAllowRetrievingValidatorInstancesByClassName()
134134
{
135135
$this->testAdapterShouldAllowAddingMultipleValidatorsAtOnceUsingBothInstancesAndPluginLoader();
136136
$ext = $this->adapter->getValidator('Zend\Validator\File\Extension');
137-
$this->assertTrue($ext instanceof FileValidator\Extension);
137+
$this->assertInstanceOf('Zend\Validator\File\Extension', $ext);
138138
}
139139

140140
public function testAdapterShouldAllowRetrievingValidatorInstancesByPluginName()
141141
{
142142
$this->testAdapterShouldAllowAddingMultipleValidatorsAtOnceUsingBothInstancesAndPluginLoader();
143143
$count = $this->adapter->getValidator('Count');
144-
$this->assertTrue($count instanceof FileValidator\Count);
144+
$this->assertInstanceOf('Zend\Validator\File\Count', $count);
145145
}
146146

147147
public function testAdapterShouldAllowRetrievingAllValidatorsAtOnce()
148148
{
149149
$this->testAdapterShouldAllowAddingMultipleValidatorsAtOnceUsingBothInstancesAndPluginLoader();
150150
$validators = $this->adapter->getValidators();
151-
$this->assertTrue(is_array($validators));
151+
$this->assertInternalType('array', $validators);
152152
$this->assertEquals(4, count($validators));
153153
foreach ($validators as $validator) {
154-
$this->assertTrue($validator instanceof Validator\ValidatorInterface);
154+
$this->assertInstanceOf('Zend\Validator\ValidatorInterface', $validator);
155155
}
156156
}
157157

@@ -187,7 +187,7 @@ public function testAdapterShouldAllowRemovingAllValidatorsAtOnce()
187187
$this->testAdapterShouldAllowAddingMultipleValidatorsAtOnceUsingBothInstancesAndPluginLoader();
188188
$this->adapter->clearValidators();
189189
$validators = $this->adapter->getValidators();
190-
$this->assertTrue(is_array($validators));
190+
$this->assertInternalType('array', $validators);
191191
$this->assertEquals(0, count($validators));
192192
}
193193

@@ -216,31 +216,31 @@ public function testValidationShouldThrowExceptionForNonexistentFile()
216216
public function testErrorMessagesShouldBeEmptyByDefault()
217217
{
218218
$messages = $this->adapter->getMessages();
219-
$this->assertTrue(is_array($messages));
219+
$this->assertInternalType('array', $messages);
220220
$this->assertEquals(0, count($messages));
221221
}
222222

223223
public function testErrorMessagesShouldBePopulatedAfterInvalidTransfer()
224224
{
225225
$this->testValidationShouldReturnFalseForInvalidTransfer();
226226
$messages = $this->adapter->getMessages();
227-
$this->assertTrue(is_array($messages));
228-
$this->assertFalse(empty($messages));
227+
$this->assertInternalType('array', $messages);
228+
$this->assertNotEmpty($messages);
229229
}
230230

231231
public function testErrorCodesShouldBeNullByDefault()
232232
{
233233
$errors = $this->adapter->getErrors();
234-
$this->assertTrue(is_array($errors));
234+
$this->assertInternalType('array', $errors);
235235
$this->assertEquals(0, count($errors));
236236
}
237237

238238
public function testErrorCodesShouldBePopulatedAfterInvalidTransfer()
239239
{
240240
$this->testValidationShouldReturnFalseForInvalidTransfer();
241241
$errors = $this->adapter->getErrors();
242-
$this->assertTrue(is_array($errors));
243-
$this->assertFalse(empty($errors));
242+
$this->assertInternalType('array', $errors);
243+
$this->assertNotEmpty($errors);
244244
}
245245

246246
public function testAdapterShouldLazyLoadFilterPluginManager()
@@ -261,7 +261,7 @@ public function testAdapterShouldAllowAddingFilterViaPluginManager()
261261
{
262262
$this->adapter->addFilter('StringTrim');
263263
$test = $this->adapter->getFilter('StringTrim');
264-
$this->assertTrue($test instanceof Filter\StringTrim);
264+
$this->assertInstanceOf('Zend\Filter\StringTrim', $test);
265265
}
266266

267267

@@ -283,12 +283,12 @@ public function testAdapterShouldAllowAddingMultipleFiltersAtOnceUsingBothInstan
283283
);
284284
$this->adapter->addFilters($filters);
285285
$test = $this->adapter->getFilters();
286-
$this->assertTrue(is_array($test));
286+
$this->assertInternalType('array', $test);
287287
$this->assertEquals(3, count($test), var_export($test, 1));
288288
$count = array_shift($test);
289-
$this->assertTrue($count instanceof Word\SeparatorToCamelCase);
289+
$this->assertInstanceOf('Zend\Filter\Word\SeparatorToCamelCase', $count);
290290
$size = array_shift($test);
291-
$this->assertTrue($size instanceof Filter\Boolean);
291+
$this->assertInstanceOf('Zend\Filter\Boolean', $size);
292292
$ext = array_shift($test);
293293
$orig = array_pop($filters);
294294
$this->assertSame($orig, $ext);
@@ -305,7 +305,7 @@ public function testAdapterShouldAllowPullingFiltersByFile()
305305
$filters = $this->adapter->getFilters('foo');
306306
$this->assertEquals(1, count($filters));
307307
$filter = array_shift($filters);
308-
$this->assertTrue($filter instanceof Filter\Boolean);
308+
$this->assertInstanceOf('Zend\Filter\Boolean', $filter);
309309
}
310310

311311
public function testCallingSetFiltersOnAdapterShouldOverwriteExistingFilters()
@@ -324,24 +324,24 @@ public function testAdapterShouldAllowRetrievingFilterInstancesByClassName()
324324
{
325325
$this->testAdapterShouldAllowAddingMultipleFiltersAtOnceUsingBothInstancesAndPluginLoader();
326326
$ext = $this->adapter->getFilter('Zend\Filter\BaseName');
327-
$this->assertTrue($ext instanceof Filter\BaseName);
327+
$this->assertInstanceOf('Zend\Filter\BaseName', $ext);
328328
}
329329

330330
public function testAdapterShouldAllowRetrievingFilterInstancesByPluginName()
331331
{
332332
$this->testAdapterShouldAllowAddingMultipleFiltersAtOnceUsingBothInstancesAndPluginLoader();
333333
$count = $this->adapter->getFilter('Boolean');
334-
$this->assertTrue($count instanceof Filter\Boolean);
334+
$this->assertInstanceOf('Zend\Filter\Boolean', $count);
335335
}
336336

337337
public function testAdapterShouldAllowRetrievingAllFiltersAtOnce()
338338
{
339339
$this->testAdapterShouldAllowAddingMultipleFiltersAtOnceUsingBothInstancesAndPluginLoader();
340340
$filters = $this->adapter->getFilters();
341-
$this->assertTrue(is_array($filters));
341+
$this->assertInternalType('array', $filters);
342342
$this->assertEquals(3, count($filters));
343343
foreach ($filters as $filter) {
344-
$this->assertTrue($filter instanceof Filter\FilterInterface);
344+
$this->assertInstanceOf('Zend\Filter\FilterInterface', $filter);
345345
}
346346
}
347347

@@ -377,7 +377,7 @@ public function testAdapterShouldAllowRemovingAllFiltersAtOnce()
377377
$this->testAdapterShouldAllowAddingMultipleFiltersAtOnceUsingBothInstancesAndPluginLoader();
378378
$this->adapter->clearFilters();
379379
$filters = $this->adapter->getFilters();
380-
$this->assertTrue(is_array($filters));
380+
$this->assertInternalType('array', $filters);
381381
$this->assertEquals(0, count($filters));
382382
}
383383

@@ -386,7 +386,7 @@ public function testTransferDestinationShouldBeMutable()
386386
$directory = __DIR__;
387387
$this->adapter->setDestination($directory);
388388
$destinations = $this->adapter->getDestination();
389-
$this->assertTrue(is_array($destinations));
389+
$this->assertInternalType('array', $destinations);
390390
foreach ($destinations as $file => $destination) {
391391
$this->assertEquals($directory, $destination);
392392
}
@@ -402,10 +402,10 @@ public function testAdapterShouldAllowRetrievingDestinationsForAnArrayOfSpecifie
402402
{
403403
$this->adapter->setDestination(__DIR__);
404404
$destinations = $this->adapter->getDestination(array('bar', 'baz'));
405-
$this->assertTrue(is_array($destinations));
405+
$this->assertInternalType('array', $destinations);
406406
$directory = __DIR__;
407407
foreach ($destinations as $file => $destination) {
408-
$this->assertTrue(in_array($file, array('bar', 'baz')));
408+
$this->assertContains($file, array('bar', 'baz'));
409409
$this->assertEquals($directory, $destination);
410410
}
411411
}
@@ -484,7 +484,7 @@ public function testAdapterShouldAllowRetrievingAllFileNames()
484484
. DIRECTORY_SEPARATOR . '_files';
485485
$this->adapter->setDestination($path);
486486
$files = $this->adapter->getFileName();
487-
$this->assertTrue(is_array($files));
487+
$this->assertInternalType('array', $files);
488488
$this->assertEquals($path . DIRECTORY_SEPARATOR . 'bar.png', $files['bar']);
489489
}
490490

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

@@ -514,13 +514,13 @@ public function testIgnoreHashValue()
514514
public function testEmptyTempDirectoryDetection()
515515
{
516516
$this->adapter->tmpDir = "";
517-
$this->assertTrue(empty($this->adapter->tmpDir), "Empty temporary directory");
517+
$this->assertEmpty($this->adapter->tmpDir, "Empty temporary directory");
518518
}
519519

520520
public function testTempDirectoryDetection()
521521
{
522522
$this->adapter->getTmpDir();
523-
$this->assertTrue(!empty($this->adapter->tmpDir), "Temporary directory filled");
523+
$this->assertNotEmpty($this->adapter->tmpDir, "Temporary directory filled");
524524
}
525525

526526
public function testTemporaryDirectoryAccessDetection()
@@ -592,7 +592,7 @@ public function testTransferDestinationAtNonExistingElement()
592592
$this->assertEquals($directory, $this->adapter->getDestination('nonexisting'));
593593

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

598598
/**
@@ -628,16 +628,16 @@ public function testAdapterShouldAllowAddingMultipleValidatorsAtOnceUsingBothIns
628628
$test = $this->adapter->getValidators('foo');
629629
$this->assertEquals(2, count($test));
630630
$mimeType = array_shift($test);
631-
$this->assertTrue($mimeType instanceof FileValidator\MimeType);
631+
$this->assertInstanceOf('Zend\Validator\File\MimeType', $mimeType);
632632
$filesSize = array_shift($test);
633-
$this->assertTrue($filesSize instanceof FileValidator\FilesSize);
633+
$this->assertInstanceOf('Zend\Validator\File\FilesSize', $filesSize);
634634

635635
$test = $this->adapter->getValidators('bar');
636636
$this->assertEquals(2, count($test));
637637
$filesSize = array_shift($test);
638-
$this->assertTrue($filesSize instanceof FileValidator\Count);
638+
$this->assertInstanceOf('Zend\Validator\File\Count', $filesSize);
639639
$mimeType = array_shift($test);
640-
$this->assertTrue($mimeType instanceof FileValidator\MimeType);
640+
$this->assertInstanceOf('Zend\Validator\File\MimeType', $mimeType);
641641

642642
$test = $this->adapter->getValidators('baz');
643643
$this->assertEquals(0, count($test));

test/Transfer/Adapter/HttpTest.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function testAutoSetUploadValidator()
6464
);
6565
$this->adapter->setValidators($validators);
6666
$test = $this->adapter->getValidator('Upload');
67-
$this->assertTrue($test instanceof FileValidator\Upload);
67+
$this->assertInstanceOf('Zend\Validator\File\Upload', $test);
6868
}
6969

7070
public function testSendingFiles()
@@ -231,23 +231,23 @@ public function testUploadProgressAdapter()
231231
$adapter = new AdapterProgressBar\Console();
232232
$status = array('progress' => $adapter, 'session' => 'upload');
233233
$status = HttpTestMockAdapter::getProgress($status);
234-
$this->assertTrue(array_key_exists('total', $status));
235-
$this->assertTrue(array_key_exists('current', $status));
236-
$this->assertTrue(array_key_exists('rate', $status));
237-
$this->assertTrue(array_key_exists('id', $status));
238-
$this->assertTrue(array_key_exists('message', $status));
239-
$this->assertTrue(array_key_exists('progress', $status));
240-
$this->assertTrue($status['progress'] instanceof ProgressBar\ProgressBar);
234+
$this->assertArrayHasKey('total', $status);
235+
$this->assertArrayHasKey('current', $status);
236+
$this->assertArrayHasKey('rate', $status);
237+
$this->assertArrayHasKey('id', $status);
238+
$this->assertArrayHasKey('message', $status);
239+
$this->assertArrayHasKey('progress', $status);
240+
$this->assertInstanceOf('Zend\ProgressBar\ProgressBar', $status['progress']);
241241

242242
$this->adapter->switchApcToUP();
243243
$status = HttpTestMockAdapter::getProgress($status);
244-
$this->assertTrue(array_key_exists('total', $status));
245-
$this->assertTrue(array_key_exists('current', $status));
246-
$this->assertTrue(array_key_exists('rate', $status));
247-
$this->assertTrue(array_key_exists('id', $status));
248-
$this->assertTrue(array_key_exists('message', $status));
249-
$this->assertTrue(array_key_exists('progress', $status));
250-
$this->assertTrue($status['progress'] instanceof ProgressBar\ProgressBar);
244+
$this->assertArrayHasKey('total', $status);
245+
$this->assertArrayHasKey('current', $status);
246+
$this->assertArrayHasKey('rate', $status);
247+
$this->assertArrayHasKey('id', $status);
248+
$this->assertArrayHasKey('message', $status);
249+
$this->assertArrayHasKey('progress', $status);
250+
$this->assertInstanceOf('Zend\ProgressBar\ProgressBar', $status['progress']);
251251
}
252252

253253
public function testValidationOfPhpExtendsFormError()

0 commit comments

Comments
 (0)