本文整理匯總了PHP中lithium\util\Set::append方法的典型用法代碼示例。如果您正苦於以下問題:PHP Set::append方法的具體用法?PHP Set::append怎麽用?PHP Set::append使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類lithium\util\Set
的用法示例。
在下文中一共展示了Set::append方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testAppend
public function testAppend() {
$array1 = array('ModelOne' => array(
'id' => 1001, 'field_one' => 'a1.m1.f1', 'field_two' => 'a1.m1.f2'
));
$array2 = array('ModelTwo' => array(
'id' => 1002, 'field_one' => 'a2.m2.f1', 'field_two' => 'a2.m2.f2'
));
$result = Set::append($array1, $array2);
$this->assertIdentical($result, $array1 + $array2);
$array3 = array('ModelOne' => array(
'id' => 1003, 'field_one' => 'a3.m1.f1',
'field_two' => 'a3.m1.f2', 'field_three' => 'a3.m1.f3'
));
$result = Set::append($array1, $array3);
$expected = array('ModelOne' => array(
'id' => 1001, 'field_one' => 'a1.m1.f1',
'field_two' => 'a1.m1.f2', 'field_three' => 'a3.m1.f3'
));
$this->assertIdentical($expected, $result);
$array1 = array(
array('ModelOne' => array(
'id' => 1001, 'field_one' => 's1.0.m1.f1', 'field_two' => 's1.0.m1.f2'
)),
array('ModelTwo' => array(
'id' => 1002, 'field_one' => 's1.1.m2.f2', 'field_two' => 's1.1.m2.f2'
))
);
$array2 = array(
array('ModelOne' => array(
'id' => 1001, 'field_one' => 's2.0.m1.f1', 'field_two' => 's2.0.m1.f2'
)),
array('ModelTwo' => array(
'id' => 1002, 'field_one' => 's2.1.m2.f2', 'field_two' => 's2.1.m2.f2'
))
);
$result = Set::append($array1, $array2);
$this->assertIdentical($result, $array1);
$array3 = array(array('ModelThree' => array(
'id' => 1003, 'field_one' => 's3.0.m3.f1', 'field_two' => 's3.0.m3.f2'
)));
$result = Set::append($array1, $array3);
$expected = array(
array(
'ModelOne' => array(
'id' => 1001, 'field_one' => 's1.0.m1.f1', 'field_two' => 's1.0.m1.f2'
),
'ModelThree' => array(
'id' => 1003, 'field_one' => 's3.0.m3.f1', 'field_two' => 's3.0.m3.f2'
)
),
array('ModelTwo' => array(
'id' => 1002, 'field_one' => 's1.1.m2.f2', 'field_two' => 's1.1.m2.f2'
))
);
$this->assertIdentical($expected, $result);
$result = Set::append($array1, array());
$this->assertIdentical($result, $array1);
$result = Set::append($array1, $array2);
$this->assertIdentical($result, $array1 + $array2);
$result = Set::append(array(), array('2'));
$this->assertIdentical(array('2'), $result);
}