public function PaymentStatusFormTest::testCopyFormValuesToEntity in Payment 8.2
@covers ::copyFormValuesToEntity
File
- tests/
src/ Unit/ Entity/ PaymentStatus/ PaymentStatusFormTest.php, line 221
Class
- PaymentStatusFormTest
- @coversDefaultClass \Drupal\payment\Entity\PaymentStatus\PaymentStatusForm
Namespace
Drupal\Tests\payment\Unit\Entity\PaymentStatusCode
public function testCopyFormValuesToEntity() {
$description = $this
->randomMachineName();
$id = $this
->randomMachineName();
$label = $this
->randomMachineName();
$parent_id = $this
->randomMachineName();
$this->paymentStatus
->expects($this
->once())
->method('setDescription')
->with($description);
$this->paymentStatus
->expects($this
->once())
->method('setId')
->with($id);
$this->paymentStatus
->expects($this
->once())
->method('setLabel')
->with($label);
$this->paymentStatus
->expects($this
->once())
->method('setParentId')
->with($parent_id);
$parent_status = $this
->createMock(PluginSelectorInterface::class);
$parent_status
->expects($this
->atLeastOnce())
->method('getPluginId')
->willReturn($parent_id);
$parent_selector = $this
->createMock(PluginSelectorInterface::class);
$parent_selector
->expects($this
->atLeastOnce())
->method('getSelectedPlugin')
->willReturn($parent_status);
$this->pluginSelectorManager
->expects($this
->atLeastOnce())
->method('createInstance')
->willReturn($parent_selector);
$form = [];
$form_state = new FormState();
$form_state
->setValue('description', $description);
$form_state
->setValue('id', $id);
$form_state
->setValue('label', $label);
$form_state
->setValue('parent_id', $parent_id);
$method = new \ReflectionMethod($this->sut, 'copyFormValuesToEntity');
$method
->setAccessible(TRUE);
$method
->invokeArgs($this->sut, array(
$this->paymentStatus,
$form,
$form_state,
));
}