/** * @test * @param string $tableName * @param array $setColumnNamesValues * @param null|string $where * @param null|string $whereLinq The corresponding string to create where clause with YaLinqo * @uses SlimApp\Db\DbTable::findRow * @dataProvider provider_update_updates_data_correctly_and_returns_true_on_success */ public function update_updates_data_correctly_and_returns_true_on_success($tableName, $setColumnNamesValues, $where, $whereLinq) { $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; $resultUpdate = $dbTable->update($setColumnNamesValues, $where); $result = $dbTable->findRow($where); // 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)->toArray(); // Substitute data in array $expected = array_merge($expected[0], $setColumnNamesValues); //die(var_dump($result, $expected)); $this->assertTrue($resultUpdate); $this->assertEquals($expected, $result); }