예제 #1
0
 /**
  * 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
0
 /**
  * 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
0
 /**
  * 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);
 }