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
Showing
13 changed files
with
150 additions
and
68 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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
/vendor | ||
/composer.phar | ||
/composer.lock | ||
*.tmp.pdf |
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 |
---|---|---|
|
@@ -13,6 +13,5 @@ install: | |
- bob install_dev_tools | ||
|
||
script: | ||
|
||
TODO: | ||
- phpunit | ||
- behat |
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,103 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
use Behat\Behat\Context\Context; | ||
use Behat\Gherkin\Node\PyStringNode; | ||
use Behat\Gherkin\Node\TableNode; | ||
use Behat\Behat\Tester\Exception\PendingException; | ||
use iio\libmergepdf\Merger; | ||
use iio\libmergepdf\Pages; | ||
use setasign\Fpdi\Tcpdf\Fpdi; | ||
use setasign\Fpdi\PdfParser\StreamReader; | ||
|
||
final class FeatureContext implements Context | ||
{ | ||
/** | ||
* @var Merger | ||
*/ | ||
private $merger; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $generatedPdf; | ||
|
||
/** | ||
* @var Fpdi | ||
*/ | ||
private $fpdi; | ||
|
||
public function __construct() | ||
{ | ||
$this->fpdi = new Fpdi; | ||
} | ||
|
||
/** | ||
* @Given the :driver driver | ||
*/ | ||
public function theDriver(string $driver) | ||
{ | ||
$driverClass = "iio\libmergepdf\Driver\\$driver"; | ||
$this->merger = new Merger(new $driverClass); | ||
} | ||
|
||
/** | ||
* @Given a pdf | ||
*/ | ||
public function aPdf() | ||
{ | ||
$this->aPdfOfVersion('1.4'); | ||
} | ||
|
||
/** | ||
* @Given a pdf with pages :pages | ||
*/ | ||
public function aPdfWithPages($pages) | ||
{ | ||
$this->aPdfOfVersionWithPages('1.4', $pages); | ||
} | ||
|
||
/** | ||
* @Given a pdf of version :version | ||
*/ | ||
public function aPdfOfVersion(string $version) | ||
{ | ||
$this->aPdfOfVersionWithPages($version, ''); | ||
} | ||
|
||
/** | ||
* @Given a pdf of version :version with pages :pages | ||
*/ | ||
public function aPdfOfVersionWithPages(string $version, string $pages) | ||
{ | ||
$this->merger->addFile(__DIR__ . "/../files/$version.pdf", new Pages($pages)); | ||
} | ||
|
||
/** | ||
* @When I merge | ||
*/ | ||
public function iMerge() | ||
{ | ||
$this->generatedPdf = $this->merger->merge(); | ||
} | ||
|
||
/** | ||
* @Then a pdf is generated | ||
*/ | ||
public function aPdfIsGenerated() | ||
{ | ||
$this->fpdi->setSourceFile(StreamReader::createByString($this->generatedPdf)); | ||
} | ||
|
||
/** | ||
* @Then a pdf with :expectedCount pages is generated | ||
*/ | ||
public function aPdfWithPagesIsGenerated(string $expectedCount) | ||
{ | ||
$pageCount = $this->fpdi->setSourceFile(StreamReader::createByString($this->generatedPdf)); | ||
if ($pageCount != $expectedCount) { | ||
throw new Exception("A pdf with $pageCount pages was created, expected $expectedCount pages."); | ||
} | ||
} | ||
} |
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,41 @@ | ||
Feature: Mergeing pdfs | ||
In order to use lib | ||
As a user | ||
I need to be able to merge pdfs | ||
|
||
Scenario: I merge two pdfs using the fpdi driver | ||
Given the "Fpdi2Driver" driver | ||
And a pdf | ||
And a pdf | ||
When I merge | ||
Then a pdf is generated | ||
|
||
Scenario: I merge selected pages using the fpdi driver | ||
Given the "Fpdi2Driver" driver | ||
And a pdf with pages "1" | ||
And a pdf with pages "1-2" | ||
When I merge | ||
Then a pdf with "3" pages is generated | ||
|
||
Scenario: I merge two pdfs using the tcpdi driver | ||
Given the "TcpdiDriver" driver | ||
And a pdf | ||
And a pdf | ||
When I merge | ||
Then a pdf is generated | ||
|
||
Scenario: I merge selected pages using the tcpdi driver | ||
Given the "TcpdiDriver" driver | ||
And a pdf with pages "1" | ||
And a pdf with pages "1-2" | ||
When I merge | ||
Then a pdf with "3" pages is generated | ||
|
||
Scenario: I merge pdfs of versions later than 1.4 | ||
Given the "TcpdiDriver" driver | ||
And a pdf of version "1.4" with pages "1" | ||
And a pdf of version "1.5" with pages "1" | ||
And a pdf of version "1.6" with pages "1" | ||
And a pdf of version "1.7" with pages "1" | ||
When I merge | ||
Then a pdf with "4" pages is generated |
File renamed without changes.
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
Binary file not shown.
This file was deleted.
Oops, something went wrong.