Skip to content

Commit

Permalink
Added API client creator and general entity creator helper methods (#17)
Browse files Browse the repository at this point in the history
* Added API client creator and general entity creator helper methods

* Moved up client creation to storage
  • Loading branch information
emulgeator authored Sep 1, 2017
1 parent 5cb4645 commit 56fe3c3
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/Test/Integration/TDbContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,29 @@ trait TDbContext
*/
abstract public function getDbConnection();


protected function createEntity(string $tableName, array $rows)
{
foreach ($rows as $row) {
$queryParams = [];
$sets = [];

foreach ($row as $columnName => $value) {
$queryParams[$columnName] = $value;
$sets[] = $columnName . ' = :' . $columnName;
}

$insert = '
INSERT INTO
' . $tableName . '
SET
' . implode(', ', $sets) . '
';

$this->getDbConnection()->query($insert, $queryParams);
}
}

/**
* @Then the :tableName table should be empty
*/
Expand Down

0 comments on commit 56fe3c3

Please sign in to comment.