-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1497438
commit a490345
Showing
10 changed files
with
208 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,4 +22,6 @@ phpunit.phar | |
|
||
composer.phar | ||
|
||
/vendor | ||
/vendor | ||
|
||
composer.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<?php | ||
use Idg\Exceptions\StructureException; | ||
/** | ||
* Blocks test | ||
* Class BlocksTest | ||
*/ | ||
class BlocksTest extends \PHPUnit\Framework\TestCase | ||
{ | ||
/** | ||
* @return \Idg\Idg | ||
*/ | ||
protected function getIdg() | ||
{ | ||
return new \Idg\Idg(1000, 3000, null, new ImagickPixel('#fff')); | ||
} | ||
|
||
/** | ||
* Test block | ||
*/ | ||
public function testBlock() | ||
{ | ||
$idg = $this->getIdg(); | ||
$idg->beginDocument(); | ||
$idg->beginBlock(); | ||
$idg->endBlock(); | ||
$idg->endDocument(); | ||
$idg->compose(); | ||
|
||
//empty document | ||
$document = $idg->getDocument(); | ||
$this->assertEquals(0, $document->getHeight()); | ||
$this->assertEquals(1000, $document->getWidth()); | ||
|
||
$idg = $this->getIdg(); | ||
$idg->beginDocument(); | ||
$idg->beginBlock()->setTop(20)->setLeft(20); | ||
$idg->beginBlock()->setTop(30); | ||
|
||
$idg->endBlock(); | ||
$idg->beginBlock()->setTop(10); | ||
|
||
$idg->endBlock(); | ||
$idg->endBlock(); | ||
|
||
$idg->beginBlock()->setTop(40); | ||
|
||
$idg->endBlock(); | ||
$idg->endDocument(); | ||
$idg->compose(); | ||
|
||
$document = $idg->getDocument(); | ||
$this->assertEquals(20 + 30 + 10 + 40, $document->getHeight()); | ||
$this->assertEquals(1000, $document->getWidth()); | ||
} | ||
|
||
/** | ||
* Test absolute block | ||
*/ | ||
public function testAbsoluteBlock() | ||
{ | ||
$idg = $this->getIdg(); | ||
$idg->beginDocument(10); | ||
$idg->beginBlock()->setTop(20)->setLeft(20); | ||
$idg->beginBlock()->setTop(30); | ||
|
||
$idg->endBlock(); | ||
$idg->beginBlock()->setTop(10); | ||
$idg->beginAbsoluteBlock(40, 50)->setWidth(100); | ||
|
||
$idg->endBlock(); | ||
$idg->endBlock(); | ||
$idg->endBlock(); | ||
|
||
// don't increase document height | ||
$idg->beginAbsoluteBlock(40, 50)->setWidth(100); | ||
|
||
$idg->endBlock(); | ||
$idg->endDocument(); | ||
$idg->compose(); | ||
|
||
$document = $idg->getDocument(); | ||
$this->assertEquals(10 + 20 + 30 + 10, $document->getHeight()); | ||
$this->assertEquals(1000, $document->getWidth()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
use Idg\Exceptions\StructureException; | ||
/** | ||
* Structure validation test | ||
* Class StructureValidationTest | ||
*/ | ||
class StructureValidationTest extends \PHPUnit\Framework\TestCase | ||
{ | ||
/** | ||
* @return \Idg\Idg | ||
*/ | ||
protected function getIdg() | ||
{ | ||
return new \Idg\Idg(1000, 3000, null, new ImagickPixel('#fff')); | ||
} | ||
|
||
/** | ||
* Test document is first | ||
*/ | ||
public function testDocumentIsFirst() | ||
{ | ||
$idg = $this->getIdg(); | ||
$this->expectException(StructureException::class); | ||
$idg->beginBlock(); | ||
} | ||
|
||
/** | ||
* Test close element | ||
*/ | ||
public function testCloseElement() | ||
{ | ||
$idg = $this->getIdg(); | ||
$this->expectException(StructureException::class); | ||
$idg->beginDocument(); | ||
$idg->compose(); | ||
} | ||
|
||
/** | ||
* Test column in row | ||
*/ | ||
public function testColumn() | ||
{ | ||
$idg = $this->getIdg(); | ||
$this->expectException(StructureException::class); | ||
$idg->beginDocument(); | ||
$idg->beginColumn(200); | ||
$idg->endColumn(); | ||
$idg->endDocument(); | ||
$idg->compose(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
use Idg\Exceptions\StructureException; | ||
/** | ||
* Tables test | ||
* Class TablesTest | ||
*/ | ||
class TablesTest extends \PHPUnit\Framework\TestCase | ||
{ | ||
/** | ||
* @return \Idg\Idg | ||
*/ | ||
protected function getIdg() | ||
{ | ||
return new \Idg\Idg(1000, 3000, null, new ImagickPixel('#fff')); | ||
} | ||
|
||
/** | ||
* Test absolute block | ||
*/ | ||
public function testTableWithBlocks() | ||
{ | ||
$idg = $this->getIdg(); | ||
$idg->beginDocument(10); | ||
$idg->beginBlock()->setTop(20)->setLeft(20); | ||
$idg->beginBlock()->setTop(30); | ||
|
||
$idg->endBlock(); | ||
$idg->beginBlock()->setTop(10); | ||
$idg->beginAbsoluteBlock(40, 50)->setWidth(100); | ||
|
||
$idg->endBlock(); | ||
$idg->endBlock(); | ||
|
||
$idg->beginRow()->setTop(15); | ||
$idg->beginColumn(100)->setStaticHeight(150); | ||
$idg->endColumn(); | ||
$idg->beginColumn(100)->setStaticHeight(170); | ||
$idg->endColumn(); | ||
$idg->endRow(); | ||
$idg->endBlock(); | ||
|
||
// don't increase document height | ||
$idg->beginAbsoluteBlock(40, 50)->setWidth(100); | ||
|
||
$idg->endBlock(); | ||
$idg->endDocument(); | ||
$idg->compose(); | ||
|
||
$document = $idg->getDocument(); | ||
$this->assertEquals(10 + 20 + 30 + 10 + 15 + 170, $document->getHeight()); | ||
$this->assertEquals(1000, $document->getWidth()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<?php |