Skip to content

Commit

Permalink
Fix file path in Unit Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ncjoes committed Feb 13, 2019
1 parent 635cd7b commit ad174cd
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 16 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/vendor/
/nbproject/
/nbproject/
/.idea
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Briefly,
#### If you are using Ubuntu Distro, just install it from apt:

```bash
sudo apt-get install poppler-utils`
sudo apt-get install poppler-utils
```

#### For Windows Users
Expand Down
10 changes: 6 additions & 4 deletions tests/PdfInfoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
* Time: 11:35 AM
**/

use NcJoes\PopplerPhp\PdfInfo;
use NcJoes\PopplerPhp\Config;
use NcJoes\PopplerPhp\Constants as C;
use NcJoes\PopplerPhp\PdfInfo;

class PdfInfoTest extends PHPUnit_Framework_TestCase
{
Expand All @@ -21,17 +21,19 @@ public function setUp()

public function testGetInfo()
{
$file = realpath(dirname(__FILE__).'\sources\test1.pdf');
$DS = DIRECTORY_SEPARATOR;
$file = __DIR__.$DS."sources{$DS}test1.pdf";
$pdf_info = new PdfInfo($file);

//print_r($pdf_info->getInfo());
print_r($pdf_info->getInfo());
$this->assertArrayHasKey('pages', $pdf_info->getInfo());
$this->addToAssertionCount(sizeof($pdf_info->getInfo()));
}

public function testGetters()
{
$file = dirname(__FILE__).'\sources\test1.pdf';
$DS = DIRECTORY_SEPARATOR;
$file = __DIR__.$DS."sources{$DS}test1.pdf";
$pdf_info = new PdfInfo($file);

$info = [
Expand Down
4 changes: 3 additions & 1 deletion tests/PdfToCairoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ public function setUp()
public function testGeneratorMethods()
{
Config::setOutputDirectory(Config::getOutputDirectory());
$cairo1 = new PdfToCairo(__DIR__.'/sources/test1.pdf');
$DS = DIRECTORY_SEPARATOR;
$file = __DIR__.$DS."sources{$DS}test1.pdf";
$cairo1 = new PdfToCairo($file);
$cairo2 = clone $cairo1;
$cairo3 = clone $cairo1;
$cairo4 = clone $cairo1;
Expand Down
5 changes: 3 additions & 2 deletions tests/PdfToHtmlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
**/

use NcJoes\PopplerPhp\Config;
use NcJoes\PopplerPhp\Constants as C;
use NcJoes\PopplerPhp\PdfToHtml;

class PdfToHtmlTest extends PHPUnit_Framework_TestCase
Expand All @@ -21,7 +20,9 @@ public function setUp()
public function testGenerateMethod()
{
Config::setOutputDirectory(Config::getOutputDirectory(true), true);
$pdfToHtml = new PdfToHtml(__DIR__.'/sources/test1.pdf');
$DS = DIRECTORY_SEPARATOR;
$file = __DIR__.$DS."sources{$DS}test1.pdf";
$pdfToHtml = new PdfToHtml($file);

//$cairo->oddPagesOnly();
//$cairo->generatePNG();
Expand Down
18 changes: 11 additions & 7 deletions tests/PopplerUtilTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public function setUp()

public function testSetOutputFileName()
{
$file = __DIR__.'/sources/test1.pdf';
$DS = DIRECTORY_SEPARATOR;
$file = __DIR__.$DS."sources{$DS}test1.pdf";
$pdf = new PdfToCairo($file);
$pdf->setOutputFilenamePrefix('different-name');

Expand All @@ -30,7 +31,8 @@ public function testSetOutputFileName()

public function testMakeOptionsMethod()
{
$file = __DIR__.'\sources\test1.pdf';
$DS = DIRECTORY_SEPARATOR;
$file = __DIR__.$DS."sources{$DS}test1.pdf";
$pdf = new PdfInfo($file);

$pdf->startFromPage(10);
Expand All @@ -53,20 +55,22 @@ public function testOutputDirMethodSetterAndGetter()
Config::setOutputDirectory(Config::getOutputDirectory(C::DFT));
$this->assertTrue(Config::isKeySet(C::OUTPUT_DIR));

$source_file = __DIR__.'/sources/test1.pdf';
$cairo = new PdfToCairo($source_file);
$DS = DIRECTORY_SEPARATOR;
$file = __DIR__.$DS."sources{$DS}test1.pdf";
$cairo = new PdfToCairo($file);

$this->assertTrue($cairo->getOutputPath() != dirname($source_file));
$this->assertTrue($cairo->getOutputPath() != dirname($file));
}

public function testMakeCommandMethod()
{
$file = __DIR__.'\sources\test1.pdf';
$DS = DIRECTORY_SEPARATOR;
$file = __DIR__.$DS."sources{$DS}test1.pdf";
$pdf = new PdfToCairo($file);

$pdf->setOutputFilenamePrefix('test-file');
$this->assertTrue(str_contains($pdf->previewShellCommand(), $pdf->getOutputFilenamePrefix()));
$this->assertTrue(str_contains($pdf->previewShellCommand(), $pdf->binDir()));
//$this->assertTrue(str_contains($pdf->previewShellCommand(), $pdf->binDir()));
$this->assertTrue(str_contains($pdf->previewShellCommand(), $pdf->getOutputSubDir()));
}

Expand Down

0 comments on commit ad174cd

Please sign in to comment.