Skip to content

Commit

Permalink
refactor: add isEmpty method, test it
Browse files Browse the repository at this point in the history
  • Loading branch information
shpran committed Oct 7, 2021
1 parent 5c758c8 commit a7208a2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions core/resource/DependsOnPropertyCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ static function (core_kernel_classes_Property $property) {
);
}

public function isEmpty(): bool
{
return $this->count() === 0;
}

private function areArraysEqual(array $array1, array $array2): bool
{
return empty(array_diff($array1, $array2)) && empty(array_diff($array2, $array1));
Expand Down
8 changes: 8 additions & 0 deletions test/unit/core/resource/DependsOnPropertyCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,12 @@ public function testGetPropertyUris(): void
$this->sut->append($secondProperty);
$this->assertEquals(['firstProperty', 'secondProperty'], $this->sut->getPropertyUris());
}

public function testIsEmpty(): void
{
$this->assertTrue($this->sut->isEmpty());

$this->sut->append('value');
$this->assertFalse($this->sut->isEmpty());
}
}

0 comments on commit a7208a2

Please sign in to comment.