Loading src/Tests/LingotekNodeBulkFormPagerTest.php→src/Tests/Form/LingotekNodeBulkFormTest.php +187 −0 Original line number Diff line number Diff line <?php namespace Drupal\lingotek\Tests; namespace Drupal\lingotek\Tests\Form; use Drupal\Core\Url; use Drupal\language\Entity\ConfigurableLanguage; use Drupal\language\Entity\ContentLanguageSettings; use Drupal\node\Entity\Node; use Drupal\node\NodeInterface; use Drupal\lingotek\Tests\LingotekTestBase; /** * Tests translating a node using the bulk management form. * Tests the bulk management form. * * @group lingotek */ class LingotekNodeBulkFormPagerTest extends LingotekTestBase { class LingotekNodeBulkFormTest extends LingotekTestBase { /** * Modules to install. * * @var array * {@inheritdoc} */ public static $modules = ['block', 'node']; /** * @var NodeInterface * A node used for testing. * * @var \Drupal\node\NodeInterface */ protected $node; /** * {@inheritdoc} */ protected function setUp() { parent::setUp(); Loading Loading @@ -88,9 +89,11 @@ class LingotekNodeBulkFormPagerTest extends LingotekTestBase { // I can init the upload of content. $this->assertLinkByHref($basepath . '/admin/lingotek/entity/upload/node/11?destination=' . $basepath . '/admin/lingotek/manage/node'); $edit = [ 'table[11]' => TRUE, // Node 11. 'table[12]' => TRUE, // Node 12. 'operation' => 'upload' // Node 11. 'table[11]' => TRUE, // Node 12. 'table[12]' => TRUE, 'operation' => 'upload', ]; $this->drupalPostForm(NULL, $edit, t('Execute')); Loading @@ -108,4 +111,77 @@ class LingotekNodeBulkFormPagerTest extends LingotekTestBase { $this->assertUrl('admin/lingotek/manage/node?page=1'); } /** * Tests that the bulk management profile filtering works correctly. */ public function testProfileFilter() { $nodes = []; // Create a node. for ($i = 1; $i < 15; $i++) { $profile = 'automatic'; if ($i % 2 == 0) { $profile = 'manual'; } elseif ($i % 3 == 0) { $profile = 'disabled'; } $edit = array(); $edit['title[0][value]'] = 'Llamas are cool ' . $i; $edit['body[0][value]'] = 'Llamas are very cool ' . $i; $edit['langcode[0][value]'] = 'en'; $edit['lingotek_translation_profile'] = $profile; $this->drupalPostForm('node/add/article', $edit, t('Save and publish')); $nodes[$i] = $edit; } $this->goToContentBulkManagementForm(); // Assert there is a pager. $this->assertLinkByHref('?page=1'); // After we filter by automatic profile, there is no pager and the rows // selected are the ones expected. $edit = [ 'filters[wrapper][profile]' => 'automatic', ]; $this->drupalPostForm(NULL, $edit, 'Filter'); foreach ([1, 5, 7, 11, 13] as $j) { $this->assertLink('Llamas are cool ' . $j); } $this->assertNoLinkByHref('?page=1'); $this->assertNoLink('Llamas are cool 2'); // After we filter by manual profile, there is no pager and the rows // selected are the ones expected. $edit = [ 'filters[wrapper][profile]' => 'manual', ]; $this->drupalPostForm(NULL, $edit, 'Filter'); foreach ([2, 4, 6, 8, 10, 12, 14] as $j) { $this->assertLink('Llamas are cool ' . $j); } $this->assertNoLink('Page 2'); $this->assertNoLink('Llamas are cool 1'); // After we filter by disabled profile, there is no pager and the rows // selected are the ones expected. $edit = [ 'filters[wrapper][profile]' => 'disabled', ]; $this->drupalPostForm(NULL, $edit, 'Filter'); foreach ([3, 9] as $j) { $this->assertLink('Llamas are cool ' . $j); } $this->assertNoLinkByHref('?page=1'); $this->assertNoLink('Llamas are cool 5'); // After we reset, we get back to having a pager and all the content. $this->drupalPostForm(NULL, [], 'Reset'); foreach (range(1, 10) as $j) { $this->assertLink('Llamas are cool ' . $j); } $this->assertLinkByHref('?page=1'); } } Loading
src/Tests/LingotekNodeBulkFormPagerTest.php→src/Tests/Form/LingotekNodeBulkFormTest.php +187 −0 Original line number Diff line number Diff line <?php namespace Drupal\lingotek\Tests; namespace Drupal\lingotek\Tests\Form; use Drupal\Core\Url; use Drupal\language\Entity\ConfigurableLanguage; use Drupal\language\Entity\ContentLanguageSettings; use Drupal\node\Entity\Node; use Drupal\node\NodeInterface; use Drupal\lingotek\Tests\LingotekTestBase; /** * Tests translating a node using the bulk management form. * Tests the bulk management form. * * @group lingotek */ class LingotekNodeBulkFormPagerTest extends LingotekTestBase { class LingotekNodeBulkFormTest extends LingotekTestBase { /** * Modules to install. * * @var array * {@inheritdoc} */ public static $modules = ['block', 'node']; /** * @var NodeInterface * A node used for testing. * * @var \Drupal\node\NodeInterface */ protected $node; /** * {@inheritdoc} */ protected function setUp() { parent::setUp(); Loading Loading @@ -88,9 +89,11 @@ class LingotekNodeBulkFormPagerTest extends LingotekTestBase { // I can init the upload of content. $this->assertLinkByHref($basepath . '/admin/lingotek/entity/upload/node/11?destination=' . $basepath . '/admin/lingotek/manage/node'); $edit = [ 'table[11]' => TRUE, // Node 11. 'table[12]' => TRUE, // Node 12. 'operation' => 'upload' // Node 11. 'table[11]' => TRUE, // Node 12. 'table[12]' => TRUE, 'operation' => 'upload', ]; $this->drupalPostForm(NULL, $edit, t('Execute')); Loading @@ -108,4 +111,77 @@ class LingotekNodeBulkFormPagerTest extends LingotekTestBase { $this->assertUrl('admin/lingotek/manage/node?page=1'); } /** * Tests that the bulk management profile filtering works correctly. */ public function testProfileFilter() { $nodes = []; // Create a node. for ($i = 1; $i < 15; $i++) { $profile = 'automatic'; if ($i % 2 == 0) { $profile = 'manual'; } elseif ($i % 3 == 0) { $profile = 'disabled'; } $edit = array(); $edit['title[0][value]'] = 'Llamas are cool ' . $i; $edit['body[0][value]'] = 'Llamas are very cool ' . $i; $edit['langcode[0][value]'] = 'en'; $edit['lingotek_translation_profile'] = $profile; $this->drupalPostForm('node/add/article', $edit, t('Save and publish')); $nodes[$i] = $edit; } $this->goToContentBulkManagementForm(); // Assert there is a pager. $this->assertLinkByHref('?page=1'); // After we filter by automatic profile, there is no pager and the rows // selected are the ones expected. $edit = [ 'filters[wrapper][profile]' => 'automatic', ]; $this->drupalPostForm(NULL, $edit, 'Filter'); foreach ([1, 5, 7, 11, 13] as $j) { $this->assertLink('Llamas are cool ' . $j); } $this->assertNoLinkByHref('?page=1'); $this->assertNoLink('Llamas are cool 2'); // After we filter by manual profile, there is no pager and the rows // selected are the ones expected. $edit = [ 'filters[wrapper][profile]' => 'manual', ]; $this->drupalPostForm(NULL, $edit, 'Filter'); foreach ([2, 4, 6, 8, 10, 12, 14] as $j) { $this->assertLink('Llamas are cool ' . $j); } $this->assertNoLink('Page 2'); $this->assertNoLink('Llamas are cool 1'); // After we filter by disabled profile, there is no pager and the rows // selected are the ones expected. $edit = [ 'filters[wrapper][profile]' => 'disabled', ]; $this->drupalPostForm(NULL, $edit, 'Filter'); foreach ([3, 9] as $j) { $this->assertLink('Llamas are cool ' . $j); } $this->assertNoLinkByHref('?page=1'); $this->assertNoLink('Llamas are cool 5'); // After we reset, we get back to having a pager and all the content. $this->drupalPostForm(NULL, [], 'Reset'); foreach (range(1, 10) as $j) { $this->assertLink('Llamas are cool ' . $j); } $this->assertLinkByHref('?page=1'); } }