本文整理汇总了PHP中Drupal\Core\Datetime\DateFormatter::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP DateFormatter::expects方法的具体用法?PHP DateFormatter::expects怎么用?PHP DateFormatter::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Datetime\DateFormatter
的用法示例。
在下文中一共展示了DateFormatter::expects方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testPreRender
/**
* @covers ::preRender
*/
public function testPreRender()
{
$payment_status_created = mt_rand();
$payment_status = $this->getMock(PaymentStatusInterface::class);
$payment_status->expects($this->atLeastOnce())->method('getCreated')->willReturn($payment_status_created);
$this->dateFormatter->expects($this->once())->method('format')->with($payment_status_created);
$element = array('#payment_statuses' => [$payment_status]);
$build = $this->sut->preRender($element);
$this->assertSame('table', $build['table']['#type']);
}
示例2: testBuildRow
/**
* @covers ::buildRow
*
* @dataProvider providerTestBuildRow
*
* @depends testBuildOperations
*/
function testBuildRow($payment_currency_exists)
{
$payment_changed_time = time();
$payment_changed_time_formatted = $this->randomMachineName();
$payment_currency_code = $this->randomMachineName();
$payment_amount = mt_rand();
$payment_amount_formatted = $this->randomMachineName();
$payment_status_definition = array('label' => $this->randomMachineName());
$payment_status = $this->getMock(PaymentStatusInterface::class);
$payment_status->expects($this->any())->method('getPluginDefinition')->willReturn($payment_status_definition);
$owner = $this->getMock(UserInterface::class);
$payment_method_label = $this->randomMachineName();
$payment_method_definition = ['label' => $payment_method_label];
$payment_method = $this->getMock(PaymentMethodInterface::class);
$payment_method->expects($this->atLeastOnce())->method('getPluginDefinition')->willReturn($payment_method_definition);
$payment = $this->getMock(PaymentInterface::class);
$payment->expects($this->any())->method('getAmount')->willReturn($payment_amount);
$payment->expects($this->any())->method('getChangedTime')->willReturn($payment_changed_time);
$payment->expects($this->any())->method('getCurrencyCode')->willReturn($payment_currency_code);
$payment->expects($this->any())->method('getOwner')->willReturn($owner);
$payment->expects($this->any())->method('getPaymentMethod')->willReturn($payment_method);
$payment->expects($this->any())->method('getPaymentStatus')->willReturn($payment_status);
$currency = $this->getMock(CurrencyInterface::class);
$currency->expects($this->once())->method('formatAmount')->with($payment_amount)->willReturn($payment_amount_formatted);
$map = array(array($payment_currency_code, $payment_currency_exists ? $currency : NULL), array('XXX', $payment_currency_exists ? NULL : $currency));
$this->currencyStorage->expects($this->atLeastOnce())->method('load')->willReturnMap($map);
$this->dateFormatter->expects($this->once())->method('format')->with($payment_changed_time)->willReturn($payment_changed_time_formatted);
$this->moduleHandler->expects($this->any())->method('invokeAll')->willReturn([]);
$build = $this->sut->buildRow($payment);
unset($build['data']['operations']['data']['#attached']);
$expected_build = array('data' => array('updated' => $payment_changed_time_formatted, 'status' => $payment_status_definition['label'], 'amount' => $payment_amount_formatted, 'payment_method' => $payment_method_label, 'owner' => array('data' => array('#theme' => 'username', '#account' => $owner)), 'operations' => array('data' => array('#type' => 'operations', '#links' => []))));
$this->assertSame($expected_build, $build);
}
示例3: testFormatTimeDiffSince
/**
* Tests the formatTimeDiffSince method.
*
* @covers ::formatTimeDiffSince
*/
public function testFormatTimeDiffSince()
{
$expected = '1 second';
$timestamp = $this->createTimestamp('2013-12-11 10:09:07');
$request_time = $this->createTimestamp('2013-12-11 10:09:08');
$options = array();
// Mocks the formatDiff function of the dateformatter object.
$this->dateFormatterStub->expects($this->any())->method('formatDiff')->with($request_time, $timestamp, $options)->will($this->returnValue($expected));
$request = Request::createFromGlobals();
$request->server->set('REQUEST_TIME', $request_time);
// Mocks a the request stack getting the current request.
$this->requestStack->expects($this->any())->method('getCurrentRequest')->willReturn($request);
$this->assertEquals($expected, $this->dateFormatterStub->formatTimeDiffUntil($timestamp, $options));
}