Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fillpdf
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
drupal.org
fillpdf
Commits
9fd30984
Commit
9fd30984
authored
5 years ago
by
Bernd Oliver Suenderhauf
Browse files
Options
Downloads
Patches
Plain Diff
Issue #3055245 by Pancho: Add a PdfParseTest for locally installed backends
parent
45346925
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/src/Functional/PdfParseTest.php
+80
-0
80 additions, 0 deletions
tests/src/Functional/PdfParseTest.php
with
80 additions
and
0 deletions
tests/src/Functional/PdfParseTest.php
0 → 100644
+
80
−
0
View file @
9fd30984
<?php
namespace
Drupal\Tests\fillpdf\Functional
;
use
Drupal\Tests\BrowserTestBase
;
use
Drupal\Tests\fillpdf\Traits\TestFillPdfTrait
;
use
Drupal\fillpdf\Component\Utility\FillPdf
;
use
Drupal\fillpdf\Entity\FillPdfForm
;
/**
* Tests PDF parsing.
*
* @group fillpdf
*/
class
PdfParseTest
extends
BrowserTestBase
{
use
TestFillPdfTrait
;
static
public
$modules
=
[
'fillpdf_test'
];
protected
$profile
=
'minimal'
;
/**
* {@inheritdoc}
*/
protected
function
setUp
()
{
parent
::
setUp
();
$this
->
initializeUser
();
}
/**
* Tests PDF population using local service.
*
* @throws \PHPUnit_Framework_SkippedTestError
* Thrown when test had to be skipped as FillPDF LocalServer is not
* available.
*/
public
function
testParseLocalService
()
{
// For local container testing, we require the Docker container to be
// running on port 8085. If http://127.0.0.1:8085/ping does not return a
// 200, we assume that we're not in an environment where we can run this
// test.
$this
->
configureLocalServiceBackend
();
$config
=
$this
->
container
->
get
(
'config.factory'
)
->
get
(
'fillpdf.settings'
);
if
(
!
FillPdf
::
checkLocalServiceEndpoint
(
$this
->
container
->
get
(
'http_client'
),
$config
))
{
throw
new
\PHPUnit_Framework_SkippedTestError
(
'FillPDF LocalServer unavailable, so skipping test.'
);
}
$this
->
backendTest
();
}
/**
* Tests PDF population using a local install of pdftk.
*
* @throws \PHPUnit_Framework_SkippedTestError
* Thrown when test had to be skipped as local pdftk install is not
* available.
*
* @todo Implementation missing.
*/
public
function
testParsePdftk
()
{
$this
->
configureFillPdf
([
'backend'
=>
'pdftk'
]);
if
(
!
FillPdf
::
checkPdftkPath
())
{
throw
new
\PHPUnit_Framework_SkippedTestError
(
'pdftk not available, so skipping test.'
);
}
$this
->
backendTest
();
}
/**
* Tests a backend.
*/
protected
function
backendTest
()
{
$this
->
uploadTestPdf
(
'fillpdf_test_v3.pdf'
);
$this
->
assertSession
()
->
pageTextNotContains
(
'No fields detected in PDF.'
);
$fillpdf_form
=
FillPdfForm
::
load
(
$this
->
getLatestFillPdfForm
());
$fields
=
$fillpdf_form
->
getFormFields
();
$this
->
assertCount
(
11
,
$fields
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment