Skip to content

Commit

Permalink
Merge pull request #24 from thenotsoft/fix-populate-item
Browse files Browse the repository at this point in the history
Fix ItemsStorage::populateItem and test
  • Loading branch information
thenotsoft committed Sep 9, 2022
2 parents 3a338e8 + d039202 commit 1776fef
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/ItemsStorage.php
Expand Up @@ -272,7 +272,7 @@ private function populateItem(array $attributes): Item
{
return $this->createItemByTypeAndName($attributes['type'], $attributes['name'])
->withDescription($attributes['description'] ?? '')
->withRuleName($attributes['ruleName'] ?? '')
->withRuleName($attributes['ruleName'] ?? null)
->withCreatedAt((int)$attributes['createdAt'])
->withUpdatedAt((int)$attributes['updatedAt']);
}
Expand Down
6 changes: 3 additions & 3 deletions tests/ItemsStorageTest.php
Expand Up @@ -15,14 +15,14 @@ public function testUpdate(): void
{
$storage = $this->getStorage();
$item = $storage->get('Parent 1');
$this->assertEmpty($item->getRuleName());
$this->assertNull($item->getRuleName());

$item = $item
->withName('Super Admin')
->withRuleName('super admin');
$storage->update('Parent 1', $item);
$this->assertSame('Super Admin', $storage->get('Super Admin')->getName());
$this->assertSame('super admin', $storage->get('Super Admin')->getRuleName());
$this->assertSame('Super Admin', $storage->get('Super Admin')?->getName());
$this->assertSame('super admin', $storage->get('Super Admin')?->getRuleName());
}

public function testGet(): void
Expand Down

0 comments on commit 1776fef

Please sign in to comment.