public function CurrencyFormTest::testCopyFormValuesToEntity in Currency 8.3
@covers ::copyFormValuesToEntity
File
- tests/
src/ Unit/ Entity/ Currency/ CurrencyFormTest.php, line 125
Class
- CurrencyFormTest
- @coversDefaultClass \Drupal\currency\Entity\Currency\CurrencyForm
Namespace
Drupal\Tests\currency\Unit\Entity\CurrencyCode
public function testCopyFormValuesToEntity() {
$currency_code = $this
->randomMachineName();
$currency_number = $this
->randomMachineName();
$currency_label = $this
->randomMachineName();
$currency_sign = $this
->randomMachineName();
$currency_subunits = mt_rand();
$currency_rounding_step = mt_rand();
$currency_status = TRUE;
$this->currency
->expects($this
->once())
->method('setCurrencyCode')
->with($currency_code);
$this->currency
->expects($this
->once())
->method('setCurrencyNumber')
->with($currency_number);
$this->currency
->expects($this
->once())
->method('setLabel')
->with($currency_label);
$this->currency
->expects($this
->once())
->method('setSign')
->with($currency_sign);
$this->currency
->expects($this
->once())
->method('setSubunits')
->with($currency_subunits);
$this->currency
->expects($this
->once())
->method('setRoundingStep')
->with($currency_rounding_step);
$this->currency
->expects($this
->once())
->method('setStatus')
->with($currency_status);
$form = array();
$form_state = $this
->createMock(FormStateInterface::class);
$form_state
->expects($this
->atLeastOnce())
->method('getValues')
->willReturn(array(
'currency_code' => $currency_code,
'currency_number' => $currency_number,
'label' => $currency_label,
'sign' => $currency_sign,
'subunits' => $currency_subunits,
'rounding_step' => $currency_rounding_step,
'status' => $currency_status,
));
$method = new \ReflectionMethod($this->sut, 'copyFormValuesToEntity');
$method
->setAccessible(TRUE);
$method
->invokeArgs($this->sut, array(
$this->currency,
$form,
$form_state,
));
}