/** * zkontroluje vystup * * @param string $jsonFilePath * @throws \Exception */ public function assertJsonFileEqual($jsonFilePath) { if (!file_exists($jsonFilePath)) { throw new \Exception("file '{$jsonFilePath}' does not found"); } $json = file_get_contents($jsonFilePath); $data = $this->jsonDecode($json); foreach ($data as $tableName => $info) { $primaryKeys = $this->getPrimaryKeys($tableName, $info); $expected = array_key_exists('items', $info) ? $info['items'] : $info; $actual = $this->pdo->query("SELECT " . $this->getColumnString($expected) . " FROM {$tableName}")->fetchAll(PDO::FETCH_ASSOC); $errors = $this->comparator->compare($expected, $actual, $primaryKeys); $this->testCase->addToAssertionCount(max(count($expected), count($actual))); if (count($errors)) { $this->testCase->fail($this->errorPrinter->getString($tableName, $errors, $primaryKeys)); } } }