Example #1
0
 public function testCreateFromArrayBug81()
 {
     $array = [['title' => 'About', 'children' => [['title' => 'Testimonials', 'children' => [['title' => 'child 1'], ['title' => 'child 2']]]]], ['title' => 'Blog'], ['title' => 'Portfolio']];
     $pages = Page::createFromArray($array);
     $about = $pages[0];
     $this->assertEquals('About', $about->title);
     $this->assertEquals(1, $about->countChildren());
     $this->assertEquals(16, $about->getKey());
     $blog = $pages[1];
     $this->assertEquals('Blog', $blog->title);
     $this->assertEquals(0, $blog->countChildren());
     $this->assertEquals(20, $blog->getKey());
     $portfolio = $pages[2];
     $this->assertEquals('Portfolio', $portfolio->title);
     $this->assertEquals(0, $portfolio->countChildren());
     $this->assertEquals(21, $portfolio->getKey());
     $pages = $pages[0]->getChildren();
     $testimonials = $pages[0];
     $this->assertEquals('Testimonials', $testimonials->title);
     $this->assertEquals(2, $testimonials->countChildren());
     $this->assertEquals(17, $testimonials->getKey());
     $pages = $pages[0]->getChildren();
     $child1 = $pages[0];
     $this->assertEquals('child 1', $child1->title);
     $this->assertEquals(0, $child1->countChildren());
     $this->assertEquals(18, $child1->getKey());
     $child2 = $pages[1];
     $this->assertEquals('child 2', $child2->title);
     $this->assertEquals(0, $child2->countChildren());
     $this->assertEquals(19, $child2->getKey());
 }