mirror of
https://github.com/silverstripe/silverstripe-behat-extension
synced 2024-10-22 17:05:32 +02:00
In stepCreateRecordWithTable, if a fixture already exists then update that record
rather than create a new, identical fixture.
This commit is contained in:
parent
79dd361e24
commit
fe77d1dacb
@ -183,8 +183,18 @@ class FixtureContext extends BehatContext
|
|||||||
if($class == 'File' || is_subclass_of($class, 'File')) {
|
if($class == 'File' || is_subclass_of($class, 'File')) {
|
||||||
$fields = $this->prepareAsset($class, $id, $fields);
|
$fields = $this->prepareAsset($class, $id, $fields);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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)) {
|
||||||
|
// Merge existing data with new data, and create new object to replace existing object
|
||||||
|
foreach($fields as $k => $v) {
|
||||||
|
$existingFixture->$k = $v;
|
||||||
|
}
|
||||||
|
$existingFixture->write();
|
||||||
|
} else {
|
||||||
$this->fixtureFactory->createObject($class, $id, $fields);
|
$this->fixtureFactory->createObject($class, $id, $fields);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Example: Given the "page" "Page 1.1" is a child of the "page" "Page1"
|
* Example: Given the "page" "Page 1.1" is a child of the "page" "Page1"
|
||||||
|
Loading…
Reference in New Issue
Block a user