class PrintEngineExceptionTest in Entity Print 8.2
Test print engine exceptions.
@group entity_print
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait- class \Drupal\Tests\entity_print\Unit\PrintEngineExceptionTest
 
Expanded class hierarchy of PrintEngineExceptionTest
File
- tests/src/ Unit/ PrintEngineExceptionTest.php, line 14 
Namespace
Drupal\Tests\entity_print\UnitView source
class PrintEngineExceptionTest extends UnitTestCase {
  /**
   * {@inheritdoc}
   */
  public function setUp() : void {
    parent::setUp();
    $container = new ContainerBuilder();
    $container
      ->set('string_translation', $this
      ->getStringTranslationStub());
    \Drupal::setContainer($container);
  }
  /**
   * Tests the pretty error messages for authorisation failures.
   *
   * @dataProvider authorisationExceptions
   */
  public function testAuthorisationException($message) {
    $exception = new PrintEngineException($message);
    $this
      ->assertEquals('Authorisation failed, are your resources behind HTTP authentication? Check the admin page to set credentials.', $exception
      ->getPrettyMessage());
  }
  /**
   * Gets the exception messages for the providers for authorisation failures.
   *
   * @return array
   *   An array of possible exception messages.
   */
  public function authorisationExceptions() {
    return [
      'Dompdf' => [
        'Failed to generate PDF: file_get_contents(http://d8.dev/sites/default/files/css/css_qm-4SpSW1uLvtwb-T4OPS48NMb2DSFqwLd5C3MLRLuY.css?om2pmk): failed to open stream: HTTP request failed! HTTP/1.1 401 Unauthorized , Unable to load css file http://d8.dev/sites/default/files/css/css_qm-4SpSW1uLvtwb-T4OPS48NMb2DSFqwLd5C3MLRLuY.css?om2pmk',
      ],
      'wkhtmltopdf' => [
        'Failed to generate PDF: Loading pages (1/6) [> ] 0% [======> ] 10% [==========> ] 18% Error: Invalid username or password [============================================================] 100% Counting pages (2/6) [============================================================] Object 1 of 1 Resolving links (4/6) [============================================================] Object 1 of 1 Loading headers and footers (5/6) Printing pages (6/6) [> ] Preparing [============================================================] Page 1 of 1 Done Exit with code 1 due to network error: AuthenticationRequiredError',
      ],
    ];
  }
}Members
| Name   | Modifiers | Type | Description | Overrides | 
|---|---|---|---|---|
| PhpunitCompatibilityTrait:: | public | function | Returns a mock object for the specified class using the available method. | |
| PhpunitCompatibilityTrait:: | public | function | Compatibility layer for PHPUnit 6 to support PHPUnit 4 code. | |
| PrintEngineExceptionTest:: | public | function | Gets the exception messages for the providers for authorisation failures. | |
| PrintEngineExceptionTest:: | public | function | Overrides UnitTestCase:: | |
| PrintEngineExceptionTest:: | public | function | Tests the pretty error messages for authorisation failures. | |
| UnitTestCase:: | protected | property | The random generator. | |
| UnitTestCase:: | protected | property | The app root. | 1 | 
| UnitTestCase:: | protected | function | Asserts if two arrays are equal by sorting them first. | |
| UnitTestCase:: | protected | function | Mocks a block with a block plugin. | 1 | 
| UnitTestCase:: | protected | function | Returns a stub class resolver. | |
| UnitTestCase:: | public | function | Returns a stub config factory that behaves according to the passed array. | |
| UnitTestCase:: | public | function | Returns a stub config storage that returns the supplied configuration. | |
| UnitTestCase:: | protected | function | Sets up a container with a cache tags invalidator. | |
| UnitTestCase:: | protected | function | Gets the random generator for the utility methods. | |
| UnitTestCase:: | public | function | Returns a stub translation manager that just returns the passed string. | |
| UnitTestCase:: | public | function | Generates a unique random string containing letters and numbers. | 
