sort = Sort::create('insertion'); $this->assertInstanceOf('OSInet\Sort\SortInterface', $this->sort); // Roughly 4 seconds on my 2011 MacBook Pro $this->expected = range(1, 1000); } protected function genericTest($source, $expected = NULL) { $actual = $this->sort->sort($source, function ($a, $b) { return $a - $b; }); if (!isset($expected)) { $expected = $this->expected; } $this->assertEquals($expected, $actual); } public function testEmpty() { $this->genericTest(array(), array()); } public function testSorted() { $source = $this->expected; $this->genericTest($source); } public function testReverted() { $source = array_reverse($this->expected); $this->genericTest($source); } public function testRandom() { $passes = 10; $source = $this->expected; for ($i = 0 ; $i < $passes ; $i++) { shuffle($source); $this->genericTest($source); } } }