private function injectBoundary(Container $container, $yStart = 0)
 {
     $parent = $container->getParent();
     $point = $parent->getFirstPoint();
     $boundary = new Boundary();
     $boundary->setNext($point->translate(0, $yStart))->setNext($point->translate($container->getWidth(), $yStart))->setNext($point->translate($container->getWidth(), $yStart + $container->getHeight()))->setNext($point->translate(0, $yStart + $container->getHeight()))->close();
     $this->invokeMethod($container, 'setBoundary', array($boundary));
 }
 private function getContainerMock($start, $end, array $methods = array())
 {
     $methods = array_merge(array('getBoundary', 'getHeight'), $methods);
     $mock = $this->getMock('PHPPdf\\Core\\Node\\Container', $methods);
     $boundary = new Boundary();
     $boundary->setNext($start[0], $start[1])->setNext($end[0], $start[1])->setNext($end[0], $end[1])->setNext($start[0], $end[1])->close();
     $mock->expects($this->atLeastOnce())->method('getBoundary')->will($this->returnValue($boundary));
     $mock->expects($this->any())->method('getHeight')->will($this->returnValue($start[1] - $end[1]));
     return $mock;
 }
Ejemplo n.º 3
0
 private function getNodeMock($x, $y, $width, $height, array $methods = array(), $boundaryAtLeastOnce = true, $class = 'PHPPdf\\Core\\Node\\Container')
 {
     $methods = array_merge(array('getBoundary', 'getHeight', 'getWidth'), $methods);
     $mock = $this->getMock($class, $methods);
     $boundary = new Boundary();
     $boundary->setNext($x, $y)->setNext($x + $width, $y)->setNext($x + $width, $y - $height)->setNext($x, $y - $height)->close();
     $mock->expects($boundaryAtLeastOnce ? $this->atLeastOnce() : $this->any())->method('getBoundary')->will($this->returnValue($boundary));
     $mock->expects($this->any())->method('getHeight')->will($this->returnValue($height));
     $mock->expects($this->any())->method('getWidth')->will($this->returnValue($width));
     return $mock;
 }
 /**
  * @test
  */
 public function clearBoundaryAndAddOldFirstPoint()
 {
     $nodeMock = $this->getMock('\\PHPPdf\\Core\\Node\\Text', array('getBoundary'));
     $boundary = new Boundary();
     $boundary->setNext(0, 100)->setNext(100, 100)->setNext(100, 0)->setNext(0, 0)->close();
     $firstPoint = $boundary->getFirstPoint();
     $nodeMock->expects($this->atLeastOnce())->method('getBoundary')->will($this->returnValue($boundary));
     $this->formatter->format($nodeMock, $this->createDocumentStub());
     $this->assertFalse($boundary->isClosed());
     $this->assertEquals($firstPoint, $boundary->getFirstPoint());
     $this->assertEquals(1, count($boundary));
 }
Ejemplo n.º 5
0
 /**
  * @return Boundary
  */
 private function createBoundary(Node $node, $preferredXCoord, $preferredYCoord)
 {
     $dummyBoundary = new Boundary();
     $dummyBoundary->setNext($preferredXCoord, $preferredYCoord)->setNext($preferredXCoord + $node->getWidth(), $preferredYCoord)->setNext($preferredXCoord + $node->getWidth(), $preferredYCoord - $node->getHeight())->setNext($preferredXCoord, $preferredYCoord - $node->getHeight());
     return $dummyBoundary;
 }
Ejemplo n.º 6
0
 /**
  * @test
  */
 public function intersectingOccursWhenAtLeastOnePointIsContainedInBySecondBoundary()
 {
     $this->boundary->setNext(0, 100)->setNext(100, 100)->setNext(100, 0)->setNext(0, 0)->close();
     $secondBoundary = new Boundary();
     $secondBoundary->setNext(99, 100)->setNext(190, 100)->setNext(190, 50)->setNext(99, 50)->close();
     $this->assertTrue($this->boundary->intersects($secondBoundary));
     $this->assertTrue($secondBoundary->intersects($this->boundary));
 }
 private function setPointsToBoundary(Boundary $source, Boundary $destination)
 {
     $destination->setNext($source[0])->setNext($source[1])->setNext($source[2])->setNext($source[3])->close();
 }
Ejemplo n.º 8
0
 private function createRowMock($start, $end, $break = false, $translate = false)
 {
     $methods = array('getHeight', 'getBoundary');
     if ($break) {
         $methods[] = 'breakAt';
     }
     if ($translate) {
         $methods[] = 'translate';
     }
     $mock = $this->getMock('PHPPdf\\Core\\Node\\Table\\Row', $methods);
     if ($break) {
         $mock->expects($this->once())->method('breakAt')->will($this->returnValue(null));
     }
     $boundary = new Boundary();
     $boundary->setNext($start[0], $start[1])->setNext($end[0], $start[1])->setNext($end[0], $end[1])->setNext($start[0], $end[1])->close();
     $height = $start[1] - $end[1];
     $mock->expects($this->atLeastOnce())->method('getBoundary')->will($this->returnValue($boundary));
     $mock->expects($this->any())->method('getHeight')->will($this->returnValue($height));
     if ($translate) {
         $mock->expects($this->atLeastOnce())->method('translate');
     }
     return $mock;
 }