Last active
May 4, 2018 19:53
-
-
Save awm086/b344a9c2f015e202bf9faefa3daf2c94 to your computer and use it in GitHub Desktop.
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
diff --git a/src/PrintBuilder.php b/src/PrintBuilder.php | |
index 7da7a04..a0d846c 100644 | |
--- a/src/PrintBuilder.php | |
+++ b/src/PrintBuilder.php | |
@@ -52,6 +52,9 @@ class PrintBuilder implements PrintBuilderInterface { | |
* {@inheritdoc} | |
*/ | |
public function deliverPrintable(array $entities, PrintEngineInterface $print_engine, $force_download = FALSE, $use_default_css = TRUE) { | |
+ if (empty($entities)) { | |
+ throw new PrintEngineException('access denied.'); | |
+ } | |
$renderer = $this->prepareRenderer($entities, $print_engine, $use_default_css); | |
// Allow other modules to alter the generated Print object. | |
diff --git a/tests/src/Kernel/PrintBuilderTest.php b/tests/src/Kernel/PrintBuilderTest.php | |
index b33ec45..7710426 100644 | |
--- a/tests/src/Kernel/PrintBuilderTest.php | |
+++ b/tests/src/Kernel/PrintBuilderTest.php | |
@@ -71,12 +71,11 @@ class PrintBuilderTest extends KernelTestBase { | |
* Test that you must pass at least 1 entity. | |
* | |
* @covers ::deliverPrintable | |
- * @expectedException \InvalidArgumentException | |
- * @expectedExceptionMessage You must pass at least 1 entity | |
*/ | |
public function testNoEntities() { | |
$print_engine = $this->container->get('plugin.manager.entity_print.print_engine')->createInstance('testprintengine'); | |
- $this->container->get('entity_print.print_builder')->deliverPrintable([], $print_engine, TRUE); | |
+ $return = $this->container->get('entity_print.print_builder')->deliverPrintable([], $print_engine, TRUE); | |
+ $this->assertFalse($return); | |
} | |
/** |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment