diff --git a/.circleci/config.yml b/.circleci/config.yml index e04b3fa..3c1167d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,72 +1,41 @@ version: 2 aliases: - - - &build + # Re-usable job to run different types of builds. + - &job-build working_directory: /app docker: - - image: singledigital/bay-circle:latest - environment: &environment - COMPOSER_ALLOW_SUPERUSER: 1 - COMPOSE_PROJECT_NAME: mysite - COMPOSE_FILE: docker-compose.yml - INSTALL_SUGGEST: 0 - BEHAT_PROFILE: "" + - image: &builder-image integratedexperts/ci-builder + environment: + INSTALL_NEW_SITE: 1 + LAGOON_ENVIRONMENT_TYPE: ci steps: - attach_workspace: at: /workspace - checkout + # Init environment for development. + - run: if [ -f "./dev-init.sh" ] && [ ! "$DEV_TOOLS" ]; then ./dev-init.sh; fi - setup_remote_docker: docker_layer_caching: true - version: 17.06.0-ce - - run: - name: Composer validate - # @dev - command: composer validate --ansi --strict --no-check-all - - run: - name: Start containers - command: | - printenv - echo "COMPOSE_FILE=$COMPOSE_FILE" >> .env.local - echo "BEHAT_PROFILE=$BEHAT_PROFILE" >> .env.local - make docker-start - - run: - name: Copy files into container - command: docker cp -L /app/. $(docker-compose ps -q cli):/app/ - - run: - name: Install dev dependencies - command: make install - - run: - name: Lint code - command: make lint - - run: - name: Prepare test fixtures - command: make install-site - - run: - name: Enable current module and dependencies - command: make install-module - - run: - name: Run tests - command: | - make test-behat || make test-behat -- --rerun + - run: .circleci/build.sh + - run: .circleci/test.sh - run: name: Copy artifacts - command: | - mkdir -p /tmp/artifacts/behat - docker cp $(docker-compose ps -q cli):/app/screenshots /tmp/artifacts/behat + command: .circleci/test-artifacts.sh when: always - store_artifacts: path: /tmp/artifacts jobs: build: - <<: *build + <<: *job-build build_suggest: - <<: *build + <<: *job-build docker: - - image: singledigital/bay-circle:latest + - image: *builder-image environment: - <<: *environment + INSTALL_NEW_SITE: 1 + LAGOON_ENVIRONMENT_TYPE: ci INSTALL_SUGGEST: 1 BEHAT_PROFILE: "--profile=suggest" @@ -75,3 +44,4 @@ workflows: main: jobs: - build + - build_suggest diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index 49f7420..0000000 --- a/.dockerignore +++ /dev/null @@ -1,4 +0,0 @@ -vendor -build -.idea -.git diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 5de2bca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,5 +0,0 @@ -[composer.{json,lock}] -indent_size = 4 - -[composer.*.{json,lock}] -indent_size = 4 diff --git a/.env b/.env deleted file mode 100644 index abd1ef4..0000000 --- a/.env +++ /dev/null @@ -1,18 +0,0 @@ -MODULE_NAME=tide_test -COMPOSE_FILE=docker-compose.yml:docker-compose.local.yml -PHP_LINT_TARGETS="." -PHPCS_TARGETS="tide_test.info.yml tests/behat/bootstrap" -COMPOSER_DEV_URL=https://raw.githubusercontent.com/dpc-sdp/tide/master/composer.dev.json - -################################################################################ -# Local overrides. -# -# Copy lines below into "env.local" file and exclude "env.local" file globally. -################################################################################ - -# Uncomment and epcify your GitHub token below (CI already uses this). -# GITHUB_TOKEN= - -# Uncomment below to install suggsted packages. -# INSTALL_SUGGEST=1 - diff --git a/.gitattributes b/.gitattributes index 059212b..17ee2d5 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,12 +1,10 @@ # Ignore files for distribution archives. - .gitattributes export-ignore .gitignore export-ignore .github export-ignore +.circleci export-ignore +.circleci/config.yml export-ignore +.env export-ignore tests export-ignore -circle.yml export-ignore composer.json export-ignore -composer.lock export-ignore -phpcs.xml export-ignore -phpunit.xml export-ignore -xdebug.sh export-ignore +dev-init.sh export-ignore diff --git a/.gitignore b/.gitignore index 17a4757..b1bbca1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,12 @@ -vendor -vendor-local +# To ignore OS temporary files use global .gitignore +# https://help.github.com/articles/ignoring-files/#create-a-global-gitignore + /composer.lock -build +/composer.build.json +/composer.build.lock +/docroot +/dpc-sdp +.env.local +docker-compose.override.yml screenshots -composer.dev.json -composer.build.json -composer.build.lock +vendor diff --git a/Makefile b/Makefile deleted file mode 100644 index 040a8de..0000000 --- a/Makefile +++ /dev/null @@ -1,214 +0,0 @@ -## -# Build project dependncies. -# -# Usage: -# make -# -# make help - show a list of available targets. -# make build - build project -# -include .env --include .env.local - -.DEFAULT_GOAL := help -.PHONY: build clean clean-full docker-cli docker-destroy docker-restart docker-start docker-stop help install install-site install-module lint rebuild rebuild-full test-behat update-fixtures -.EXPORT_ALL_VARIABLES: ; - -## Build project. -build: - $(call title,Building project) - $(call exec,$(MAKE) docker-start) - $(call exec,$(MAKE) install) - $(call exec,$(MAKE) install-site) - $(call exec,$(MAKE) install-module) - @echo '' - $(call title,Build complete) - -## Remove dependencies. -clean: - $(call title,Removing dependencies) - $(call exec,[ -d $(WEBROOT)/sites/default ] && chmod -Rf 777 $(WEBROOT)/sites/default||true) - $(call exec,git ls-files --directory --other -i --exclude-from=.gitignore | xargs rm -Rf) - -## Remove dependencies and Docker images. -clean-full: docker-stop docker-destroy clean - -## Destroy Docker containers. -docker-destroy: - $(call title,Destroying Dockert containers) - $(call exec,docker-compose down) - -## Re-start Docker containers. -docker-restart: - $(call title,Restarting Docker containers) - $(call exec,docker-compose restart) - -## Start Docker containers. -docker-start: - $(call title,Starting Docker containers) - $(call exec,COMPOSE_CONVERT_WINDOWS_PATHS=1 docker-compose up -d $(filter-out $@,$(MAKECMDGOALS))) - $(call exec,if docker-compose logs |grep "\[Error\]"; then exit 1; fi) - @docker ps -a --filter name=^/$(COMPOSE_PROJECT_NAME)_ - -## Stop Docker containers. -docker-stop: - $(call title,Stopping Docker containers) - $(call exec,docker-compose stop $(filter-out $@,$(MAKECMDGOALS))) - -## Run Drush command. -drush: - $(call title,Executing Drush command inside CLI container) - $(call exec,docker-compose exec cli drush -r $(APP)/$(WEBROOT) $(filter-out $@,$(MAKECMDGOALS))) - -## Display this help message. -help: - @echo '' - @echo 'Usage:' - @echo ' ${YELLOW}make${RESET} ${GREEN}${RESET}' - @echo '' - @echo 'Targets:' - @awk '/^[a-zA-Z\-0-9][a-zA-Z\-\_0-9]+:/ { \ - helpMessage = match(lastLine, /^## (.*)/); \ - if (helpMessage) { \ - helpCommand = substr($$1, 0, index($$1, ":")-1); \ - helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \ - printf " ${YELLOW}%-$(HELP_TARGET_WIDTH)s${RESET} ${GREEN}%s${RESET}\n", helpCommand, helpMessage; \ - } \ - } \ - { lastLine = $$0 }' $(MAKEFILE_LIST) - -## Install dependencies -install: - $(call title,Installing dependencies) - $(call exec,docker-compose exec cli apk add --update make jq) - # Download development config from Tide profile repository. - $(call exec,docker-compose exec cli bash -c "curl -L --header 'Accept: application/vnd.github.v3.raw' --header 'User-Agent: dpc-sdp/tide curl v7.47.0' $(COMPOSER_DEV_URL) > $(APP)/composer.dev.json") - # Merge module's and development composer configs. - $(call exec,docker-compose exec cli bash -c "jq --indent 4 -M -s '.[0] * .[1]' $(APP)/composer.json $(APP)/composer.dev.json > $(COMPOSER_BUILD)") - $(call exec,docker-compose exec cli bash -c "COMPOSER=$(COMPOSER_BUILD) composer install -n --ansi --prefer-dist --no-suggest") - -## Install current module. -install-module: - $(call title,Installing current module and dependencies) - # If running with suggested modules, requre them first. - $(call exec,docker-compose exec cli bash -c "if [ "$(INSTALL_SUGGEST)" = "1" ] ; then cat $(COMPOSER_BUILD) | jq -r 'select(.suggest != null) | .suggest | keys[]' | xargs -i composer require {}; fi") - # Copy module code into local vendor directory. - $(call exec,docker-compose exec cli rm -Rf $(APP)/vendor-local/$(MODULE_NAME)) - $(call exec,docker-compose exec cli mkdir -p $(APP)/vendor-local/$(MODULE_NAME)) - $(call exec,docker-compose exec cli bash -c "git ls-tree HEAD --name-only|xargs -I '{}' cp -R '{}' $(APP)/vendor-local/$(MODULE_NAME)/") - # Add local module repository. - $(call exec,docker-compose exec cli bash -c "COMPOSER=$(COMPOSER_BUILD) composer config repositories.dpc-sdp/$(MODULE_NAME) path vendor-local/$(MODULE_NAME)") - # Require module from local repository. - $(call exec,docker-compose exec cli bash -c "COMPOSER=$(COMPOSER_BUILD) composer require dpc-sdp/$(MODULE_NAME)") - # If running with suggested modules, install them first. - $(call exec,docker-compose exec cli bash -c "if [ "$(INSTALL_SUGGEST)" = "1" ] ; then cat $(COMPOSER_BUILD) | jq -r 'select(.suggest != null) | .suggest | keys[]' | sed 's/dpc-sdp\///' | xargs -i drush -r $(APP)/$(WEBROOT) en -y {}; fi") - # Enable current module. - $(call exec,docker-compose exec cli drush -r $(APP)/$(WEBROOT) en -y $(MODULE_NAME)) - -## Install site. -install-site: - $(call title,Installing a site) - $(call exec,docker-compose exec cli drush -r $(APP)/$(WEBROOT) si testing -y --db-url=mysql://drupal:drupal@$(MYSQL_HOST)/drupal --account-name=admin --account-pass=admin install_configure_form.enable_update_status_module=NULL install_configure_form.enable_update_status_emails=NULL) - $(call exec,docker-compose exec cli bash -c "COMPOSER=$(COMPOSER_BUILD) composer --working-dir=$(APP)/$(BUILD) drupal-post-install") - -## Lint code. -lint: - $(call title,Linting code) - $(call exec,docker-compose exec cli vendor/bin/parallel-lint --exclude vendor $(PHP_LINT_EXCLUDES) -e $(PHP_LINT_EXTENSIONS) $(PHP_LINT_TARGETS)) - $(call exec,docker-compose exec cli vendor/bin/phpcs $(PHPCS_TARGETS)) - -update-fixtures: - $(call title,Updating fixture files for Drupal $(DRUPAL_VERSION)) - $(call exec,rsync -av --delete --no-progress --exclude-from=$(BUILD)/.rsync-exclude $(BUILD)/ $(FIXTURES)/d$(DRUPAL_VERSION)/) - -## Re-build project dependencies. -rebuild: clean build - -## Clean and fully re-build project dependencies. -rebuild-full: clean-full build - -## Run Behat tests. -test-behat: - $(call title,Running behat tests) - $(call exec,docker-compose exec cli vendor/bin/behat --format=progress_fail --strict --colors $(BEHAT_PROFILE) $(filter-out $@,$(MAKECMDGOALS))) - -#------------------------------------------------------------------------------- -# VARIABLES. -#------------------------------------------------------------------------------- -COMPOSE_PROJECT_NAME ?= app - -APP ?= /app -WEBROOT ?= build/docroot -BUILD ?= build -FIXTURES ?= tests/behat/fixtures -URL ?= http://$(MODULE_NAME).docker.amazee.io/ - -DRUPAL_VERSION ?= 8 -MODULES_PATH ?= modules -INSTALL_SUGGEST ?= 0 - -MYSQL_HOST ?= mariadb -MYSQL_PORT ?= 3306 - -PHP_LINT_EXTENSIONS ?= php,inc,module,theme,install -PHP_LINT_TARGETS ?= ./ -PHP_LINT_TARGETS := $(subst $\",,$(PHP_LINT_TARGETS)) -PHP_LINT_EXCLUDES ?= --exclude vendor --exclude node_modules --exclude build -PHP_LINT_EXCLUDES := $(subst $\",,$(PHP_LINT_EXCLUDES)) - -PHPCS_TARGETS := $(subst $\",,$(PHPCS_TARGETS)) - -# Path to a file with additional sanitization commands. -DB_SANITIZE_SQL ?= .dev/sanitize.sql - -# Prefix of the Docker images. -DOCKER_IMAGE_PREFIX ?= amazeeio - -# GitHub token to not be limited by API calls. -GITHUB_TOKEN ?= "" - -# GitHub token to allow access to private repos to download files. -# This is NOT the same token as above! It has a larger security scope and should -# be used with caution. It will be removed once project go open-source. -GITHUB_PRIVATE_TOKEN ?= "" - -# Override composer configuration file with the one used for build. -COMPOSER_BUILD ?= $(APP)/composer.build.json - -# URL of the development Composer configuration file. -COMPOSER_DEV_URL ?= file:///composer.dev.json - -# Width of the target column in help target. -HELP_TARGET_WIDTH = 20 - -# Print verbose messages. -VERBOSE ?= 1 - -# Colors for output text. -GREEN := $(shell tput -Txterm setaf 2) -YELLOW := $(shell tput -Txterm setaf 3) -WHITE := $(shell tput -Txterm setaf 7) -RESET := $(shell tput -Txterm sgr0) - -#------------------------------------------------------------------------------- -# FUNCTIONS. -#------------------------------------------------------------------------------- - -## -# Execute command and display executed command to user. -# -define exec - @printf "$$ ${YELLOW}${subst ",',${1}}${RESET}\n" && $1 -endef - -## -# Display the target title to user. -# -define title - $(if $(VERBOSE),@printf "${GREEN}==> ${1}...${RESET}\n") -endef - -# Pass arguments from CLI to commands. -# @see https://stackoverflow.com/a/6273809/1826109 -%: - @: diff --git a/README.md b/README.md index 422db6b..bd798e0 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,3 @@ composer require dpc-sdp/tide_test # PURPOSE - test content type - other test functionality - -# Caveats - -Tide Test is on the alpha release, use with caution. APIs are likely to change before the stable version, that there will be breaking changes and that we're not supporting it for external production sites at the moment. diff --git a/behat.yml b/behat.yml deleted file mode 100644 index 230c13b..0000000 --- a/behat.yml +++ /dev/null @@ -1,76 +0,0 @@ -default: - autoload: [ %paths.base%/tests/behat/bootstrap ] - gherkin: - filters: - tags: "~@suggest&&~@skipped" - suites: - default: - paths: [ %paths.base%/tests/behat/features ] - contexts: - - FeatureContext - - Drupal\DrupalExtension\Context\MinkContext - - Drupal\DrupalExtension\Context\MarkupContext - - Drupal\DrupalExtension\Context\MessageContext - - IntegratedExperts\BehatScreenshotExtension\Context\ScreenshotContext - - Ubirak\RestApiBehatExtension\RestApiContext - - Ubirak\RestApiBehatExtension\Json\JsonContext - - extensions: - Behat\MinkExtension: - goutte: ~ - base_url: http://nginx:8080 - files_path: %paths.base%/tests/behat/fixtures - browser_name: chrome - selenium2: - wd_host: "http://selenium:4444/wd/hub" - capabilities: { "browser": "chrome", "version": "*", "marionette": true } - javascript_session: selenium2 - # Provides integration with Drupal APIs. - Drupal\DrupalExtension: - blackbox: ~ - api_driver: drupal - drush_driver: drush - drupal: - drupal_root: build/docroot - drush: - root: build/docroot - selectors: - message_selector: '.messages' - error_message_selector: '.messages.error' - success_message_selector: '.messages.status' - warning_message_selector: '.messages.warning' - region_map: - alert: '.region-alert' - header: '.region-header' - header_search: '.region-header-search' - menu: '.region-menu' - breadcrumb: '.region-breadcrumb' - feature: '.region-feature' - above_content: '.region-above-content' - content: '.region-content' - sidebar: '.region-sidebar' - above_footer: '.region-above-footer' - footer_first: '.region-footer-first' - footer_second: '.region-footer-second' - footer_third: '.region-footer-third' - footer_fourth: '.region-footer-fourth' - footer_fifth: '.region-footer-fifth' - footer_sixth: '.region-footer-sixth' - splash: '.region-splash' - disabled: '.region-disabled' - # Allows to capture HTML and JPG screenshots (based on the driver used). - IntegratedExperts\BehatScreenshotExtension: - dir: %paths.base%/screenshots - fail: true - purge: false - # Show explicit fail information and continue the test run. - IntegratedExperts\BehatFormatProgressFail\FormatExtension: ~ - Ubirak\RestApiBehatExtension\Extension: - rest: - base_url: http://nginx:8080 - store_response: true - -suggest: - gherkin: - filters: - tags: "~@nosuggest&&~@skipped" diff --git a/composer.json b/composer.json index 24e0e52..94d1f20 100644 --- a/composer.json +++ b/composer.json @@ -2,24 +2,14 @@ "name": "dpc-sdp/tide_test", "description": "Test content type and related configuration for Tide Drupal 8 distribution", "type": "drupal-module", - "license": "GPL-2.0+", + "license": "GPL-2.0-or-later", "require": { - "drupal/smart_trim": "^1.1", - "dpc-sdp/tide_core": "@dev" + "dpc-sdp/tide_core": "^1.0" }, "repositories": { "drupal": { "type": "composer", "url": "https://packages.drupal.org/8" } - }, - "minimum-stability": "dev", - "prefer-stable": true, - "config": { - "platform": { - "php": "7.1" - }, - "process-timeout": 0, - "sort-packages": true } } diff --git a/dev-init.sh b/dev-init.sh new file mode 100755 index 0000000..1729349 --- /dev/null +++ b/dev-init.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +## +# Install development files from the centralised location. +# +# Files already committed within current repository will not be overridden. +## +# To override any files coming from Dev Tools to persist in the current +# repository, modify `.git/info/exclude` file and commit them. +# +# Usage: +# . dev-init.sh +# +# To update all files, including committed: +# ALLOW_OVERRIDE=1 . dev-init.sh +# + +# Development only: uncomment and set the commit value to fetch Dev Tools at +# specific commit. +#export GH_COMMIT=COMMIT_SHA + +curl https://raw.githubusercontent.com/dpc-sdp/dev-tools/master/install | bash diff --git a/docker-compose.local.yml b/docker-compose.local.yml deleted file mode 100644 index 2543b29..0000000 --- a/docker-compose.local.yml +++ /dev/null @@ -1,29 +0,0 @@ -version: '2' -services: - cli: - volumes_from: - - container:amazeeio-ssh-agent - environment: - - XDEBUG_ENABLE=true - volumes: - - .:/app:delegated - php: - environment: - - XDEBUG_ENABLE=true - volumes: - - .:/app:delegated - nginx: - networks: - - amazeeio-network - environment: - - AMAZEEIO_URL=tide-module.docker.amazee.io - - AMAZEEIO=AMAZEEIO - - AMAZEEIO_HTTP_PORT=8080 - volumes: - - .:/app:delegated - mariadb: - ports: - - 13309:3306 -networks: - amazeeio-network: - external: true diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index a4534ca..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,33 +0,0 @@ -version: '2' -services: - cli: - image: amazeeio/php:7.1-cli-drupal - environment: - - WEBROOT=build/docroot - - COMPOSER=composer.build.json - volumes: - - .:/app - php: - image: amazeeio/php:7.1-fpm - environment: - - WEBROOT=build/docroot - volumes: - - .:/app - depends_on: - - cli - nginx: - image: amazeeio/nginx-drupal - environment: - - WEBROOT=build/docroot - volumes: - - .:/app - networks: - - default - depends_on: - - cli - expose: - - "8080" - mariadb: - image: amazeeio/centos7-mariadb10-drupal - selenium: - image: selenium/standalone-chrome diff --git a/phpcs.xml b/phpcs.xml deleted file mode 100644 index 59ec8c1..0000000 --- a/phpcs.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - PHPCS Standard for Tide modules. - - - - - - - - - - - - circle\.yml - \.circle\/config\.yml - - - - warning - - - - * - - - - src/* - tests/behat/bootstrap/* - - - - * - - diff --git a/scripts/composer/ScriptHandler.php b/scripts/composer/ScriptHandler.php index a75e4d3..cb4a53c 100644 --- a/scripts/composer/ScriptHandler.php +++ b/scripts/composer/ScriptHandler.php @@ -1,10 +1,5 @@ exists($drupalRoot . '/'. $dir)) { - $fs->mkdir($drupalRoot . '/'. $dir); - $fs->touch($drupalRoot . '/'. $dir . '/.gitkeep'); + if (!$fs->exists($drupalRoot . '/' . $dir)) { + $fs->mkdir($drupalRoot . '/' . $dir); + $fs->touch($drupalRoot . '/' . $dir . '/.gitkeep'); } } - // Prepare the settings file for installation + // Prepare the settings file for installation. if (!$fs->exists($drupalRoot . '/sites/default/settings.php') and $fs->exists($drupalRoot . '/sites/default/default.settings.php')) { $fs->copy($drupalRoot . '/sites/default/default.settings.php', $drupalRoot . '/sites/default/settings.php'); require_once $drupalRoot . '/core/includes/bootstrap.inc'; require_once $drupalRoot . '/core/includes/install.inc'; $settings['config_directories'] = [ CONFIG_SYNC_DIRECTORY => (object) [ - 'value' => Path::makeRelative($drupalFinder->getComposerRoot() . '/config/sync', $drupalRoot), + 'value' => Path::makeRelative($drupalFinder->getComposerRoot() . '/config/default', $drupalRoot), 'required' => TRUE, ], ]; drupal_rewrite_settings($settings, $drupalRoot . '/sites/default/settings.php'); - $fs->chmod($drupalRoot . '/sites/default/settings.php', 0666); - $event->getIO()->write("Create a sites/default/settings.php file with chmod 0666"); + $fs->chmod($drupalRoot . '/sites/default/settings.php', 0644); + $event->getIO()->write("Create a sites/default/settings.php file with chmod 0644"); } - // Create the files directory with chmod 0777 + // Create the files directory with chmod 0777. if (!$fs->exists($drupalRoot . '/sites/default/files')) { $oldmask = umask(0); $fs->mkdir($drupalRoot . '/sites/default/files', 0777); diff --git a/tests/behat/bootstrap/FeatureContext.php b/tests/behat/bootstrap/FeatureContext.php deleted file mode 100644 index e8a9dd5..0000000 --- a/tests/behat/bootstrap/FeatureContext.php +++ /dev/null @@ -1,33 +0,0 @@ -getSession()->getCurrentUrl(); - $current_path = parse_url($current_path, PHP_URL_PATH); - $current_path = ltrim($current_path, '/'); - $current_path = $current_path == '' ? '' : $current_path; - - if ($current_path != $path) { - throw new \Exception(sprintf('Current path is "%s", but expected is "%s"', $current_path, $path)); - } - } - - /** - * Creates and authenticates a user with the given role(s). - * - * @Given I am logged in as a user with the :role role(s) - * @Given I am logged in as a/an :role - */ - public function assertAuthenticatedByRole($role) { - // Override parent assertion to allow using 'anonymous user' role without - // actually creating a user with role. By default, - // assertAuthenticatedByRole() will create a user with 'authenticated role' - // even if 'anonymous user' role is provided. - if ($role == 'anonymous user') { - if (!empty($this->loggedInUser)) { - $this->logout(); - } - } - else { - parent::assertAuthenticatedByRole($role); - } - } - - /** - * @Then I wait for :sec second(s) - */ - public function waitForSeconds($sec) { - sleep($sec); - } - - /** - * @Given no :type content type - */ - public function removeContentType($type) { - $content_type_entity = \Drupal::entityManager()->getStorage('node_type')->load($type); - if ($content_type_entity) { - $content_type_entity->delete(); - } - } - -} diff --git a/tide_test.install b/tide_test.install index 626382d..07cbde5 100644 --- a/tide_test.install +++ b/tide_test.install @@ -8,7 +8,6 @@ use Drupal\user\Entity\Role; use Drupal\workflows\Entity\Workflow; - /** * Implements hook_install(). * @@ -32,14 +31,21 @@ function tide_test_install() { } } - // Set the default and admin theme to Seven. It is important to set themes - // only to enabled ones (and we are enabling Seven in profile dependencies). - \Drupal::configFactory() - ->getEditable('system.theme') - ->set('default', 'seven') - ->set('admin', 'seven') - ->save(TRUE); + // Enable Seven theme if current theme is not set or Classy (usually + // happens when using minimal or testing profile). + $default_theme = \Drupal::service('theme_handler')->getDefault(); + print 'Current theme is ' . $default_theme; + if (is_null($default_theme) || $default_theme == 'classy') { + \Drupal::service('theme_installer')->install(['seven']); + + \Drupal::configFactory() + ->getEditable('system.theme') + ->set('default', 'seven') + ->set('admin', 'seven') + ->save(TRUE); + } } + /** * Implements hook_uninstall(). */