Commit 495e46d4 authored by Jeremy Mikola's avatar Jeremy Mikola

Declare Collection methods alphabetically by visibility

We can move this to a separate, pedantic test class later.
parent b6a120e0
This diff is collapsed.
......@@ -6,7 +6,7 @@ use MongoDB\Driver\Manager;
class CollectionTest extends PHPUnit_Framework_TestCase {
function setUp() {
require __DIR__ . "/" . "utils.inc";
require_once __DIR__ . "/" . "utils.inc";
$this->faker = Faker\Factory::create();
$this->faker->seed(1234);
......@@ -44,5 +44,28 @@ class CollectionTest extends PHPUnit_Framework_TestCase {
}
$this->assertEquals(0, $n);
}
public function testMethodOrder()
{
$class = new ReflectionClass('MongoDB\Collection');
$filters = array(
'public' => ReflectionMethod::IS_PUBLIC,
'protected' => ReflectionMethod::IS_PROTECTED,
'private' => ReflectionMethod::IS_PRIVATE,
);
foreach ($filters as $visibility => $filter) {
$methods = array_map(
function(ReflectionMethod $method) { return $method->getName(); },
$class->getMethods($filter)
);
$sortedMethods = $methods;
sort($sortedMethods);
$this->assertEquals($methods, $sortedMethods, sprintf('%s methods are declared alphabetically', ucfirst($visibility)));
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment