Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UPDATE] Update and modify some builder tests #54

Merged
merged 6 commits into from
Jun 1, 2024
Merged

Conversation

Neirda24
Copy link
Contributor

@Neirda24 Neirda24 commented May 31, 2024

$ ./vendor/bin/phpunit --coverage-html ./coverage-html --testdox
PHPUnit 10.5.20 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.3.7 with PCOV 1.0.11
Configuration: /Users/neirda/Projects/Sensiolabs/OpenSource/Gotenberg/GotenbergBundle/phpunit.xml

...............................................................  63 / 173 ( 36%)
............................................................... 126 / 173 ( 72%)
...............................................                 173 / 173 (100%)

Time: 00:00.165, Memory: 28.00 MB

Abstract Chromium Pdf Builder (Sensiolabs\GotenbergBundle\Tests\Builder\Pdf\AbstractChromiumPdfBuilder)
 ✔ Configuration "single_page" is correctly set
 ✔ Configuration "pdf_format - A-1b" is correctly set
 ✔ Configuration "pdf_universal_access" is correctly set
 ✔ Configuration "paper_width" is correctly set
 ✔ Configuration "paper_height" is correctly set
 ✔ Configuration "margin_top" is correctly set
 ✔ Configuration "margin_bottom" is correctly set
 ✔ Configuration "margin_left" is correctly set
 ✔ Configuration "margin_right" is correctly set
 ✔ Configuration "prefer_css_page_size" is correctly set
 ✔ Configuration "print_background" is correctly set
 ✔ Configuration "omit_background" is correctly set
 ✔ Configuration "landscape" is correctly set
 ✔ Configuration "scale" is correctly set
 ✔ Configuration "native_page_ranges" is correctly set
 ✔ Configuration "wait_delay" is correctly set
 ✔ Configuration "wait_for_expression" is correctly set
 ✔ Configuration "emulated_media_type" is correctly set
 ✔ Configuration "cookies" is correctly set
 ✔ Configuration "extra_http_headers" is correctly set
 ✔ Configuration "fail_on_http_status_codes" is correctly set
 ✔ Configuration "fail_on_console_exceptions" is correctly set
 ✔ Configuration "skip_network_idle_event" is correctly set
 ✔ Configuration "metadata" is correctly set
 ✔ Paper size applies width and height
 ✔ Paper standard size applies correctly
 ✔ Margins applies correctly
 ✔ Pdf format can be reset
 ✔ Twig header is correctly rendered
 ✔ Twig footer is correctly rendered
 ✔ Plain file header is correctly rendered
 ✔ Plain file footer is correctly rendered
 ✔ Assets can be added using php
 ✔ Assets can be added using twig
 ✔ Can add cookies
 ✔ Can add extra http headers
 ✔ Can add metadata
 ✔ Throw if twig not available
 ✔ Throw if twig template is invalid

Abstract Chromium Screenshot Builder (Sensiolabs\GotenbergBundle\Tests\Builder\Screenshot\AbstractChromiumScreenshotBuilder)
 ✔ Configuration "width" is correctly set
 ✔ Configuration "height" is correctly set
 ✔ Configuration "clip" is correctly set
 ✔ Configuration "format" is correctly set
 ✔ Configuration "quality" is correctly set
 ✔ Configuration "omit_background" is correctly set
 ✔ Configuration "optimize_for_speed" is correctly set
 ✔ Configuration "wait_delay" is correctly set
 ✔ Configuration "wait_for_expression" is correctly set
 ✔ Configuration "emulated_media_type" is correctly set
 ✔ Configuration "cookies" is correctly set
 ✔ Configuration "extra_http_headers" is correctly set
 ✔ Configuration "fail_on_http_status_codes" is correctly set
 ✔ Configuration "fail_on_console_exceptions" is correctly set
 ✔ Configuration "skip_network_idle_event" is correctly set

Abstract Pdf Builder (Sensiolabs\GotenbergBundle\Tests\Builder\Pdf\AbstractPdfBuilder)
 ✔ Filename is correctly set on response
 ✔ Form field "extraHttpHeaders" is correctly normalized
 ✔ Form field "assets" is correctly normalized
 ✔ Form field "header.html" is correctly normalized
 ✔ Form field "index.html" is correctly normalized
 ✔ Form field "footer.html" is correctly normalized
 ✔ Form field "failOnHttpStatusCodes" is correctly normalized
 ✔ Form field "cookies" is correctly normalized
 ✔ Form field "metadata" is correctly normalized
 ✔ Native "boolean (true)" is correctly normalized
 ✔ Native "boolean (false)" is correctly normalized
 ✔ Native "int" is correctly normalized
 ✔ Native "float (.0)" is correctly normalized
 ✔ Native "float (.5)" is correctly normalized

Abstract Screenshot Builder (Sensiolabs\GotenbergBundle\Tests\Builder\Screenshot\AbstractScreenshotBuilder)
 ✔ Filename is correctly set on response
 ✔ Form field "extraHttpHeaders" is correctly normalized
 ✔ Form field "assets" is correctly normalized
 ✔ Form field "header.html" is correctly normalized
 ✔ Form field "index.html" is correctly normalized
 ✔ Form field "footer.html" is correctly normalized
 ✔ Form field "failOnHttpStatusCodes" is correctly normalized
 ✔ Form field "cookies" is correctly normalized
 ✔ Native "boolean (true)" is correctly normalized
 ✔ Native "boolean (false)" is correctly normalized
 ✔ Native "int" is correctly normalized
 ✔ Native "float (.0)" is correctly normalized
 ✔ Native "float (.5)" is correctly normalized

Asset Base Dir Formatter (Formatter\AssetBaseDirFormatter)
 ✔ Resolve path when "absolute path and absolute base dir"
 ✔ Resolve path when "absolute path and relative base dir"
 ✔ Resolve path when "relative path and relative base dir"
 ✔ Resolve path when "relative path and relative base dir with end slash"
 ✔ Resolve path when "relative path and absolute base dir"

Configuration (Sensiolabs\GotenbergBundle\Tests\DependencyInjection\Configuration)
 ✔ Default config
 ✔ Invalid range with data set "as string"
 ✔ Invalid range with data set "as integer"
 ✔ Invalid range with data set "as boolean"
 ✔ Valid pdf html configuration with data set "paper size config"
 ✔ Valid pdf html configuration with data set "styles config"
 ✔ Valid pdf html configuration with data set "different scale"
 ✔ Valid pdf html configuration with data set "range a page to generate"
 ✔ Valid pdf html configuration with data set "delay to wait before generate"
 ✔ Valid pdf html configuration with data set "emulated media type"
 ✔ Valid pdf html configuration with data set "exception render"
 ✔ Valid pdf html configuration with data set "pdf format configuration"
 ✔ Valid pdf html configuration with data set "pdf universal configuration"
 ✔ Valid pdf html configuration with data set "both pdf configuration"
 ✔ Valid pdf html configuration with data set "Update accepted status codes from the main page"
 ✔ Valid pdf html configuration with data set "waits for the network idle"
 ✔ Valid pdf html configuration with data set "add cookies to store"
 ✔ With extra headers configuration
 ✔ Valid screenshot html configuration with data set "screenshot size config"
 ✔ Valid screenshot html configuration with data set "clip config"
 ✔ Valid screenshot html configuration with data set "screenshot format"
 ✔ Valid screenshot html configuration with data set "quality"
 ✔ Valid screenshot html configuration with data set "omit background"
 ✔ Valid screenshot html configuration with data set "optimize for speed"
 ✔ Valid screenshot html configuration with data set "delay to wait before generate"
 ✔ Valid screenshot html configuration with data set "emulated media type"
 ✔ Valid screenshot html configuration with data set "add cookies to store"
 ✔ Valid screenshot html configuration with data set "Update accepted status codes from the main page"
 ✔ Valid screenshot html configuration with data set "exception render"
 ✔ Valid screenshot html configuration with data set "performance mode"

Gotenberg Client (Sensiolabs\GotenbergBundle\Tests\Client\GotenbergClient)
 ✔ Pdf call
 ✔ Screenshot call

Gotenberg Pdf (Sensiolabs\GotenbergBundle\Tests\GotenbergPdf)
 ✔ Url builder factory
 ✔ Html builder factory
 ✔ Markdown builder factory
 ✔ Office builder factory

Gotenberg Screenshot (Sensiolabs\GotenbergBundle\Tests\GotenbergScreenshot)
 ✔ Url builder factory
 ✔ Html builder factory
 ✔ Markdown builder factory

Html Pdf Builder (Sensiolabs\GotenbergBundle\Tests\Builder\Pdf\HtmlPdfBuilder)
 ✔ Endpoint is correct
 ✔ With plain content file with data set "with twig"
 ✔ With plain content file with data set "without twig"
 ✔ With twig content file
 ✔ Required form data

Html Screenshot Builder (Sensiolabs\GotenbergBundle\Tests\Builder\Screenshot\HtmlScreenshotBuilder)
 ✔ Endpoint is correct
 ✔ With plain content file with data set "with twig"
 ✔ With plain content file with data set "without twig"
 ✔ With twig content file
 ✔ Required form data

Libre Office Pdf Builder (Sensiolabs\GotenbergBundle\Tests\Builder\Pdf\LibreOfficePdfBuilder)
 ✔ Endpoint is correct
 ✔ Configuration is correctly set with data set "pdf_format"
 ✔ Configuration is correctly set with data set "pdf_universal_access"
 ✔ Configuration is correctly set with data set "landscape"
 ✔ Configuration is correctly set with data set "native_page_ranges"
 ✔ Configuration is correctly set with data set "merge"
 ✔ Configuration is correctly set with data set "metadata"
 ✔ Office files with data set "odt"
 ✔ Office files with data set "docx"
 ✔ Office files with data set "html"
 ✔ Office files with data set "xslx"
 ✔ Office files with data set "pptx"
 ✔ Required form data

Markdown Pdf Builder (Sensiolabs\GotenbergBundle\Tests\Builder\Pdf\MarkdownPdfBuilder)
 ✔ Endpoint is correct
 ✔ Required wrapper template
 ✔ Required markdown file

Markdown Screenshot Builder (Sensiolabs\GotenbergBundle\Tests\Builder\Screenshot\MarkdownScreenshotBuilder)
 ✔ Endpoint is correct
 ✔ Markdown file
 ✔ Required wrapper template
 ✔ Required markdown file

Paper Size (Sensiolabs\GotenbergBundle\Tests\Enum\PaperSize)
 ✔ Unit is always inches
 ✔ Width
 ✔ Height

Sensiolabs Gotenberg Extension (Sensiolabs\GotenbergBundle\Tests\DependencyInjection\SensiolabsGotenbergExtension)
 ✔ Gotenberg configured with valid config
 ✔ Gotenberg client configured with default config
 ✔ Gotenberg client configured with valid config

Unit (Enum\Unit)
 ✔ It can be parsed correctly with data set "(int) 12"
 ✔ It can be parsed correctly with data set "(string) 12"
 ✔ It can be parsed correctly with data set "12.0"
 ✔ It can be parsed correctly with data set "12.1"
 ✔ It can be parsed correctly with data set "12.1in"
 ✔ It can be parsed correctly with data set "12.1pc"

Url Pdf Builder (Sensiolabs\GotenbergBundle\Tests\Builder\Pdf\UrlPdfBuilder)
 ✔ Endpoint is correct
 ✔ Url
 ✔ Required form data

Url Screenshot Builder (Sensiolabs\GotenbergBundle\Tests\Builder\Screenshot\UrlScreenshotBuilder)
 ✔ Endpoint is correct
 ✔ Url
 ✔ Required form data

OK (173 tests, 370 assertions)

Generating code coverage report in HTML format ... done [00:00.097]
Capture d’écran 2024-05-31 à 16 23 46

@Neirda24 Neirda24 changed the title WIP : [UPDATE] Update and modify some builder tests [UPDATE] Update and modify some builder tests May 31, 2024

$data = $builder->getMultipartFormData();

self::assertCount(2, $data);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self:: or $this->, that is the question.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No diff on phpunit side. Which one do you prefer ?

Copy link
Contributor

@Jean-Beru Jean-Beru May 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I does not matter to me.

toss a coin
...
wait a bit for suspens
...
STATIC !

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will follow your lead

gandalf

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 33 to 34
$builder->files(self::OFFICE_DOCUMENTS_DIR.'/document_1.docx');
$builder->generate();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be chained

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@Neirda24 Neirda24 self-assigned this May 31, 2024
@Neirda24 Neirda24 added this to the v8.0.0 milestone May 31, 2024
@Neirda24 Neirda24 merged commit 7eea2cb into main Jun 1, 2024
@Neirda24 Neirda24 deleted the feature/tests branch June 1, 2024 06:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants