當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Mock::toArray方法代碼示例

本文整理匯總了PHP中Mockery\Mock::toArray方法的典型用法代碼示例。如果您正苦於以下問題:PHP Mock::toArray方法的具體用法?PHP Mock::toArray怎麽用?PHP Mock::toArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Mockery\Mock的用法示例。


在下文中一共展示了Mock::toArray方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testToArray

 public function testToArray()
 {
     $this->transfer->shouldReceive('getProperties')->andReturn(['prop_normal' => ['is_multiple' => false], 'prop_multi' => ['is_multiple' => true], 'prop_normal_type' => ['is_multiple' => false, 'type' => '\\Hitmeister\\Component\\Api\\Transfers\\StatusPingTransfer'], 'prop_multi_type' => ['is_multiple' => true, 'type' => '\\Hitmeister\\Component\\Api\\Transfers\\StatusPingTransfer'], 'not_in_data' => ['is_multiple' => true]]);
     $data = ['prop_normal' => 'hello', 'prop_multi' => ['hello', 'world'], 'prop_normal_type' => ['message' => 'hello'], 'prop_multi_type' => [['message' => 'hello'], ['message' => 'world']], 'prop_is_invalid' => 'hello'];
     $this->transfer->fromArray($data);
     $result = $this->transfer->toArray();
     $this->assertArrayNotHasKey('not_in_data', $result);
     $this->assertArrayHasKey('prop_normal', $result);
     $this->assertArrayHasKey('prop_multi', $result);
     $this->assertArrayHasKey('prop_normal_type', $result);
     $this->assertArrayHasKey('prop_multi_type', $result);
     $this->assertArrayNotHasKey('prop_is_invalid', $result);
     $this->assertTrue(is_array($result['prop_multi']));
     $this->assertTrue(is_array($result['prop_normal_type']));
     $this->assertTrue(is_array($result['prop_multi_type']));
     $this->assertEquals('hello', $result['prop_normal']);
     $this->assertEquals(2, count($result['prop_multi']));
     $this->assertEquals(1, count($result['prop_normal_type']));
     $this->assertEquals(2, count($result['prop_multi_type']));
 }
開發者ID:hitmeister,項目名稱:api-sdk-php,代碼行數:20,代碼來源:AbstractTransferTest.php

示例2: it_should_convert_to_array

 /**
  * @test
  */
 public function it_should_convert_to_array()
 {
     $this->assertEquals(['field1' => 'value1', 'field2' => 'value2', 'nested' => ['nested_field' => 'nested_value']], $this->result->toArray());
 }
開發者ID:geekybeaver,項目名稱:larasearch,代碼行數:7,代碼來源:ResultTest.php


注:本文中的Mockery\Mock::toArray方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。