fixed type error in test for timebasefieldupdater

This commit is contained in:
naomi 2022-06-07 13:57:49 +01:00
parent b70697995a
commit 44b9680e0c

View File

@ -17,24 +17,24 @@ class TimeBasedFieldUpdaterTest extends UnitTestCase{
} }
function testFieldIsUpdatedOnEntityReturnedByQuery():void { function testFieldIsUpdatedOnEntityReturnedByQuery():void {
$this->query->method('execute')->willReturn([1]); $this->query->method('execute')->willReturn(['1']);
$this->entity = $this->getMockBuilder('\\Drupal\\Core\\Entity\\EntityBase')->disableOriginalConstructor()->getMock(); $this->entity = $this->getMockBuilder('\\Drupal\\Core\\Entity\\EntityBase')->disableOriginalConstructor()->getMock();
$this->storage->expects($this->once())->method('load')->with(1)->willReturn($this->entity); $this->storage->expects($this->once())->method('load')->with(1)->willReturn($this->entity);
$this->updater->update([], '3 months', ['dummy_field' => 4]); $this->updater->update([], '3 months', ['dummy_field' => 4]);
$this->assertEquals($this->entity->dummy_field, 4); $this->assertEquals($this->entity->dummy_field, 4);
} }
function testFieldIsUpdatedOnAllEntitiesReturnedByQuery():void { function testFieldIsUpdatedOnAllEntitiesReturnedByQuery():void {
$this->query->method('execute')->willReturn([1, 2]); $this->query->method('execute')->willReturn(['1', '2']);
$entity = $this->getEntity(); $entity = $this->getEntity();
$entity2 = $this->getEntity(); $entity2 = $this->getEntity();
$this->storage->method('load')->willReturnMap([[1, $entity], [2, $entity2]]); $this->storage->method('load')->willReturnMap([['1', $entity], ['2', $entity2]]);
$this->updater->update([], '3 months', ['dummy_field' => 4]); $this->updater->update([], '3 months', ['dummy_field' => 4]);
$this->assertEquals($entity->dummy_field, 4); $this->assertEquals($entity->dummy_field, 4);
$this->assertEquals($entity2->dummy_field, 4); $this->assertEquals($entity2->dummy_field, 4);
} }
function testMultipleFieldsAreUpdated(): void { function testMultipleFieldsAreUpdated(): void {
$this->query->method('execute')->willReturn([1]); $this->query->method('execute')->willReturn(['1']);
$entity = $this->getEntity(); $entity = $this->getEntity();
$this->storage->expects($this->once())->method('load')->with(1)->willReturn($entity); $this->storage->expects($this->once())->method('load')->with(1)->willReturn($entity);
$this->updater->update([], '3 months', ['dummy_field' => 4, 'dummy_field_2' => 5]); $this->updater->update([], '3 months', ['dummy_field' => 4, 'dummy_field_2' => 5]);