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
03c4316
commit a0ee766
Showing
22 changed files
with
254 additions
and
2 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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
composer.lock | ||
public | ||
vendor | ||
|
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,11 @@ | ||
before_script: | ||
- composer self-update | ||
- composer install | ||
language: php | ||
php: | ||
- 5.4 | ||
- 5.5 | ||
script: | ||
- ./vendor/bin/phpunit | ||
notifications: | ||
email: false |
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,18 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<phpunit bootstrap="vendor/autoload.php"> | ||
<testsuites> | ||
<testsuite name="Pop PDF Component PHPUnit Test"> | ||
<directory>tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
<filter> | ||
<whitelist addUncoveredFilesFromWhitelist="true"> | ||
<directory suffix=".php">src</directory> | ||
</whitelist> | ||
</filter> | ||
<logging> | ||
<log type="coverage-html" target="/tmp/pop-pdf-cc" charset="UTF-8" | ||
yui="true" highlight="false" showUncoveredFiles="true" | ||
lowUpperBound="35" highLowerBound="70" /> | ||
</logging> | ||
</phpunit> |
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
Empty file.
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,146 @@ | ||
<?php | ||
|
||
namespace Pop\Pdf\Test; | ||
|
||
use Pop\Pdf\Document; | ||
use Pop\Pdf\Document\Page; | ||
use Pop\Pdf\Document\Font; | ||
|
||
class DocumentTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
|
||
public function testConstructor() | ||
{ | ||
$doc = new Document(new Page(Page::LETTER)); | ||
$this->assertInstanceOf('Pop\Pdf\Document', $doc); | ||
} | ||
|
||
public function testAddPages() | ||
{ | ||
$doc = new Document(); | ||
$doc->addPages([new Page(Page::LETTER), new Page(Page::LETTER)]); | ||
$doc->createPage(Page::LEGAL); | ||
$doc->copyPage(1); | ||
$this->assertEquals(4, $doc->getNumberOfPages()); | ||
} | ||
|
||
public function testCopyPageException() | ||
{ | ||
$this->setExpectedException('Pop\Pdf\Exception'); | ||
$doc = new Document(); | ||
$doc->createPage(Page::LEGAL); | ||
$doc->copyPage(3); | ||
} | ||
|
||
public function testOrderPages() | ||
{ | ||
$doc = new Document(); | ||
$doc->addPages([new Page(Page::LETTER), new Page(Page::LETTER)]); | ||
$doc->createPage(Page::LEGAL); | ||
$doc->copyPage(1); | ||
$doc->orderPages([4, 3, 2, 1]); | ||
$this->assertEquals(4, $doc->getNumberOfPages()); | ||
} | ||
|
||
public function testOrderPagesBadCountException() | ||
{ | ||
$this->setExpectedException('Pop\Pdf\Exception'); | ||
$doc = new Document(); | ||
$doc->addPages([new Page(Page::LETTER), new Page(Page::LETTER)]); | ||
$doc->createPage(Page::LEGAL); | ||
$doc->copyPage(1); | ||
$doc->orderPages([4, 2, 1]); | ||
} | ||
|
||
public function testOrderPagesPageNotExistException() | ||
{ | ||
$this->setExpectedException('Pop\Pdf\Exception'); | ||
$doc = new Document(); | ||
$doc->addPages([new Page(Page::LETTER), new Page(Page::LETTER)]); | ||
$doc->createPage(Page::LEGAL); | ||
$doc->copyPage(1); | ||
$doc->orderPages([4, 8, 3, 1]); | ||
} | ||
|
||
public function testDeletePage() | ||
{ | ||
$doc = new Document(); | ||
$doc->addPages([new Page(Page::LETTER), new Page(Page::LETTER)]); | ||
$doc->createPage(Page::LEGAL); | ||
$this->assertEquals(3, $doc->getNumberOfPages()); | ||
$doc->deletePage(3); | ||
} | ||
|
||
public function testDeletePageException() | ||
{ | ||
$this->setExpectedException('Pop\Pdf\Exception'); | ||
$doc = new Document(); | ||
$doc->addPages([new Page(Page::LETTER), new Page(Page::LETTER)]); | ||
$doc->createPage(Page::LEGAL); | ||
$this->assertEquals(3, $doc->getNumberOfPages()); | ||
$doc->deletePage(8); | ||
} | ||
|
||
public function testAddFont() | ||
{ | ||
$doc = new Document(); | ||
$doc->addFont(new Font('Arial')); | ||
$this->assertEquals(1, $doc->getNumberOfFonts()); | ||
} | ||
|
||
public function testAddFontException() | ||
{ | ||
$this->setExpectedException('Pop\Pdf\Exception'); | ||
$doc = new Document(); | ||
$doc->addFont(new Font(__DIR__ . '/tmp/fonts/times.ttf')); | ||
} | ||
|
||
public function testEmbedFont() | ||
{ | ||
$doc = new Document(); | ||
$doc->embedFont(new Font(__DIR__ . '/tmp/fonts/times.ttf')); | ||
$this->assertEquals(1, $doc->getNumberOfFonts()); | ||
$this->assertFalse($doc->hasImportedFonts()); | ||
$this->assertEquals(0, count($doc->getImportedFonts())); | ||
} | ||
|
||
public function testEmbedFontException() | ||
{ | ||
$this->setExpectedException('Pop\Pdf\Exception'); | ||
$doc = new Document(); | ||
$doc->embedFont(new Font('Arial')); | ||
} | ||
|
||
public function testSetCurrentPage() | ||
{ | ||
$doc = new Document(); | ||
$doc->addPages([new Page(Page::LETTER), new Page(Page::LETTER)]); | ||
$doc->setCurrentPage(1); | ||
$this->assertEquals(2, $doc->getNumberOfPages()); | ||
$this->assertEquals(1, $doc->getCurrentPage()); | ||
} | ||
|
||
public function testSetCurrentPageException() | ||
{ | ||
$this->setExpectedException('Pop\Pdf\Exception'); | ||
$doc = new Document(); | ||
$doc->addPages([new Page(Page::LETTER), new Page(Page::LETTER)]); | ||
$doc->setCurrentPage(8); | ||
} | ||
|
||
public function testSetCurrentFont() | ||
{ | ||
$doc = new Document(); | ||
$doc->addFont(new Font('Arial')); | ||
$doc->setCurrentFont('Arial'); | ||
$this->assertEquals('Arial', $doc->getCurrentFont()); | ||
} | ||
|
||
public function testSetCurrentFontException() | ||
{ | ||
$this->setExpectedException('Pop\Pdf\Exception'); | ||
$doc = new Document(); | ||
$doc->setCurrentFont('Arial'); | ||
} | ||
|
||
} |
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,63 @@ | ||
<?php | ||
|
||
namespace Pop\Pdf\Test; | ||
|
||
use Pop\Pdf; | ||
|
||
class PdfTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
|
||
public function testConstructor() | ||
{ | ||
$pdf = new Pdf\Pdf(); | ||
$this->assertInstanceOf('Pop\Pdf\Pdf', $pdf); | ||
} | ||
|
||
public function testImportFromFile() | ||
{ | ||
$pdf = new Pdf\Pdf(); | ||
$this->assertInstanceOf('Pop\Pdf\Document', $pdf->importFromFile(__DIR__ . '/tmp/doc.pdf', 1)); | ||
} | ||
|
||
public function testWriteToFile() | ||
{ | ||
$pdf = new Pdf\Pdf(); | ||
$doc = $pdf->importFromFile(__DIR__ . '/tmp/doc.pdf', 1); | ||
$pdf->writeToFile($doc, __DIR__ . '/tmp/mytest.pdf'); | ||
$this->assertFileExists(__DIR__ . '/tmp/mytest.pdf'); | ||
unlink(__DIR__ . '/tmp/mytest.pdf'); | ||
} | ||
|
||
/** | ||
* @runInSeparateProcess | ||
*/ | ||
public function testOutputToHttp() | ||
{ | ||
$_SERVER['SERVER_PORT'] = 443; | ||
|
||
$pdf = new Pdf\Pdf(); | ||
$doc = $pdf->importFromFile(__DIR__ . '/tmp/doc.pdf', 1); | ||
|
||
ob_start(); | ||
$pdf->outputToHttp($doc); | ||
$result = ob_get_clean(); | ||
|
||
$this->assertContains('%PDF', $result); | ||
} | ||
|
||
/** | ||
* @runInSeparateProcess | ||
*/ | ||
public function testToString() | ||
{ | ||
$pdf = new Pdf\Pdf(); | ||
$doc = $pdf->importFromFile(__DIR__ . '/tmp/doc.pdf', 1); | ||
|
||
ob_start(); | ||
echo $doc; | ||
$result = ob_get_clean(); | ||
|
||
$this->assertContains('%PDF', $result); | ||
} | ||
|
||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.