Skip to content
Snippets Groups Projects
Commit 073f94f1 authored by Adam G-H's avatar Adam G-H
Browse files

Test against Lightning Core 4.x (Drupal core 8.7.x).

parent 03e33add
Branches
Tags
No related merge requests found
...@@ -6,7 +6,7 @@ cache: ...@@ -6,7 +6,7 @@ cache:
directories: directories:
- "$HOME/.composer/cache" - "$HOME/.composer/cache"
- "$HOME/.drush/cache" - "$HOME/.drush/cache"
- "$HOME/.npm"
php: php:
- 7.1 - 7.1
...@@ -26,38 +26,33 @@ addons: ...@@ -26,38 +26,33 @@ addons:
chrome: stable chrome: stable
before_install: before_install:
# Tweak PHP configuration.
- phpenv config-add ./tests/travis.php.ini
- phpenv rehash
- composer self-update - composer self-update
- composer --version - composer --version
- google-chrome-stable --version - google-chrome-stable --version
- export ORCA=$TRAVIS_BUILD_DIR/../orca - export ORCA=$TRAVIS_BUILD_DIR/../orca
- export ORCA_FIXTURE=$ORCA-build - export ORCA_FIXTURE=$ORCA-build
- export ORCA_SUT=drupal/lightning_workflow - export ORCA_SUT_NAME=drupal/lightning_workflow
- export ORCA_SUT_BRANCH=8.x-3.x
- export ORCA_PACKAGES_CONFIG_ALTER=../lightning-workflow/tests/packages.yml
- export PATH="$HOME/.composer/vendor/bin:$PATH" - export PATH="$HOME/.composer/vendor/bin:$PATH"
- export PATH="$ORCA/bin:$PATH" - export PATH="$ORCA/bin:$PATH"
- export PATH="$ORCA/vendor/bin:$PATH" - export PATH="$ORCA/vendor/bin:$PATH"
- export PATH="$ORCA_FIXTURE/vendor/bin:$PATH" - export PATH="$ORCA_FIXTURE/vendor/bin:$PATH"
# Add the ORCA repository. # Install ORCA and prepare the environment.
- composer config --global repositories.orca vcs "https://github.com/acquia/orca" - git clone --branch develop --depth 1 https://github.com/acquia/orca.git $ORCA
# Use a personal access token to authenticate with GitHub, to avoid being - $ORCA/bin/travis/before_install.sh
# rate-limited. The token is configured in the Travis CI repository settings.
- composer config --global github-oauth.github.com $GITHUB_API_TOKEN
install: install:
- composer create-project --stability dev --no-dev acquia/orca $ORCA - $ORCA/bin/travis/install.sh
- "$ORCA/bin/travis/install 8.x-3.x"
# Run ORCA static analysis tools. # Run ORCA static analysis tools.
- orca static-analysis:run ./ - orca static-analysis:run ./
# Use ORCA to build the code base. # Use ORCA to build the code base.
- orca fixture:init -f --sut $ORCA_SUT $ORCA_FIXTURE_FLAGS - orca fixture:init -f --sut $ORCA_SUT_NAME --core 8.7.x-dev $ORCA_FIXTURE_FLAGS
- # Install dev dependencies. - # Install dev dependencies.
- composer require --dev drupal/inline_entity_form --working-dir $ORCA_FIXTURE - composer require --dev drupal/inline_entity_form --working-dir $ORCA_FIXTURE
...@@ -66,7 +61,7 @@ before_script: ...@@ -66,7 +61,7 @@ before_script:
- $TRAVIS_BUILD_DIR/update.sh $VERSION - $TRAVIS_BUILD_DIR/update.sh $VERSION
script: script:
- orca tests:run --sut $ORCA_SUT $ORCA_TEST_FLAGS - orca tests:run --sut $ORCA_SUT_NAME $ORCA_TEST_FLAGS
after_failure: after_failure:
- cd docroot - cd docroot
......
langcode: en langcode: en
status: true status: true
dependencies:
module:
- content_moderation
- node
- user
id: moderation_history id: moderation_history
label: 'Moderation history' label: 'Moderation history'
module: views module: views
......
...@@ -12,11 +12,13 @@ use Drupal\Core\Entity\EntityPublishedInterface; ...@@ -12,11 +12,13 @@ use Drupal\Core\Entity\EntityPublishedInterface;
use Drupal\Core\Entity\Display\EntityViewDisplayInterface; use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Serialization\Yaml;
use Drupal\Core\Session\AccountInterface; use Drupal\Core\Session\AccountInterface;
use Drupal\lightning_core\Element; use Drupal\lightning_core\Element;
use Drupal\lightning_core\Routing\RouteSubscriber; use Drupal\lightning_core\Routing\RouteSubscriber;
use Drupal\lightning_workflow\Plugin\views\field\NodeBulkForm; use Drupal\lightning_workflow\Plugin\views\field\NodeBulkForm;
use Drupal\node\NodeTypeInterface; use Drupal\node\NodeTypeInterface;
use Drupal\views\Entity\View;
use Drupal\views\ViewEntityInterface; use Drupal\views\ViewEntityInterface;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
use Drupal\workflows\Entity\Workflow; use Drupal\workflows\Entity\Workflow;
...@@ -42,10 +44,25 @@ function lightning_workflow_node_type_insert(NodeTypeInterface $node_type) { ...@@ -42,10 +44,25 @@ function lightning_workflow_node_type_insert(NodeTypeInterface $node_type) {
$plugin = $workflow->getTypePlugin(); $plugin = $workflow->getTypePlugin();
if ($plugin instanceof ContentModerationInterface) { if ($plugin instanceof ContentModerationInterface) {
// We need to rebuild all routes because Content Moderation needs to ensure
// that edit forms load the latest revision.
$plugin->addEntityTypeAndBundle('node', $node_type->id()); $plugin->addEntityTypeAndBundle('node', $node_type->id());
$workflow->save(); $workflow->save();
// The moderation_history view depends on the existence of the
// moderation_state base field, which is only defined once a content type
// has been opted into moderation. Now that's done, so create the
// moderation_history view if it doesn't already exist.
if (Drupal::moduleHandler()->moduleExists('views')) {
$view = View::load('moderation_history');
if (empty($view)) {
$values = file_get_contents(__DIR__ . '/config/dynamic/views.view.moderation_history.yml');
$values = Yaml::decode($values);
View::create($values)->save();
}
}
// We need to rebuild all routes because Content Moderation needs to ensure
// that edit forms load the latest revision, and that the moderation_history
// view's routes are registered if needed.
Drupal::service('router.builder')->rebuild(); Drupal::service('router.builder')->rebuild();
} }
} }
......
...@@ -7,6 +7,7 @@ use Drupal\Core\Entity\EntityTypeInterface; ...@@ -7,6 +7,7 @@ use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Extension\Extension; use Drupal\Core\Extension\Extension;
use Drupal\Core\Field\BaseFieldDefinition; use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\Update\UpdateKernel;
use Drupal\datetime\Plugin\Field\FieldType\DateTimeItemInterface; use Drupal\datetime\Plugin\Field\FieldType\DateTimeItemInterface;
use Drupal\lightning_core\OverrideHelper; use Drupal\lightning_core\OverrideHelper;
use Drupal\lightning_scheduler\Plugin\Field\FieldWidget\ModerationStateWidget; use Drupal\lightning_scheduler\Plugin\Field\FieldWidget\ModerationStateWidget;
...@@ -42,6 +43,13 @@ function lightning_scheduler_system_info_alter(array &$info, Extension $extensio ...@@ -42,6 +43,13 @@ function lightning_scheduler_system_info_alter(array &$info, Extension $extensio
* Implements hook_cron(). * Implements hook_cron().
*/ */
function lightning_scheduler_cron() { function lightning_scheduler_cron() {
// Do not execute during database updates. This hook could be invoked if, for
// example, Automated Cron is triggered at the end of one of the many HTTP
// requests that are made during an update.php process.
if (Drupal::service('kernel') instanceof UpdateKernel) {
return;
}
$field_map = Drupal::service('entity_field.manager')->getFieldMap(); $field_map = Drupal::service('entity_field.manager')->getFieldMap();
/** @var \Drupal\lightning_scheduler\TransitionManager $transition_manager */ /** @var \Drupal\lightning_scheduler\TransitionManager $transition_manager */
...@@ -76,6 +84,7 @@ function lightning_scheduler_cron() { ...@@ -76,6 +84,7 @@ function lightning_scheduler_cron() {
*/ */
function lightning_scheduler_entity_base_field_info(EntityTypeInterface $entity_type) { function lightning_scheduler_entity_base_field_info(EntityTypeInterface $entity_type) {
$fields = []; $fields = [];
/** @var \Drupal\content_moderation\ModerationInformationInterface $moderation_info */
$moderation_info = Drupal::service('content_moderation.moderation_information'); $moderation_info = Drupal::service('content_moderation.moderation_information');
$migrations = Drupal::service('lightning_scheduler.migrator')->getMigrations(); $migrations = Drupal::service('lightning_scheduler.migrator')->getMigrations();
......
No preview for this file type
...@@ -16,16 +16,6 @@ abstract class MigrationTestBase extends UpdatePathTestBase { ...@@ -16,16 +16,6 @@ abstract class MigrationTestBase extends UpdatePathTestBase {
} }
public function test() { public function test() {
// Forcibly uninstall Lightning Dev. It is mentioned in the fixture, but not
// physically present in ORCA fixtures.
$this->config('core.extension')
->clear('module.lightning_dev')
->save();
$this->container
->get('keyvalue')
->get('system.schema')
->deleteMultiple(['lightning_dev']);
$this->runUpdates(); $this->runUpdates();
$migrations = $this->container->get('state')->get('lightning_scheduler.migrations'); $migrations = $this->container->get('state')->get('lightning_scheduler.migrations');
......
drupal/lightning_api:
version_dev: 4.x-dev
drupal/lightning_core:
version_dev: 4.x-dev
...@@ -21,22 +21,9 @@ class ModerationHistoryTest extends BrowserTestBase { ...@@ -21,22 +21,9 @@ class ModerationHistoryTest extends BrowserTestBase {
'views', 'views',
]; ];
/**
* The content type created during the test.
*
* @var \Drupal\node\NodeTypeInterface
*/
private $nodeType;
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->nodeType = $this->createContentType();
}
public function testModerationHistory() { public function testModerationHistory() {
$node_type = $this->createContentType();
$user_permissions = [ $user_permissions = [
'administer nodes', 'administer nodes',
'bypass node access', 'bypass node access',
...@@ -48,10 +35,12 @@ class ModerationHistoryTest extends BrowserTestBase { ...@@ -48,10 +35,12 @@ class ModerationHistoryTest extends BrowserTestBase {
$user_a = $this->createUser($user_permissions, 'userA'); $user_a = $this->createUser($user_permissions, 'userA');
$user_b = $this->createUser($user_permissions, 'userB'); $user_b = $this->createUser($user_permissions, 'userB');
$this->enableModeration(); // Enable moderation for the content type.
$node_type->setThirdPartySetting('lightning_workflow', 'workflow', 'editorial');
lightning_workflow_node_type_insert($node_type);
$node = $this->createNode([ $node = $this->createNode([
'type' => $this->nodeType->id(), 'type' => $node_type->id(),
'title' => 'Foo', 'title' => 'Foo',
'moderation_state' => 'draft', 'moderation_state' => 'draft',
]); ]);
...@@ -71,16 +60,6 @@ class ModerationHistoryTest extends BrowserTestBase { ...@@ -71,16 +60,6 @@ class ModerationHistoryTest extends BrowserTestBase {
$this->assertSession()->pageTextContainsOnce('Set to published on ' . $date_formatter->format($timestamp_b, 'long') . ' by ' . $user_b->getUsername()); $this->assertSession()->pageTextContainsOnce('Set to published on ' . $date_formatter->format($timestamp_b, 'long') . ' by ' . $user_b->getUsername());
} }
/**
* Enables moderation for the content type under test.
*/
private function enableModeration() {
$this->nodeType->setThirdPartySetting('lightning_workflow', 'workflow', 'editorial');
\Drupal::moduleHandler()
->invoke('lightning_workflow', 'node_type_insert', [ $this->nodeType ]);
}
/** /**
* Creates a new revision of the given $node. * Creates a new revision of the given $node.
* *
......
; PHP configuration for Travis CI.
; This file must be named travis.php.ini in order to override travis.ini, which
; is created by Travis CI.
max_execution_time = 120
sendmail_path = /bin/true
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment