当前位置: 首页>>代码示例>>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;未经允许,请勿转载。