test: replace usage of at() matcher with alternatives
The PHPUnit at() matcher, used to determine the order that methods are called on test doubles, has been deprecated in PHPUnit 9 and has been removed in PHPUnit 10. Migrate usage of at() to other constructs following Drupal core examples in: <https://www.drupal.org/node/3218874>
This commit is contained in:
parent
e182856b4b
commit
6ca3bb6fec
|
|
@ -88,22 +88,12 @@ class HookHelperTest extends Base
|
||||||
->getMock();
|
->getMock();
|
||||||
|
|
||||||
$this->container['template']
|
$this->container['template']
|
||||||
->expects($this->at(0))
|
->expects($this->any())
|
||||||
->method('render')
|
->method('render')
|
||||||
->with(
|
->willReturnMap([
|
||||||
$this->equalTo('tpl1'),
|
['tpl1', array(), 'tpl1_content'],
|
||||||
$this->equalTo(array())
|
['tpl2', array(), 'tpl2_content'],
|
||||||
)
|
]);
|
||||||
->will($this->returnValue('tpl1_content'));
|
|
||||||
|
|
||||||
$this->container['template']
|
|
||||||
->expects($this->at(1))
|
|
||||||
->method('render')
|
|
||||||
->with(
|
|
||||||
$this->equalTo('tpl2'),
|
|
||||||
$this->equalTo(array())
|
|
||||||
)
|
|
||||||
->will($this->returnValue('tpl2_content'));
|
|
||||||
|
|
||||||
$hookHelper = new HookHelper($this->container);
|
$hookHelper = new HookHelper($this->container);
|
||||||
$hookHelper->attach('test', 'tpl1');
|
$hookHelper->attach('test', 'tpl1');
|
||||||
|
|
|
||||||
|
|
@ -148,14 +148,12 @@ class ProjectFileTest extends Base
|
||||||
->method('generateThumbnailFromFile');
|
->method('generateThumbnailFromFile');
|
||||||
|
|
||||||
$this->container['objectStorage']
|
$this->container['objectStorage']
|
||||||
->expects($this->at(0))
|
->expects($this->exactly(2))
|
||||||
->method('moveUploadedFile')
|
->method('moveUploadedFile')
|
||||||
->with($this->equalTo('/tmp/phpYzdqkD'), $this->anything());
|
->withConsecutive(
|
||||||
|
['/tmp/phpYzdqkD'],
|
||||||
$this->container['objectStorage']
|
['/tmp/phpeEwEWG'],
|
||||||
->expects($this->at(1))
|
);
|
||||||
->method('moveUploadedFile')
|
|
||||||
->with($this->equalTo('/tmp/phpeEwEWG'), $this->anything());
|
|
||||||
|
|
||||||
$this->assertTrue($fileModel->uploadFiles(1, $files));
|
$this->assertTrue($fileModel->uploadFiles(1, $files));
|
||||||
|
|
||||||
|
|
@ -232,7 +230,7 @@ class ProjectFileTest extends Base
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->container['objectStorage']
|
$this->container['objectStorage']
|
||||||
->expects($this->at(0))
|
->expects($this->once())
|
||||||
->method('moveUploadedFile')
|
->method('moveUploadedFile')
|
||||||
->with($this->equalTo('/tmp/phpYzdqkD'), $this->anything())
|
->with($this->equalTo('/tmp/phpYzdqkD'), $this->anything())
|
||||||
->will($this->throwException(new \Kanboard\Core\ObjectStorage\ObjectStorageException('test')));
|
->will($this->throwException(new \Kanboard\Core\ObjectStorage\ObjectStorageException('test')));
|
||||||
|
|
|
||||||
|
|
@ -175,14 +175,12 @@ class TaskFileModelTest extends Base
|
||||||
->method('generateThumbnailFromFile');
|
->method('generateThumbnailFromFile');
|
||||||
|
|
||||||
$this->container['objectStorage']
|
$this->container['objectStorage']
|
||||||
->expects($this->at(0))
|
->expects($this->exactly(2))
|
||||||
->method('moveUploadedFile')
|
->method('moveUploadedFile')
|
||||||
->with($this->equalTo('/tmp/phpYzdqkD'), $this->anything());
|
->withConsecutive(
|
||||||
|
['/tmp/phpYzdqkD'],
|
||||||
$this->container['objectStorage']
|
['/tmp/phpeEwEWG'],
|
||||||
->expects($this->at(1))
|
);
|
||||||
->method('moveUploadedFile')
|
|
||||||
->with($this->equalTo('/tmp/phpeEwEWG'), $this->anything());
|
|
||||||
|
|
||||||
$this->assertTrue($fileModel->uploadFiles(1, $files));
|
$this->assertTrue($fileModel->uploadFiles(1, $files));
|
||||||
|
|
||||||
|
|
@ -259,7 +257,7 @@ class TaskFileModelTest extends Base
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->container['objectStorage']
|
$this->container['objectStorage']
|
||||||
->expects($this->at(0))
|
->expects($this->once())
|
||||||
->method('moveUploadedFile')
|
->method('moveUploadedFile')
|
||||||
->with($this->equalTo('/tmp/phpYzdqkD'), $this->anything())
|
->with($this->equalTo('/tmp/phpYzdqkD'), $this->anything())
|
||||||
->will($this->throwException(new \Kanboard\Core\ObjectStorage\ObjectStorageException('test')));
|
->will($this->throwException(new \Kanboard\Core\ObjectStorage\ObjectStorageException('test')));
|
||||||
|
|
@ -411,14 +409,12 @@ class TaskFileModelTest extends Base
|
||||||
$this->assertEquals(1, $fileModel->create(1, 'image.gif', 'tmp/image.gif', 10));
|
$this->assertEquals(1, $fileModel->create(1, 'image.gif', 'tmp/image.gif', 10));
|
||||||
|
|
||||||
$this->container['objectStorage']
|
$this->container['objectStorage']
|
||||||
->expects($this->at(0))
|
->expects($this->exactly(2))
|
||||||
->method('remove')
|
->method('remove')
|
||||||
->with('tmp/image.gif');
|
->withConsecutive(
|
||||||
|
['tmp/image.gif'],
|
||||||
$this->container['objectStorage']
|
['thumbnails'.DIRECTORY_SEPARATOR.'tmp/image.gif'],
|
||||||
->expects($this->at(1))
|
);
|
||||||
->method('remove')
|
|
||||||
->with('thumbnails'.DIRECTORY_SEPARATOR.'tmp/image.gif');
|
|
||||||
|
|
||||||
$this->assertTrue($fileModel->remove(1));
|
$this->assertTrue($fileModel->remove(1));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,20 +51,13 @@ class UserNotificationTest extends Base
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->container['userNotificationTypeModel']
|
$this->container['userNotificationTypeModel']
|
||||||
->expects($this->at(0))
|
->expects($this->exactly(3))
|
||||||
->method('getSelectedTypes')
|
->method('getSelectedTypes')
|
||||||
->will($this->returnValue(array('email')));
|
->willReturnOnConsecutiveCalls(
|
||||||
|
array('email'),
|
||||||
$this->container['userNotificationTypeModel']
|
array('email'),
|
||||||
->expects($this->at(1))
|
array('email','web'),
|
||||||
->method('getSelectedTypes')
|
);
|
||||||
->will($this->returnValue(array('email')));
|
|
||||||
|
|
||||||
$this->container['userNotificationTypeModel']
|
|
||||||
->expects($this->at(2))
|
|
||||||
->method('getSelectedTypes')
|
|
||||||
->with($this->equalTo(1))
|
|
||||||
->will($this->returnValue(array('email', 'web')));
|
|
||||||
|
|
||||||
$settings = $n->readSettings(1);
|
$settings = $n->readSettings(1);
|
||||||
$this->assertNotEmpty($settings);
|
$this->assertNotEmpty($settings);
|
||||||
|
|
@ -209,21 +202,18 @@ class UserNotificationTest extends Base
|
||||||
->method('notifyUser');
|
->method('notifyUser');
|
||||||
|
|
||||||
$this->container['userNotificationTypeModel']
|
$this->container['userNotificationTypeModel']
|
||||||
->expects($this->at(0))
|
->expects($this->once())
|
||||||
->method('getSelectedTypes')
|
->method('getSelectedTypes')
|
||||||
->will($this->returnValue(array('email', 'web')));
|
->will($this->returnValue(array('email', 'web')));
|
||||||
|
|
||||||
$this->container['userNotificationTypeModel']
|
$this->container['userNotificationTypeModel']
|
||||||
->expects($this->at(1))
|
->expects($this->exactly(2))
|
||||||
->method('getType')
|
->method('getType')
|
||||||
->with($this->equalTo('email'))
|
->withConsecutive(
|
||||||
->will($this->returnValue($notifier));
|
['email'],
|
||||||
|
['web'],
|
||||||
$this->container['userNotificationTypeModel']
|
)
|
||||||
->expects($this->at(2))
|
->willReturn($notifier);
|
||||||
->method('getType')
|
|
||||||
->with($this->equalTo('web'))
|
|
||||||
->will($this->returnValue($notifier));
|
|
||||||
|
|
||||||
$userNotificationModel->sendNotifications(TaskModel::EVENT_CREATE, array('task' => $taskFinderModel->getDetails(1)));
|
$userNotificationModel->sendNotifications(TaskModel::EVENT_CREATE, array('task' => $taskFinderModel->getDetails(1)));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue