Skip to content

Commit

Permalink
fix: Test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Nevermind23 committed Dec 5, 2024
1 parent b7b3d72 commit 7cf6d4d
Showing 1 changed file with 9 additions and 25 deletions.
34 changes: 9 additions & 25 deletions test/unit/models/classes/resources/Service/ClassDeleterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -835,38 +835,24 @@ static function (string $uri): bool {
$this->sut->delete($class);
}

public function testDeleteSkipsNonExistentInstances(): void
public function testDeleteNonExistingInstance(): void
{
$this->rootClassSpecification
->expects($this->once())
->method('isSatisfiedBy')
->willReturn(false);

$this->permissionChecker
->expects($this->exactly(2))
->expects($this->once())
->method('hasReadAccess')
->willReturn(true);
$this->permissionChecker
->expects($this->once())
->method('hasWriteAccess')
->willReturn(true);

$this->resourceRepository
->expects($this->once())
->method('delete');

$existingInstance = $this->createMock(core_kernel_classes_Resource::class);
$existingInstance
->expects($this->once())
->method('getUri')
->willReturn('existingInstanceUri');
$existingInstance
->expects($this->once())
->method('exists')
->willReturn(true);

$nonExistingInstance = $this->createMock(core_kernel_classes_Resource::class);
$nonExistingInstance
$classInstance = $this->createMock(core_kernel_classes_Resource::class);
$classInstance
->expects($this->once())
->method('exists')
->willReturn(false);
Expand All @@ -876,19 +862,17 @@ public function testDeleteSkipsNonExistentInstances(): void
->expects($this->once())
->method('getUri')
->willReturn('classUri');
$class
->expects($this->once())
->method('getSubClasses')
->willReturn([]);
$class
->expects($this->once())
->method('getInstances')
->willReturn([$nonExistingInstance, $existingInstance]);
->willReturn([$classInstance]);
$class
->expects($this->never())
->method('getProperties');
$class
->expects($this->once())
->method('exists')
->willReturn(true);

$this->expectException(PartialClassDeletionException::class);

$this->sut->delete($class);
}
Expand Down

0 comments on commit 7cf6d4d

Please sign in to comment.