merged branch stloyd/proper_asserts (PR #2916)
Commits
-------
fd174a2
[Tests] Use proper assertion for counting
Discussion
----------
[Tests] Use proper assertion for counting
```
Bug fix: no
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
```
Docs PR: symfony/symfony-docs#924
This commit is contained in:
commit
694c74da30
@ -28,7 +28,7 @@ class ArrayNodeDefinitionTest extends \PHPUnit_Framework_TestCase
|
||||
->end()
|
||||
->append($child);
|
||||
|
||||
$this->assertEquals(count($this->getField($parent, 'children')), 3);
|
||||
$this->assertCount(3, $this->getField($parent, 'children'));
|
||||
$this->assertTrue(in_array($child, $this->getField($parent, 'children')));
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ class ChoiceTypeTest extends TypeTestCase
|
||||
'choices' => $this->choices,
|
||||
));
|
||||
|
||||
$this->assertEquals(count($this->choices), $form->count(), 'Each choice should become a new field');
|
||||
$this->assertCount($form->count(), $this->choices, 'Each choice should become a new field');
|
||||
}
|
||||
|
||||
public function testExpandedChoicesOptionsAreFlattened()
|
||||
@ -93,7 +93,7 @@ class ChoiceTypeTest extends TypeTestCase
|
||||
$flattened = array_replace($flattened, $choices);
|
||||
}
|
||||
|
||||
$this->assertEquals(count($flattened), $form->count(), 'Each nested choice should become a new field, not the groups');
|
||||
$this->assertCount($form->count(), $flattened, 'Each nested choice should become a new field, not the groups');
|
||||
|
||||
foreach ($flattened as $value => $choice) {
|
||||
$this->assertTrue($form->has($value), 'Flattened choice is named after it\'s value');
|
||||
|
@ -60,7 +60,7 @@ class FileProfilerStorageTest extends \PHPUnit_Framework_TestCase
|
||||
$profile->setMethod('GET');
|
||||
self::$storage->write($profile);
|
||||
}
|
||||
$this->assertEquals(count(self::$storage->find('127.0.0.1', 'http://foo.bar', 20, 'GET')), 10, '->write() stores data in the database');
|
||||
$this->assertCount(10, self::$storage->find('127.0.0.1', 'http://foo.bar', 20, 'GET'), '->write() stores data in the database');
|
||||
}
|
||||
|
||||
|
||||
@ -89,7 +89,7 @@ class FileProfilerStorageTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
// Check parent has child
|
||||
$children = $parentProfile->getChildren();
|
||||
$this->assertEquals(1, count($children));
|
||||
$this->assertCount(1, $children);
|
||||
$this->assertEquals($childProfile->getToken(), $children[0]->getToken());
|
||||
}
|
||||
|
||||
@ -134,9 +134,9 @@ class FileProfilerStorageTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
self::$storage->write($profile);
|
||||
|
||||
$this->assertEquals(count(self::$storage->find('127.0.0.1', '', 10, 'GET')), 1, '->find() retrieve a record by IP');
|
||||
$this->assertEquals(count(self::$storage->find('127.0.%.1', '', 10, 'GET')), 0, '->find() does not interpret a "%" as a wildcard in the IP');
|
||||
$this->assertEquals(count(self::$storage->find('127.0._.1', '', 10, 'GET')), 0, '->find() does not interpret a "_" as a wildcard in the IP');
|
||||
$this->assertCount(1, self::$storage->find('127.0.0.1', '', 10, 'GET'), '->find() retrieve a record by IP');
|
||||
$this->assertCount(0, self::$storage->find('127.0.%.1', '', 10, 'GET'), '->find() does not interpret a "%" as a wildcard in the IP');
|
||||
$this->assertCount(0, self::$storage->find('127.0._.1', '', 10, 'GET'), '->find() does not interpret a "_" as a wildcard in the IP');
|
||||
}
|
||||
|
||||
public function testRetrieveByUrl()
|
||||
@ -177,11 +177,11 @@ class FileProfilerStorageTest extends \PHPUnit_Framework_TestCase
|
||||
$profile->setMethod('GET');
|
||||
self::$storage->write($profile);
|
||||
|
||||
$this->assertEquals(count(self::$storage->find('127.0.0.1', 'http://foo.bar/\'', 10, 'GET')), 1, '->find() accepts single quotes in URLs');
|
||||
$this->assertEquals(count(self::$storage->find('127.0.0.1', 'http://foo.bar/"', 10, 'GET')), 1, '->find() accepts double quotes in URLs');
|
||||
$this->assertEquals(count(self::$storage->find('127.0.0.1', 'http://foo\\bar/', 10, 'GET')), 1, '->find() accepts backslash in URLs');
|
||||
$this->assertEquals(count(self::$storage->find('127.0.0.1', 'http://foo.bar/;', 10, 'GET')), 1, '->find() accepts semicolon in URLs');
|
||||
$this->assertEquals(count(self::$storage->find('127.0.0.1', 'http://foo.bar/%', 10, 'GET')), 1, '->find() does not interpret a "%" as a wildcard in the URL');
|
||||
$this->assertEquals(count(self::$storage->find('127.0.0.1', 'http://foo.bar/_', 10, 'GET')), 1, '->find() does not interpret a "_" as a wildcard in the URL');
|
||||
$this->assertCount(1, self::$storage->find('127.0.0.1', 'http://foo.bar/\'', 10, 'GET'), '->find() accepts single quotes in URLs');
|
||||
$this->assertCount(1, self::$storage->find('127.0.0.1', 'http://foo.bar/"', 10, 'GET'), '->find() accepts double quotes in URLs');
|
||||
$this->assertCount(1, self::$storage->find('127.0.0.1', 'http://foo\\bar/', 10, 'GET'), '->find() accepts backslash in URLs');
|
||||
$this->assertCount(1, self::$storage->find('127.0.0.1', 'http://foo.bar/;', 10, 'GET'), '->find() accepts semicolon in URLs');
|
||||
$this->assertCount(1, self::$storage->find('127.0.0.1', 'http://foo.bar/%', 10, 'GET'), '->find() does not interpret a "%" as a wildcard in the URL');
|
||||
$this->assertCount(1, self::$storage->find('127.0.0.1', 'http://foo.bar/_', 10, 'GET'), '->find() does not interpret a "_" as a wildcard in the URL');
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ class MongoDbProfilerStorageTest extends \PHPUnit_Framework_TestCase
|
||||
$profile->setUrl('http://foo.bar');
|
||||
self::$storage->write($profile);
|
||||
}
|
||||
$this->assertEquals(count(self::$storage->find('127.0.0.1', 'http://foo.bar', 20)), 10, '->write() stores data in the database');
|
||||
$this->assertCount(10, self::$storage->find('127.0.0.1', 'http://foo.bar', 20), '->write() stores data in the database');
|
||||
self::$storage->purge();
|
||||
}
|
||||
|
||||
@ -84,7 +84,7 @@ class MongoDbProfilerStorageTest extends \PHPUnit_Framework_TestCase
|
||||
self::$storage->write($profile);
|
||||
}
|
||||
$records = self::$storage->find('', '', 3);
|
||||
$this->assertEquals(count($records), 3, '->find() returns all previously added records');
|
||||
$this->assertCount(3, $records, '->find() returns all previously added records');
|
||||
$this->assertEquals($records[0]['token'], 'time_2', '->find() returns records ordered by time in descendant order');
|
||||
$this->assertEquals($records[1]['token'], 'time_1', '->find() returns records ordered by time in descendant order');
|
||||
$this->assertEquals($records[2]['token'], 'time_0', '->find() returns records ordered by time in descendant order');
|
||||
@ -98,9 +98,9 @@ class MongoDbProfilerStorageTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
self::$storage->write($profile);
|
||||
|
||||
$this->assertEquals(count(self::$storage->find('127.0.0.1', '', 10)), 1, '->find() retrieve a record by IP');
|
||||
$this->assertEquals(count(self::$storage->find('127.0.%.1', '', 10)), 0, '->find() does not interpret a "%" as a wildcard in the IP');
|
||||
$this->assertEquals(count(self::$storage->find('127.0._.1', '', 10)), 0, '->find() does not interpret a "_" as a wildcard in the IP');
|
||||
$this->assertCount(1, self::$storage->find('127.0.0.1', '', 10), '->find() retrieve a record by IP');
|
||||
$this->assertCount(0, self::$storage->find('127.0.%.1', '', 10), '->find() does not interpret a "%" as a wildcard in the IP');
|
||||
$this->assertCount(0, self::$storage->find('127.0._.1', '', 10), '->find() does not interpret a "_" as a wildcard in the IP');
|
||||
|
||||
self::$storage->purge();
|
||||
}
|
||||
@ -132,11 +132,11 @@ class MongoDbProfilerStorageTest extends \PHPUnit_Framework_TestCase
|
||||
$profile->setUrl('http://foo.bar/_');
|
||||
self::$storage->write($profile);
|
||||
|
||||
$this->assertEquals(count(self::$storage->find('127.0.0.1', 'http://foo.bar/\'', 10)), 1, '->find() accepts single quotes in URLs');
|
||||
$this->assertEquals(count(self::$storage->find('127.0.0.1', 'http://foo.bar/"', 10)), 1, '->find() accepts double quotes in URLs');
|
||||
$this->assertEquals(count(self::$storage->find('127.0.0.1', 'http://foo\\bar/', 10)), 1, '->find() accepts backslash in URLs');
|
||||
$this->assertEquals(count(self::$storage->find('127.0.0.1', 'http://foo.bar/%', 10)), 1, '->find() does not interpret a "%" as a wildcard in the URL');
|
||||
$this->assertEquals(count(self::$storage->find('127.0.0.1', 'http://foo.bar/_', 10)), 1, '->find() does not interpret a "_" as a wildcard in the URL');
|
||||
$this->assertCount(1, self::$storage->find('127.0.0.1', 'http://foo.bar/\'', 10), '->find() accepts single quotes in URLs');
|
||||
$this->assertCount(1, self::$storage->find('127.0.0.1', 'http://foo.bar/"', 10), '->find() accepts double quotes in URLs');
|
||||
$this->assertCount(1, self::$storage->find('127.0.0.1', 'http://foo\\bar/', 10), '->find() accepts backslash in URLs');
|
||||
$this->assertCount(1, self::$storage->find('127.0.0.1', 'http://foo.bar/%', 10), '->find() does not interpret a "%" as a wildcard in the URL');
|
||||
$this->assertCount(1, self::$storage->find('127.0.0.1', 'http://foo.bar/_', 10), '->find() does not interpret a "_" as a wildcard in the URL');
|
||||
|
||||
self::$storage->purge();
|
||||
}
|
||||
@ -147,7 +147,7 @@ class MongoDbProfilerStorageTest extends \PHPUnit_Framework_TestCase
|
||||
$profile = new Profile('token_'.$i);
|
||||
self::$storage->write($profile);
|
||||
}
|
||||
$this->assertEquals(count(self::$storage->find('', '', 10)), 5, '->find() returns all previously added records');
|
||||
$this->assertCount(5, self::$storage->find('', '', 10), '->find() returns all previously added records');
|
||||
self::$storage->purge();
|
||||
}
|
||||
|
||||
@ -161,7 +161,7 @@ class MongoDbProfilerStorageTest extends \PHPUnit_Framework_TestCase
|
||||
self::$storage->write($profile);
|
||||
}
|
||||
$records = self::$storage->find('', '', 3);
|
||||
$this->assertEquals(count($records), 1, '->find() returns only one record');
|
||||
$this->assertCount(1, $records, '->find() returns only one record');
|
||||
$this->assertEquals($records[0]['token'], 'time_2', '->find() returns the latest added record');
|
||||
self::$storage->purge();
|
||||
}
|
||||
|
@ -50,7 +50,8 @@ class SqliteProfilerStorageTest extends \PHPUnit_Framework_TestCase
|
||||
$profile->setMethod('GET');
|
||||
self::$storage->write($profile);
|
||||
}
|
||||
$this->assertEquals(count(self::$storage->find('127.0.0.1', 'http://foo.bar', 20, 'GET')), 10, '->write() stores data in the database');
|
||||
|
||||
$this->assertCount(10, self::$storage->find('127.0.0.1', 'http://foo.bar', 20, 'GET'), '->write() stores data in the database');
|
||||
}
|
||||
|
||||
public function testStoreSpecialCharsInUrl()
|
||||
@ -94,9 +95,9 @@ class SqliteProfilerStorageTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
self::$storage->write($profile);
|
||||
|
||||
$this->assertEquals(count(self::$storage->find('127.0.0.1', '', 10, 'GET')), 1, '->find() retrieve a record by IP');
|
||||
$this->assertEquals(count(self::$storage->find('127.0.%.1', '', 10, 'GET')), 0, '->find() does not interpret a "%" as a wildcard in the IP');
|
||||
$this->assertEquals(count(self::$storage->find('127.0._.1', '', 10, 'GET')), 0, '->find() does not interpret a "_" as a wildcard in the IP');
|
||||
$this->assertCount(1, self::$storage->find('127.0.0.1', '', 10, 'GET'), '->find() retrieve a record by IP');
|
||||
$this->assertCount(0, self::$storage->find('127.0.%.1', '', 10, 'GET'), '->find() does not interpret a "%" as a wildcard in the IP');
|
||||
$this->assertCount(0, self::$storage->find('127.0._.1', '', 10, 'GET'), '->find() does not interpret a "_" as a wildcard in the IP');
|
||||
}
|
||||
|
||||
public function testRetrieveByUrl()
|
||||
@ -131,10 +132,10 @@ class SqliteProfilerStorageTest extends \PHPUnit_Framework_TestCase
|
||||
$profile->setMethod('GET');
|
||||
self::$storage->write($profile);
|
||||
|
||||
$this->assertEquals(count(self::$storage->find('127.0.0.1', 'http://foo.bar/\'', 10, 'GET')), 1, '->find() accepts single quotes in URLs');
|
||||
$this->assertEquals(count(self::$storage->find('127.0.0.1', 'http://foo.bar/"', 10, 'GET')), 1, '->find() accepts double quotes in URLs');
|
||||
$this->assertEquals(count(self::$storage->find('127.0.0.1', 'http://foo\\bar/', 10, 'GET')), 1, '->find() accepts backslash in URLs');
|
||||
$this->assertEquals(count(self::$storage->find('127.0.0.1', 'http://foo.bar/%', 10, 'GET')), 1, '->find() does not interpret a "%" as a wildcard in the URL');
|
||||
$this->assertEquals(count(self::$storage->find('127.0.0.1', 'http://foo.bar/_', 10, 'GET')), 1, '->find() does not interpret a "_" as a wildcard in the URL');
|
||||
$this->assertCount(1, self::$storage->find('127.0.0.1', 'http://foo.bar/\'', 10, 'GET'), '->find() accepts single quotes in URLs');
|
||||
$this->assertCount(1, self::$storage->find('127.0.0.1', 'http://foo.bar/"', 10, 'GET'), '->find() accepts double quotes in URLs');
|
||||
$this->assertCount(1, self::$storage->find('127.0.0.1', 'http://foo\\bar/', 10, 'GET'), '->find() accepts backslash in URLs');
|
||||
$this->assertCount(1, self::$storage->find('127.0.0.1', 'http://foo.bar/%', 10, 'GET'), '->find() does not interpret a "%" as a wildcard in the URL');
|
||||
$this->assertCount(1, self::$storage->find('127.0.0.1', 'http://foo.bar/_', 10, 'GET'), '->find() does not interpret a "_" as a wildcard in the URL');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user