本文整理匯總了PHP中Cake\Utility\Hash::nest方法的典型用法代碼示例。如果您正苦於以下問題:PHP Hash::nest方法的具體用法?PHP Hash::nest怎麽用?PHP Hash::nest使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Cake\Utility\Hash
的用法示例。
在下文中一共展示了Hash::nest方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testNestInvalid
/**
* Tests that nest() throws an InvalidArgumentException when providing an invalid input.
*
* @expectedException \InvalidArgumentException
* @return void
*/
public function testNestInvalid()
{
$input = array(array('ParentCategory' => array('id' => '1', 'name' => 'Lorem ipsum dolor sit amet', 'parent_id' => '1')));
Hash::nest($input);
}
示例2: testNestInvalid
/**
* Tests that nest() throws an InvalidArgumentException when providing an invalid input.
*
* @expectedException \InvalidArgumentException
* @return void
*/
public function testNestInvalid()
{
$input = [['ParentCategory' => ['id' => '1', 'name' => 'Lorem ipsum dolor sit amet', 'parent_id' => '1']]];
Hash::nest($input);
}
示例3: testMissingParent
/**
* test Hash nest with no specified parent data.
*
* The result should be the same as the input.
* For an easier comparison, unset all the empty children arrays from the result
*
* @return void
*/
public function testMissingParent()
{
$input = array(array('id' => 1), array('id' => 2), array('id' => 3), array('id' => 4), array('id' => 5), array('id' => 6), array('id' => 7), array('id' => 8), array('id' => 9), array('id' => 10));
$result = Hash::nest($input, array('idPath' => '{n}.id', 'parentPath' => '{n}.parent_id'));
foreach ($result as &$row) {
if (empty($row['children'])) {
unset($row['children']);
}
}
$this->assertEquals($input, $result);
}