Loading tests/src/Functional/CommerceDevelGenerateCommandTest.php 0 → 100644 +55 −0 Original line number Diff line number Diff line <?php namespace Drupal\Tests\devel_generate_commerce\Functional; use Drupal\Tests\BrowserTestBase; use Drupal\Tests\devel_generate\Traits\DevelGenerateSetupTrait; use Drush\TestTraits\DrushTestTrait; /** * Devel Generate Commerce Module Drush Command Test. * * @group devel_generate_commerce */ class CommerceDevelGenerateCommandTest extends BrowserTestBase { use DrushTestTrait; use DevelGenerateSetupTrait; /** * {@inheritdoc} */ protected $defaultTheme = 'stable'; /** * {@inheritdoc} */ protected static $modules = ['node', 'block', 'devel_generate_commerce']; /** * {@inheritdoc} */ protected function setUp(): void { parent::setUp(); $this->drupalPlaceBlock('page_title_block'); } /** * Tests generating commerce entities via drush. */ public function testDrushGenerateCommand() { // Creates commerce entities With out Kill Option. $options = [ 'products_num' => 55, 'kill' => NULL, ]; $this->drush('devel-generate:commerce', $options); $commerce_entities = \Drupal::entityQuery('commerce')->accessCheck(TRUE)->execute(); $this->assertCount(55, $commerce_entities); $messages = $this->getErrorOutput(); $this->assertStringContainsStringIgnoringCase('Finished 55 elements created successfully.', $messages, 'devel-generate:commerce batch ending message not found'); } } tests/src/Functional/ModuleLoadTest.php 0 → 100644 +101 −0 Original line number Diff line number Diff line <?php namespace Drupal\Tests\devel_generate_commerce\Functional; use Drupal\Tests\BrowserTestBase; /** * Devel Generate Commerce Module Load Test. * * @group devel_generate_commerce */ class ModuleLoadTest extends BrowserTestBase { /** * {@inheritdoc} */ protected $defaultTheme = 'stable'; /** * {@inheritdoc} */ protected static $modules = ['node', 'block', 'devel_generate_commerce']; /** * {@inheritdoc} */ protected function setUp(): void { parent::setUp(); $this->drupalPlaceBlock('page_title_block'); } /** * Tests Homepage after enabling Devel Generate Commerce Module. */ public function testHomepage() { // Test homepage. $this->drupalGet('<front>'); $this->assertSession()->statusCodeEquals(200); // Minimal homepage title. $this->assertSession()->pageTextContains('Log in'); } /** * Tests the Devel Generate Commerce module unistall. */ public function testModuleUninstall() { $admin_user = $this->drupalCreateUser([ 'access administration pages', 'administer site configuration', 'administer modules', ]); // Uninstall the module. $this->drupalLogin($admin_user); $this->drupalGet('/admin/modules/uninstall'); $this->assertSession()->statusCodeEquals(200); $this->assertSession()->pageTextContains('Devel Generate Commerce'); $this->submitForm(['uninstall[devel_generate_commerce]' => TRUE], 'Uninstall'); $this->submitForm([], 'Uninstall'); $this->assertSession()->pageTextContains('The selected modules have been uninstalled.'); $this->assertSession()->pageTextNotContains('Devel Generate Commerce'); // Visit the frontpage. $this->drupalGet(''); $this->assertSession()->statusCodeEquals(200); } /** * Tests Devel Generate Commerce module reinstalling after being uninstalled. */ public function testReinstallAfterUninstall() { $admin_user = $this->drupalCreateUser([ 'access administration pages', 'administer site configuration', 'administer modules', ]); // Uninstall the module. $this->drupalLogin($admin_user); $assert_session = $this->assertSession(); $page = $this->getSession()->getPage(); // Uninstall the Devel Generate Commerce module. $this->container->get('module_installer')->uninstall(['devel_generate_commerce'], FALSE); $this->drupalGet('/admin/modules'); $page->checkField('modules[devel_generate_commerce][enable]'); $page->pressButton('Install'); $assert_session->pageTextNotContains('Unable to install Devel Generate Commerce'); $assert_session->pageTextContains('Module Devel Generate Commerce has been enabled'); } } Loading
tests/src/Functional/CommerceDevelGenerateCommandTest.php 0 → 100644 +55 −0 Original line number Diff line number Diff line <?php namespace Drupal\Tests\devel_generate_commerce\Functional; use Drupal\Tests\BrowserTestBase; use Drupal\Tests\devel_generate\Traits\DevelGenerateSetupTrait; use Drush\TestTraits\DrushTestTrait; /** * Devel Generate Commerce Module Drush Command Test. * * @group devel_generate_commerce */ class CommerceDevelGenerateCommandTest extends BrowserTestBase { use DrushTestTrait; use DevelGenerateSetupTrait; /** * {@inheritdoc} */ protected $defaultTheme = 'stable'; /** * {@inheritdoc} */ protected static $modules = ['node', 'block', 'devel_generate_commerce']; /** * {@inheritdoc} */ protected function setUp(): void { parent::setUp(); $this->drupalPlaceBlock('page_title_block'); } /** * Tests generating commerce entities via drush. */ public function testDrushGenerateCommand() { // Creates commerce entities With out Kill Option. $options = [ 'products_num' => 55, 'kill' => NULL, ]; $this->drush('devel-generate:commerce', $options); $commerce_entities = \Drupal::entityQuery('commerce')->accessCheck(TRUE)->execute(); $this->assertCount(55, $commerce_entities); $messages = $this->getErrorOutput(); $this->assertStringContainsStringIgnoringCase('Finished 55 elements created successfully.', $messages, 'devel-generate:commerce batch ending message not found'); } }
tests/src/Functional/ModuleLoadTest.php 0 → 100644 +101 −0 Original line number Diff line number Diff line <?php namespace Drupal\Tests\devel_generate_commerce\Functional; use Drupal\Tests\BrowserTestBase; /** * Devel Generate Commerce Module Load Test. * * @group devel_generate_commerce */ class ModuleLoadTest extends BrowserTestBase { /** * {@inheritdoc} */ protected $defaultTheme = 'stable'; /** * {@inheritdoc} */ protected static $modules = ['node', 'block', 'devel_generate_commerce']; /** * {@inheritdoc} */ protected function setUp(): void { parent::setUp(); $this->drupalPlaceBlock('page_title_block'); } /** * Tests Homepage after enabling Devel Generate Commerce Module. */ public function testHomepage() { // Test homepage. $this->drupalGet('<front>'); $this->assertSession()->statusCodeEquals(200); // Minimal homepage title. $this->assertSession()->pageTextContains('Log in'); } /** * Tests the Devel Generate Commerce module unistall. */ public function testModuleUninstall() { $admin_user = $this->drupalCreateUser([ 'access administration pages', 'administer site configuration', 'administer modules', ]); // Uninstall the module. $this->drupalLogin($admin_user); $this->drupalGet('/admin/modules/uninstall'); $this->assertSession()->statusCodeEquals(200); $this->assertSession()->pageTextContains('Devel Generate Commerce'); $this->submitForm(['uninstall[devel_generate_commerce]' => TRUE], 'Uninstall'); $this->submitForm([], 'Uninstall'); $this->assertSession()->pageTextContains('The selected modules have been uninstalled.'); $this->assertSession()->pageTextNotContains('Devel Generate Commerce'); // Visit the frontpage. $this->drupalGet(''); $this->assertSession()->statusCodeEquals(200); } /** * Tests Devel Generate Commerce module reinstalling after being uninstalled. */ public function testReinstallAfterUninstall() { $admin_user = $this->drupalCreateUser([ 'access administration pages', 'administer site configuration', 'administer modules', ]); // Uninstall the module. $this->drupalLogin($admin_user); $assert_session = $this->assertSession(); $page = $this->getSession()->getPage(); // Uninstall the Devel Generate Commerce module. $this->container->get('module_installer')->uninstall(['devel_generate_commerce'], FALSE); $this->drupalGet('/admin/modules'); $page->checkField('modules[devel_generate_commerce][enable]'); $page->pressButton('Install'); $assert_session->pageTextNotContains('Unable to install Devel Generate Commerce'); $assert_session->pageTextContains('Module Devel Generate Commerce has been enabled'); } }