You are here

protected function InvoiceGeneratorTest::setUp in Commerce Invoice 8.2

Overrides InvoiceKernelTestBase::setUp

File

tests/src/Kernel/InvoiceGeneratorTest.php, line 59

Class

InvoiceGeneratorTest
Tests the invoice generator service.

Namespace

Drupal\Tests\commerce_invoice\Kernel

Code

protected function setUp() : void {
  parent::setUp();
  $this
    ->installConfig([
    'commerce_product',
  ]);
  $this
    ->installConfig([
    'language',
  ]);
  $this
    ->installEntitySchema('commerce_product_variation');

  // Turn off title generation to allow explicit values to be used.
  $variation_type = ProductVariationType::load('default');
  $variation_type
    ->setGenerateTitle(FALSE);
  $variation_type
    ->save();
  ConfigurableLanguage::createFromLangcode('fr')
    ->save();
  $this->container
    ->get('content_translation.manager')
    ->setEnabled('commerce_product_variation', 'default', TRUE);
  $this->invoiceGenerator = $this->container
    ->get('commerce_invoice.invoice_generator');
  $user = $this
    ->createUser();
  $this->user = $this
    ->reloadEntity($user);
  $profile = Profile::create([
    'type' => 'customer',
    'address' => [
      'country_code' => 'US',
      'postal_code' => '53177',
      'locality' => 'Milwaukee',
      'address_line1' => 'Pabst Blue Ribbon Dr',
      'administrative_area' => 'WI',
      'given_name' => 'Frederick',
      'family_name' => 'Pabst',
    ],
    'uid' => $this->user
      ->id(),
  ]);
  $profile
    ->save();
  $this->profile = $this
    ->reloadEntity($profile);
  $invoice_type = InvoiceType::load('default');
  $invoice_type
    ->setPaymentTerms('Payment terms');
  $invoice_type
    ->setFooterText('Footer text');
  $invoice_type
    ->save();
  $language_manager = \Drupal::languageManager();
  $config_translation = $language_manager
    ->getLanguageConfigOverride('fr', 'commerce_invoice.commerce_invoice_type.default');
  $config_translation
    ->setData([
    'paymentTerms' => 'Termes de paiement',
    'footerText' => 'Texte pied de page',
  ]);
  $config_translation
    ->save();
}