You are here

class XlsxExporterTest in Webform XLSX export 8

Class XlsxExporterTest.

@package Drupal\Tests\webform_xlsx_export\Unit

@group webform_xlsx_export

Hierarchy

Expanded class hierarchy of XlsxExporterTest

File

tests/src/Unit/XlsxExporterTest.php, line 20

Namespace

Drupal\Tests\webform_xlsx_export\Unit
View source
class XlsxExporterTest extends UnitTestCase {

  /**
   * Exporter class used in tests.
   *
   * @var \Drupal\webform_xlsx_export\Plugin\WebformExporter\XlsxExporter
   */
  private $exporter;

  /**
   * Prepare variables used in tests.
   */
  protected function setUp() {
    parent::setUp();

    /** @var \Psr\Log\LoggerInterface $logger */
    $logger = $this
      ->createMock(LoggerInterface::class);

    /** @var \Drupal\Core\Config\ConfigFactoryInterface $config_factory */
    $config_factory = $this
      ->createMock(ConfigFactoryInterface::class);

    /** @var \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager */
    $entity_type_manager = $this
      ->createMock(EntityTypeManagerInterface::class);

    /** @var \Drupal\webform\Plugin\WebformElementManagerInterface $element_manager */
    $element_manager = $this
      ->createMock(WebformElementManagerInterface::class);

    /** @var \Drupal\webform\WebformTokenManagerInterface $token_manager */
    $token_manager = $this
      ->createMock(WebformTokenManagerInterface::class);
    $this->exporter = new XlsxExporter([], 'foo', NULL, $logger, $config_factory, $entity_type_manager, $element_manager, $token_manager);
  }

  /**
   * Test getFileExtension().
   */
  public function testGetFileExtension() {
    $this
      ->assertEquals('xlsx', $this->exporter
      ->getFileExtension());
  }

  /**
   * Test createExport().
   */
  public function testCreateExport() {
    $this
      ->assertNull($this->exporter
      ->createExport());
  }

  /**
   * Test openExport().
   */
  public function testOpenExport() {
    $this
      ->markTestIncomplete('We need to mock ConfigFactoryInterface.');
  }

  /**
   * Test closeExport().
   */
  public function testCloseExport() {
    $this
      ->markTestIncomplete('We need to mock ConfigFactoryInterface.');
  }

}

Members

Namesort descending Modifiers Type Description Overrides
PhpunitCompatibilityTrait::getMock Deprecated public function Returns a mock object for the specified class using the available method.
PhpunitCompatibilityTrait::setExpectedException Deprecated public function Compatibility layer for PHPUnit 6 to support PHPUnit 4 code.
UnitTestCase::$randomGenerator protected property The random generator.
UnitTestCase::$root protected property The app root. 1
UnitTestCase::assertArrayEquals protected function Asserts if two arrays are equal by sorting them first.
UnitTestCase::getBlockMockWithMachineName Deprecated protected function Mocks a block with a block plugin. 1
UnitTestCase::getClassResolverStub protected function Returns a stub class resolver.
UnitTestCase::getConfigFactoryStub public function Returns a stub config factory that behaves according to the passed array.
UnitTestCase::getConfigStorageStub public function Returns a stub config storage that returns the supplied configuration.
UnitTestCase::getContainerWithCacheTagsInvalidator protected function Sets up a container with a cache tags invalidator.
UnitTestCase::getRandomGenerator protected function Gets the random generator for the utility methods.
UnitTestCase::getStringTranslationStub public function Returns a stub translation manager that just returns the passed string.
UnitTestCase::randomMachineName public function Generates a unique random string containing letters and numbers.
XlsxExporterTest::$exporter private property Exporter class used in tests.
XlsxExporterTest::setUp protected function Prepare variables used in tests. Overrides UnitTestCase::setUp
XlsxExporterTest::testCloseExport public function Test closeExport().
XlsxExporterTest::testCreateExport public function Test createExport().
XlsxExporterTest::testGetFileExtension public function Test getFileExtension().
XlsxExporterTest::testOpenExport public function Test openExport().