mirror of
https://github.com/silverstripe/silverstripe-behat-extension
synced 2024-10-22 17:05:32 +02:00
Merge pull request #226 from creative-commoners/pulls/4.10/fix-stepCreateRecordWithTable
BUG Correct method parameters on stepCreateRecordWithTable
This commit is contained in:
commit
b3de55e205
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@ -9,3 +9,5 @@ jobs:
|
|||||||
ci:
|
ci:
|
||||||
name: CI
|
name: CI
|
||||||
uses: silverstripe/gha-ci/.github/workflows/ci.yml@v1
|
uses: silverstripe/gha-ci/.github/workflows/ci.yml@v1
|
||||||
|
with:
|
||||||
|
composer_require_extra: silverstripe/installer:4.13.x-dev
|
||||||
|
@ -235,7 +235,7 @@ use the inline definition syntax. The following example shows some syntax variat
|
|||||||
Scenario: View a page in the tree
|
Scenario: View a page in the tree
|
||||||
Given I am logged in with "ADMIN" permissions
|
Given I am logged in with "ADMIN" permissions
|
||||||
And I go to "/admin/pages"
|
And I go to "/admin/pages"
|
||||||
Then I should see "Page 1" in CMS Tree
|
Then I should see "Page 1"
|
||||||
|
|
||||||
* Fixtures are created where you defined them. If you want the fixtures to be created
|
* Fixtures are created where you defined them. If you want the fixtures to be created
|
||||||
before every scenario, define them in
|
before every scenario, define them in
|
||||||
|
@ -289,22 +289,23 @@ class FixtureContext implements Context
|
|||||||
* @param string $null
|
* @param string $null
|
||||||
* @param TableNode $fieldsTable
|
* @param TableNode $fieldsTable
|
||||||
*/
|
*/
|
||||||
public function stepCreateRecordWithTable($type, $id, $null, TableNode $fieldsTable)
|
public function stepCreateRecordWithTable($type, $id, TableNode $fieldsTable)
|
||||||
{
|
{
|
||||||
|
|
||||||
$class = $this->convertTypeToClass($type);
|
$class = $this->convertTypeToClass($type);
|
||||||
// TODO Support more than one record
|
// TODO Support more than one record
|
||||||
$fields = $this->convertFields($class, $fieldsTable->getRowsHash());
|
$fields = $this->convertFields($class, $fieldsTable->getRowsHash());
|
||||||
$fields = $this->prepareFixture($class, $id, $fields);
|
$fields = $this->prepareFixture($class, $id, $fields);
|
||||||
|
|
||||||
// We should check if this fixture object already exists - if it does, we update it. If not, we create it
|
// We should check if this fixture object already exists - if it does, we update it. If not, we create it
|
||||||
if ($existingFixture = $this->fixtureFactory->get($class, $id)) {
|
if ($existingFixture = $this->getFixtureFactory()->get($class, $id)) {
|
||||||
// Merge existing data with new data, and create new object to replace existing object
|
// Merge existing data with new data, and create new object to replace existing object
|
||||||
foreach ($fields as $k => $v) {
|
foreach ($fields as $k => $v) {
|
||||||
$existingFixture->$k = $v;
|
$existingFixture->$k = $v;
|
||||||
}
|
}
|
||||||
$existingFixture->write();
|
$existingFixture->write();
|
||||||
} else {
|
} else {
|
||||||
$this->fixtureFactory->createObject($class, $id, $fields);
|
$this->getFixtureFactory()->createObject($class, $id, $fields);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user