示例#1
0
 /**
  * @test
  */
 public function dontIgnorePaddingBottom()
 {
     $page = new Page();
     $paddingBottom = 10;
     $leftFloatedContainerHeight = 20;
     $rightFloatedContainerHeight = 40;
     $containerHeight = $paddingBottom + $leftFloatedContainerHeight + $rightFloatedContainerHeight;
     $container = new Container();
     $container->makeAttributesSnapshot();
     $container->setPaddingBottom($paddingBottom);
     $container->setHeight($containerHeight);
     $container->setWidth($page->getWidth());
     $this->invokeMethod($container, 'setBoundary', array($this->objectMother->getBoundaryStub(0, $page->getFirstPoint()->getY(), $page->getWidth(), $containerHeight)));
     $leftFloatedContainer = new Container();
     $leftFloatedContainer->setFloat(Node::FLOAT_LEFT);
     $leftFloatedContainer->setHeight($leftFloatedContainerHeight);
     $leftFloatedContainer->setWidth(10);
     $this->invokeMethod($leftFloatedContainer, 'setBoundary', array($this->objectMother->getBoundaryStub(0, $page->getFirstPoint()->getY(), 10, $leftFloatedContainerHeight)));
     $rightFloatedContainer = new Container();
     $rightFloatedContainer->setFloat(Node::FLOAT_RIGHT);
     $rightFloatedContainer->setHeight($rightFloatedContainerHeight);
     $rightFloatedContainer->setWidth(10);
     $this->invokeMethod($rightFloatedContainer, 'setBoundary', array($this->objectMother->getBoundaryStub(0, $page->getFirstPoint()->getY() + $leftFloatedContainerHeight, 10, $rightFloatedContainerHeight)));
     $page->add($container->add($leftFloatedContainer)->add($rightFloatedContainer));
     $this->formatter->format($container, $this->document);
     $expectedHeight = $paddingBottom + $rightFloatedContainerHeight;
     $this->assertEquals($expectedHeight, $container->getHeight());
     $this->assertEquals($expectedHeight, $container->getFirstPoint()->getY() - $container->getDiagonalPoint()->getY());
 }
 /**
  * @test
  */
 public function nodeWithAutoMarginPositioning()
 {
     $node = new Container(array('width' => 100, 'height' => 100));
     $node->hadAutoMargins(true);
     $node->makeAttributesSnapshot();
     $node->setWidth(110);
     $child = new Container(array('width' => 50, 'height' => 50));
     $node->add($child);
     $page = new Page();
     $page->add($node);
     $node->getBoundary()->setNext($page->getFirstPoint());
     $child->getBoundary()->setNext($page->getFirstPoint());
     foreach (array($node, $child) as $g) {
         $this->formatter->format($g, $this->createDocumentStub());
     }
     $nodeBoundary = $node->getBoundary();
     $childBoundary = $child->getBoundary();
     $pageBoundary = $page->getBoundary();
     $this->assertEquals($pageBoundary[0]->translate(-5, 0), $nodeBoundary[0]);
     $this->assertEquals($pageBoundary[0]->translate(105, 0), $nodeBoundary[1]);
     $this->assertEquals($pageBoundary[0]->translate(105, 100), $nodeBoundary[2]);
     $this->assertEquals($pageBoundary[0]->translate(-5, 100), $nodeBoundary[3]);
 }