diff --git a/modules/features_ui/tests/src/Functional/FeaturesBundleUiTest.php b/modules/features_ui/tests/src/Functional/FeaturesBundleUiTest.php index 6a0efab..2253402 100644 --- a/modules/features_ui/tests/src/Functional/FeaturesBundleUiTest.php +++ b/modules/features_ui/tests/src/Functional/FeaturesBundleUiTest.php @@ -91,14 +91,14 @@ class FeaturesBundleUiTest extends BrowserTestBase { // Check initial form. $this->drupalGet('admin/config/development/features/bundle/_exclude/default'); - $this->assertFieldChecked('edit-types-config-features-bundle', 'features_bundle is checked'); - $this->assertNoFieldChecked('edit-types-config-system-simple', 'system_simple is not checked'); - $this->assertNoFieldChecked('edit-types-config-user-role', 'user_role is not checked'); - $this->assertFieldChecked('edit-curated', 'curated is checked'); - $this->assertFieldChecked('edit-module-namespace', 'namespace is checked'); + $this->assertSession()->checkboxChecked('edit-types-config-features-bundle'); + $this->assertSession()->checkboxNotChecked('edit-types-config-system-simple'); + $this->assertSession()->checkboxNotChecked('edit-types-config-user-role'); + $this->assertSession()->checkboxChecked('edit-curated'); + $this->assertSession()->checkboxChecked('edit-module-namespace'); // Configure the form. - $this->drupalPostForm(NULL, [ + $this->submitForm([ 'types[config][system_simple]' => TRUE, 'types[config][user_role]' => FALSE, 'curated' => TRUE, @@ -107,11 +107,11 @@ class FeaturesBundleUiTest extends BrowserTestBase { // Check form results. $this->drupalGet('admin/config/development/features/bundle/_exclude/default'); - $this->assertFieldChecked('edit-types-config-features-bundle', 'Saved, features_bundle is checked'); - $this->assertFieldChecked('edit-types-config-system-simple', 'Saved, system_simple is checked'); - $this->assertNoFieldChecked('edit-types-config-user-role', 'Saved, user_role is not checked'); - $this->assertFieldChecked('edit-curated', 'Saved, curated is checked'); - $this->assertNoFieldChecked('edit-module-namespace', 'Saved, namespace is not checked'); + $this->assertSession()->checkboxChecked('edit-types-config-features-bundle'); + $this->assertSession()->checkboxChecked('edit-types-config-system-simple'); + $this->assertSession()->checkboxNotChecked('edit-types-config-user-role'); + $this->assertSession()->checkboxChecked('edit-curated'); + $this->assertSession()->checkboxNotChecked('edit-module-namespace'); // Check final values. $settings = $this->defaultBundle()->getAssignmentSettings('exclude'); @@ -143,19 +143,19 @@ class FeaturesBundleUiTest extends BrowserTestBase { // Can we visit the config page with no settings? $this->drupalGet('admin/config/development/features/bundle/_exclude/default'); - $this->assertNoFieldChecked('edit-types-config-features-bundle', 'features_bundle is not checked'); - $this->assertNoFieldChecked('edit-types-config-system-simple', 'system_simple is not checked'); - $this->assertNoFieldChecked('edit-types-config-user-role', 'user_role is not checked'); - $this->assertNoFieldChecked('edit-curated', 'curated is not checked'); - $this->assertNoFieldChecked('edit-module-namespace', 'namespace is not checked'); + $this->assertSession()->checkboxNotChecked('edit-types-config-features-bundle'); + $this->assertSession()->checkboxNotChecked('edit-types-config-system-simple'); + $this->assertSession()->checkboxNotChecked('edit-types-config-user-role'); + $this->assertSession()->checkboxNotChecked('edit-curated'); + $this->assertSession()->checkboxNotChecked('edit-module-namespace'); // Can we enable the method? $this->drupalGet('admin/config/development/features/bundle'); - $this->assertNoFieldChecked('edit-enabled-exclude', 'Exclude disabled'); - $this->drupalPostForm(NULL, [ + $this->assertSession()->checkboxNotChecked('edit-enabled-exclude'); + $this->submitForm([ 'enabled[exclude]' => TRUE, ], 'Save settings'); - $this->assertFieldChecked('edit-enabled-exclude', 'Exclude enabled'); + $this->assertSession()->checkboxChecked('edit-enabled-exclude', 'Exclude enabled'); // Check new settings. $settings = $this->defaultBundle()->getAssignmentSettings('exclude'); @@ -168,9 +168,10 @@ class FeaturesBundleUiTest extends BrowserTestBase { // Can we run assignment with no settings? $this->drupalGet('admin/config/development/features'); + $this->drupalGet('admin/config/development/features/bundle/_exclude/default'); // Can we configure the method? - $this->drupalPostForm('admin/config/development/features/bundle/_exclude/default', [ + $this->submitForm([ 'types[config][system_simple]' => TRUE, 'types[config][user_role]' => FALSE, 'curated' => TRUE, @@ -179,11 +180,11 @@ class FeaturesBundleUiTest extends BrowserTestBase { // Check form results. $this->drupalGet('admin/config/development/features/bundle/_exclude/default'); - $this->assertNoFieldChecked('edit-types-config-features-bundle', 'Saved, features_bundle is not checked'); - $this->assertFieldChecked('edit-types-config-system-simple', 'Saved, system_simple is checked'); - $this->assertNoFieldChecked('edit-types-config-user-role', 'Saved, user_role is not checked'); - $this->assertFieldChecked('edit-curated', 'Saved, curated is checked'); - $this->assertNoFieldChecked('edit-module-namespace', 'Saved, namespace is not checked'); + $this->assertSession()->checkboxNotChecked('edit-types-config-features-bundle'); + $this->assertSession()->checkboxChecked('edit-types-config-system-simple'); + $this->assertSession()->checkboxNotChecked('edit-types-config-user-role'); + $this->assertSession()->checkboxChecked('edit-curated'); + $this->assertSession()->checkboxNotChecked('edit-module-namespace'); // Check final values. $settings = $this->defaultBundle()->getAssignmentSettings('exclude'); diff --git a/modules/features_ui/tests/src/Functional/FeaturesCreateUiTest.php b/modules/features_ui/tests/src/Functional/FeaturesCreateUiTest.php index 27197b6..3fc7233 100644 --- a/modules/features_ui/tests/src/Functional/FeaturesCreateUiTest.php +++ b/modules/features_ui/tests/src/Functional/FeaturesCreateUiTest.php @@ -45,7 +45,7 @@ class FeaturesCreateUiTest extends BrowserTestBase { $this->drupalPlaceBlock('local_actions_block'); $this->drupalGet('admin/config/development/features'); $this->clickLink('Create new feature'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $edit = [ 'name' => 'Test feature', @@ -55,10 +55,10 @@ class FeaturesCreateUiTest extends BrowserTestBase { 'system_simple[sources][selected][system.theme]' => TRUE, 'system_simple[sources][selected][user.settings]' => TRUE, ]; - $this->drupalPostForm(NULL, $edit, 'Download Archive'); + $this->submitForm($edit, 'Download Archive'); - $this->assertResponse(200); - $archive = $this->getRawContent(); + $this->assertSession()->statusCodeEquals(200); + $archive = $this->getSession()->getPage()->getContent(); $filename = tempnam($this->tempFilesDirectory, 'feature'); file_put_contents($filename, $archive); @@ -89,12 +89,12 @@ class FeaturesCreateUiTest extends BrowserTestBase { // Ensure that the features listing renders the right content. $this->drupalGet('admin/config/development/features'); $tds = $this->xpath('//table[contains(@class, "features-listing")]/tbody/tr[td[3] = "' . $feature_name . '"]/td'); - $this->assertLink('Test feature'); + $this->assertSession()->linkExists('Test feature'); $this->assertEquals($feature_name, $tds[2]->getText()); $description_column = $tds[3]->getText(); $this->assertTrue(strpos($description_column, 'system.theme') !== FALSE); $this->assertTrue(strpos($description_column, 'user.settings') !== FALSE); - $this->assertRaw('Test description: giraffe'); + $this->assertSession()->responseContains('Test description: giraffe'); $this->assertEquals('Uninstalled', $tds[5]->getText()); $this->assertEquals('', $tds[6]->getText()); @@ -104,7 +104,7 @@ class FeaturesCreateUiTest extends BrowserTestBase { 'system_simple[included][system.theme]' => FALSE, 'user_role[sources][selected][authenticated]' => TRUE, ]; - $this->drupalPostForm(NULL, $edit, 'Write'); + $this->submitForm($edit, 'Write'); $info_filename = $module_path . '/' . $feature_name . '.info.yml'; $parsed_info = Yaml::decode(file_get_contents($info_filename)); @@ -124,7 +124,8 @@ class FeaturesCreateUiTest extends BrowserTestBase { // Install new feature module. $edit = []; $edit['modules[' . $feature_name . '][enable]'] = TRUE; - $this->drupalPostForm('admin/modules', $edit, 'Install'); + $this->drupalGet('admin/modules'); + $this->submitForm($edit, 'Install'); // Check that the feature is listed as installed. $this->drupalGet('admin/config/development/features'); @@ -143,9 +144,10 @@ class FeaturesCreateUiTest extends BrowserTestBase { $tds = $this->xpath('//table[contains(@class, "features-listing")]/tbody/tr[td[3] = "' . $feature_name . '"]/td'); $this->assertTrue(strpos($tds[6]->getText(), 'Changed') !== FALSE); + $this->drupalGet('admin/modules/uninstall'); // Uninstall the module. - $this->drupalPostForm('admin/modules/uninstall', ['uninstall[' . $feature_name . ']' => $feature_name], 'Uninstall'); + $this->submitForm(['uninstall[' . $feature_name . ']' => $feature_name], 'Uninstall'); $this->submitForm([], 'Uninstall'); $this->drupalGet('admin/config/development/features'); @@ -155,12 +157,13 @@ class FeaturesCreateUiTest extends BrowserTestBase { $this->clickLink('Changed'); $this->drupalGet('admin/config/development/features/diff/' . $feature_name); - $this->assertRaw('anonymous : Giraffe'); - $this->assertRaw('anonymous : Anonymous'); + $this->assertSession()->responseContains('anonymous : Giraffe'); + $this->assertSession()->responseContains('anonymous : Anonymous'); $edit = []; $edit['modules[' . $feature_name . '][enable]'] = TRUE; - $this->drupalPostForm('admin/modules', $edit, 'Install'); + $this->drupalGet('admin/modules'); + $this->submitForm($edit, 'Install'); $this->drupalGet('admin/config/development/features'); $tds = $this->xpath('//table[contains(@class, "features-listing")]/tbody/tr[td[3] = "' . $feature_name . '"]/td'); @@ -180,7 +183,7 @@ class FeaturesCreateUiTest extends BrowserTestBase { $this->assertTrue(strpos($tds[6]->getText(), 'Changed') !== FALSE); $this->clickLink('Test feature'); - $this->drupalPostForm(NULL, [], 'Write'); + $this->submitForm([], 'Write'); $this->drupalGet('admin/config/development/features'); $tds = $this->xpath('//table[contains(@class, "features-listing")]/tbody/tr[td[3] = "' . $feature_name . '"]/td'); diff --git a/tests/src/Kernel/FeaturesAssignTest.php b/tests/src/Kernel/FeaturesAssignTest.php index 948432f..23475ae 100644 --- a/tests/src/Kernel/FeaturesAssignTest.php +++ b/tests/src/Kernel/FeaturesAssignTest.php @@ -57,7 +57,7 @@ class FeaturesAssignTest extends KernelTestBase { /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->installConfig('features'); diff --git a/tests/src/Kernel/FeaturesAssignerTest.php b/tests/src/Kernel/FeaturesAssignerTest.php index a98c777..24cc219 100644 --- a/tests/src/Kernel/FeaturesAssignerTest.php +++ b/tests/src/Kernel/FeaturesAssignerTest.php @@ -20,7 +20,7 @@ class FeaturesAssignerTest extends KernelTestBase { /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); // We need system.site in order to run $this->configImporter->import(). $this->installConfig('system'); diff --git a/tests/src/Kernel/FeaturesGenerateTest.php b/tests/src/Kernel/FeaturesGenerateTest.php index 8e40b47..2c4a879 100644 --- a/tests/src/Kernel/FeaturesGenerateTest.php +++ b/tests/src/Kernel/FeaturesGenerateTest.php @@ -51,7 +51,7 @@ class FeaturesGenerateTest extends KernelTestBase { /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->installConfig('features'); diff --git a/tests/src/Kernel/FeaturesManagerKernelTest.php b/tests/src/Kernel/FeaturesManagerKernelTest.php index b81e23d..5f60f7d 100644 --- a/tests/src/Kernel/FeaturesManagerKernelTest.php +++ b/tests/src/Kernel/FeaturesManagerKernelTest.php @@ -36,7 +36,7 @@ class FeaturesManagerKernelTest extends KernelTestBase { /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->installConfig('features'); diff --git a/tests/src/Unit/FeaturesBundleTest.php b/tests/src/Unit/FeaturesBundleTest.php index 07ee199..3725945 100644 --- a/tests/src/Unit/FeaturesBundleTest.php +++ b/tests/src/Unit/FeaturesBundleTest.php @@ -2,6 +2,7 @@ namespace Drupal\Tests\features\Unit; +use Prophecy\PhpUnit\ProphecyTrait; use Drupal\features\Entity\FeaturesBundle; use Drupal\Tests\UnitTestCase; @@ -11,10 +12,11 @@ use Drupal\Tests\UnitTestCase; */ class FeaturesBundleTest extends UnitTestCase { + use ProphecyTrait; /** * {@inheritDoc} */ - public function setUp() { + public function setUp(): void { parent::setUp(); // Mock an assigner. diff --git a/tests/src/Unit/FeaturesManagerTest.php b/tests/src/Unit/FeaturesManagerTest.php index 640d3ae..23c548e 100644 --- a/tests/src/Unit/FeaturesManagerTest.php +++ b/tests/src/Unit/FeaturesManagerTest.php @@ -2,6 +2,7 @@ namespace Drupal\Tests\features\Unit; +use Prophecy\PhpUnit\ProphecyTrait; use Drupal\Component\Serialization\Yaml; use Drupal\config_update\ConfigDiffInterface; use Drupal\Core\Config\ConfigFactoryInterface; @@ -37,6 +38,7 @@ class FeaturesManagerTest extends UnitTestCase { * The name of the install profile. */ const PROFILE_NAME = 'my_profile'; + use ProphecyTrait; /** * The feature manager interface. @@ -48,56 +50,56 @@ class FeaturesManagerTest extends UnitTestCase { /** * The entity type manager object. * - * @var \Drupal\Core\Entity\EntityTypeManagerInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Drupal\Core\Entity\EntityTypeManagerInterface|\PHPUnit\Framework\MockObject\MockObject */ protected $entityTypeManager; /** * The storage interface object. * - * @var \Drupal\Core\Config\StorageInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Drupal\Core\Config\StorageInterface|\PHPUnit\Framework\MockObject\MockObject */ protected $configStorage; /** * The config factory. * - * @var \Drupal\Core\Config\ConfigFactoryInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Drupal\Core\Config\ConfigFactoryInterface|\PHPUnit\Framework\MockObject\MockObject */ protected $configFactory; /** * The config manager. * - * @var \Drupal\Core\Config\ConfigManagerInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Drupal\Core\Config\ConfigManagerInterface|\PHPUnit\Framework\MockObject\MockObject */ protected $configManager; /** * The module handler. * - * @var \Drupal\Core\Extension\ModuleHandlerInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Drupal\Core\Extension\ModuleHandlerInterface|\PHPUnit\Framework\MockObject\MockObject */ protected $moduleHandler; /** * The extension. * - * @var \Drupal\Core\Extension\ModuleHandlerInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Drupal\Core\Extension\ModuleHandlerInterface|\PHPUnit\Framework\MockObject\MockObject */ protected $configReverter; /** * The module extension list mock. * - * @var \Drupal\Core\Extension\ModuleHandlerInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Drupal\Core\Extension\ModuleHandlerInterface|\PHPUnit\Framework\MockObject\MockObject */ protected $moduleExtensionList; /** * {@inheritdoc} */ - public function setUp() { + public function setUp(): void { parent::setUp(); $container = new ContainerBuilder();