Skip to content

Commit

Permalink
chore: fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shpran committed Nov 15, 2024
1 parent d6c2e29 commit 2b65377
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,10 @@ public function testCreate(): void
)
->willReturn($resourceTransferResult);

$this->eventManager
$this->translatedIntoLanguagesSynchronizer
->expects($this->once())
->method('trigger');
->method('sync')
->with($instance);

$this->assertInstanceOf(
core_kernel_classes_Resource::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ public function testDelete(): void
$translation = new ResourceTranslation($translationResourceId, 'something');
$resourceCollection = new ResourceCollection($translation);

$resource = $this->createMock(core_kernel_classes_Resource::class);
$translationResource = $this->createMock(core_kernel_classes_Resource::class);
$originalResource = $this->createMock(core_kernel_classes_Resource::class);

$this->resourceTranslationRepository
->expects($this->once())
Expand All @@ -103,14 +104,15 @@ public function testDelete(): void
$this->ontology
->expects($this->once())
->method('getResource')
->with($translationResourceId)
->willReturn($resource);
->withConsecutive([$translationResourceId], ['id1'])
->willReturnOnConsecutiveCalls($translationResource, $originalResource);

$this->eventManager
$this->translatedIntoLanguagesSynchronizer
->expects($this->once())
->method('trigger');
->method('sync')
->with($originalResource);

$this->assertSame($resource, $this->service->deleteByRequest($request));
$this->assertSame($translationResource, $this->service->deleteByRequest($request));
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,10 @@ public function testSync(): void
->method('__invoke')
->with($translationResource);

$this->eventManager
$this->translatedIntoLanguagesSynchronizer
->expects($this->once())
->method('trigger');
->method('sync')
->with($resource);

$this->sut->addSynchronizer('rootId', $callable);
$this->assertEquals($resource, $this->sut->syncByRequest($request));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ public function testUpdateSuccess(): void
]
);

$this->translatedIntoLanguagesSynchronizer
->expects($this->once())
->method('sync')
->with($resource);

$this->assertSame(
$resource,
$this->service->update(
Expand Down

0 comments on commit 2b65377

Please sign in to comment.