本文整理汇总了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']));
}
示例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());
}