本文整理匯總了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());
}