Example #1
0
 public function testGetterSetter()
 {
     $page = new Page();
     $page->setEnabled(true);
     $this->assertTrue($page->getEnabled());
     $page->setCustomUrl('http://foo.bar');
     $this->assertEquals('http://foo.bar', $page->getCustomUrl());
     $page->setMetaKeyword('foo, bar');
     $this->assertEquals('foo, bar', $page->getMetaKeyword());
     $page->setMetaDescription('Foo bar is awesome');
     $this->assertEquals('Foo bar is awesome', $page->getMetaDescription());
     $page->setJavascript("alert('foo bar is around')");
     $this->assertEquals("alert('foo bar is around')", $page->getJavascript());
     $page->setStylesheet('foo.bar { display: block; }');
     $this->assertEquals('foo.bar { display: block; }', $page->getStylesheet());
     $time = new \DateTime();
     $page->setCreatedAt($time);
     $page->setUpdatedAt($time);
     $this->assertEquals($time, $page->getCreatedAt());
     $this->assertEquals($time, $page->getUpdatedAt());
     $children = array(new Page(), new Page());
     $page->setChildren($children);
     $this->assertEquals(2, count($page->getChildren()));
     $snapshots = array($this->getMock('Sonata\\PageBundle\\Model\\SnapshotInterface'));
     $page->setSnapshots($snapshots);
     $this->assertEquals(1, count($page->getSnapshots()));
     $page->addSnapshot($this->getMock('Sonata\\PageBundle\\Model\\SnapshotInterface'));
     $this->assertEquals(2, count($page->getSnapshots()));
     $this->assertInstanceOf('Sonata\\PageBundle\\Model\\SnapshotInterface', $page->getSnapshot());
     $page->setTarget($this->getMock('Sonata\\PageBundle\\Model\\PageInterface'));
     $this->assertInstanceOf('Sonata\\PageBundle\\Model\\PageInterface', $page->getTarget());
     $page->setTarget(null);
     $this->assertNull($page->getTarget());
     $page->setTemplateCode('template1');
     $this->assertEquals('template1', $page->getTemplateCode());
     $page->setDecorate(true);
     $this->assertTrue($page->getDecorate());
     $page->setPosition(1);
     $this->assertEquals(1, $page->getPosition());
     $page->setName(null);
     $this->assertEquals('-', (string) $page);
     $page->setName('Salut');
     $this->assertEquals('Salut', (string) $page);
 }