Skip to content

Commit

Permalink
FIX Remove implicitly added item
Browse files Browse the repository at this point in the history
  • Loading branch information
Sabina Talipova committed Oct 24, 2023
1 parent 302aa4c commit d0c0890
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
5 changes: 0 additions & 5 deletions src/ChangeSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,11 +298,6 @@ protected function calculateImplicit()
*/
public function sync()
{
// Only sync open changesets
if ($this->State !== static::STATE_OPEN) {
return;
}

// Start a transaction (if we can)
DB::get_conn()->withTransaction(function () {

Expand Down
28 changes: 28 additions & 0 deletions tests/php/ChangeSetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -735,4 +735,32 @@ public function testIsSyncedCanBeSkipped()

$this->assertFalse($changeset->isSyncCalled, 'isSynced is skipped when providing truthy argument to publish');
}

public function testRemoveObject()
{
$this->publishAllFixtures();

$mid1 = $this->objFromFixture(ChangeSetTest\MidObject::class, 'mid1');
$mid2 = $this->objFromFixture(ChangeSetTest\MidObject::class, 'mid2');

$changeset = new ChangeSet();
$changeset->write();
$changeset->addObject($mid1);
$changeset->addObject($mid2);
$changeset->publish();

$changeset->removeObject($mid1);

$this->assertChangeSetLooksLike(
$changeset,
[
ChangeSetTest\MidObject::class . '.mid2' => ChangeSetItem::EXPLICITLY,
ChangeSetTest\EndObject::class . '.end2' => ChangeSetItem::IMPLICITLY,
]
);

$changeset->removeObject($mid2);

$this->assertChangeSetLooksLike($changeset, []);
}
}

0 comments on commit d0c0890

Please sign in to comment.