/** * @test * @covers SlimApp\Db\DbTable::findAll * @uses SlimApp\HasRequiredParamsTrait * @param string $tableName * @param array $keyOperatorValueValueType * @param string $findAllResults 'noResults' if no results expected, 'results' otherwise * @param string $tableName * @param null|string $where * @param null|string $whereLinq The corresponding string to create where clause with YaLinqo * @param null|string $order * @param null|string $orderLinq The corresponding string to create the order clause with YaLinqo * @param null|integer $limit * @param null|integer $offset * @dataProvider provider_findAll_returns_false_when_data_not_present_in_database_data_otherwise */ public function findAll_returns_false_when_data_not_present_in_database_data_otherwise($findAllResults, $tableName, $where, $whereLinq, $order, $orderLinq, $limit, $offset) { $config = (require __DIR__ . '/database-config-for-dbunit.php'); $table = $this->getMockBuilder('SlimApp\\Db\\DbTable')->setConstructorArgs([$config])->getMockForAbstractClass(); $dbTable = new \SebastianBergmann\PeekAndPoke\Proxy($table); // Set tablename manually (set in subclasses, not in abstract class...) $dbTable->tableName = $tableName; $results = $dbTable->findAll($where, $order, $limit, $offset); // Get data as array from dataset (xml seed file) $resources = $this->getTablesFromDataSet()[$tableName]; // ie. users // Query array using a php linq $expected = \YaLinqo\Enumerable::from($resources)->where('$resources ==> $resources' . $whereLinq); if (null !== $orderLinq) { $expected = $expected->orderBy('$resources ==> $resources' . $orderLinq); } // Get expected values as single dimension / one-dimensional array $expected = array_values($expected->toArray()); if (null !== $limit) { if (null === $offset) { $offset = 0; } $expected = array_values(array_slice($expected, $offset, $limit)); } //die(var_dump($results, $expected)); $this->assertEquals($expected, $results); if ('noResults' === $findAllResults) { $this->assertEmpty($results); } }