Skip to content

Commit

Permalink
test del
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Jan 11, 2022
1 parent 656e64a commit 2423e81
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/ModelNestedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,35 @@ public function testUpdate(): void
['id' => 2, 'name' => 'Susan', 'birthday' => new \DateTime('2020-10-10')],
], $m->export());
}

public function testDelete(): void
{
$m = $this->createTestModel();

$m->load(2)->delete();

$this->assertSame([
['main', Model::HOOK_BEFORE_LOAD, [2]],
['inner', Persistence\Sql::HOOK_INIT_SELECT_QUERY, [Query::class, 'select']],
['main', Persistence\Sql::HOOK_INIT_SELECT_QUERY, [Query::class, 'select']],
['main', Model::HOOK_AFTER_LOAD, []],
['main', Model::HOOK_BEFORE_DELETE, []],
['inner', Model::HOOK_BEFORE_LOAD, [2]],
['inner', Persistence\Sql::HOOK_INIT_SELECT_QUERY, [Query::class, 'select']],
['inner', Model::HOOK_AFTER_LOAD, []],
['inner', Model::HOOK_BEFORE_DELETE, []],
['inner', Persistence\Sql::HOOK_BEFORE_DELETE_QUERY, [Query::class]],
['inner', Persistence\Sql::HOOK_AFTER_DELETE_QUERY, [Query::class, DbalResult::class]],
['inner', Model::HOOK_AFTER_DELETE, []],
['inner', Model::HOOK_BEFORE_UNLOAD, []],
['inner', Model::HOOK_AFTER_UNLOAD, []],
['main', Model::HOOK_AFTER_DELETE, []],
['main', Model::HOOK_BEFORE_UNLOAD, []],
['main', Model::HOOK_AFTER_UNLOAD, []],
], $this->hookLog);

$this->assertSameExportUnordered([
['id' => 1, 'name' => 'John', 'birthday' => new \DateTime('1980-2-1')],
], $m->export());
}
}

0 comments on commit 2423e81

Please sign in to comment.