Verified Commit 87ae5711 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3423523 by phenaproxima, narendraR, Wim Leers: Test that recipe runner...

Issue #3423523 by phenaproxima, narendraR, Wim Leers: Test that recipe runner fails and rolls back if a recipe tries to use a non-existent config action

(cherry picked from commit f4b42298b1e4f50e70d388a5f6af7567fbf0b735)
parent 052e55f4
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -89,7 +89,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
      $io->success(sprintf('%s applied successfully', $recipe->name));
      return 0;
    }
    catch (InvalidConfigException $e) {
    catch (\Throwable $e) {
      $this->rollBackToCheckpoint($backup_checkpoint);
      throw $e;
    }
+24 −0
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@

namespace Drupal\KernelTests\Core\Recipe;

use Drupal\Component\Plugin\Exception\PluginNotFoundException;
use Drupal\Core\Recipe\Recipe;
use Drupal\Core\Recipe\RecipePreExistingConfigException;
use Drupal\Core\Recipe\RecipeRunner;
@@ -193,4 +194,27 @@ public function testConfigActionsPreExistingConfig() :void {
    $this->assertSame('not bar', $this->config('config_test.system')->get('foo'));
  }

  public function testInvalidConfigAction() :void {
    $recipe_data = <<<YAML
name: Invalid config action
install:
  - config_test
config:
  actions:
    config_test.dynamic.recipe:
      ensure_exists:
        label: 'Created by recipe'
      setBody: 'Description set by recipe'
YAML;

    $dir = uniqid('public://');
    mkdir($dir);
    file_put_contents($dir . '/recipe.yml', $recipe_data);

    $recipe = Recipe::createFromDirectory($dir);
    $this->expectException(PluginNotFoundException::class);
    $this->expectExceptionMessage('The "setBody" plugin does not exist.');
    RecipeRunner::processRecipe($recipe);
  }

}
+0 −13
Original line number Diff line number Diff line
@@ -291,19 +291,6 @@ public static function providerRecipeValidation(): iterable {
        ],
      ],
    ];
    // @todo Uncomment this in https://drupal.org/i/3423523.
    // @codingStandardsIgnoreStart
//     yield 'non-existent config action' => [
//       <<<YAML
//name: Non-existent config action
//config:
//   actions:
//     user.role.anonymous:
//       some_non_existent_action: '*'
//YAML,
//       [],
//     ];
     // @codingStandardsIgnoreEnd
  }

  /**