Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Entity & Field Plugins #157

Closed
wants to merge 12 commits into from
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
*.tgz
*.phar
composer.lock
phpunit.xml
reports
vendor
drush
web
48 changes: 40 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,56 @@
language: php

php:
- 5.5
- 5.6
- 7.0
- 7.1
- 7.2
- hhvm

env:
global:
- PATH=$PATH:/home/travis/.composer/vendor/bin
matrix:
- TEST=syntax DRUPAL=0
- TEST=unit DRUPAL=0
- TEST=kernel DRUPAL=8
- TEST=behat DRUPAL=7
- TEST=behat DRUPAL=8

matrix:
allow_failures:
# This is broken at this time due to a phpspec issue.
# @see https://github.com/jhedstrom/DrupalDriver/issues/172
- php: hhvm
include:
- php: 5.5
env: TEST=syntax DRUPAL=0
- php: 5.5
env: TEST=unit DRUPAL=0
- php: 5.5
env: TEST=behat DRUPAL=6
allow_failures:
# Behat tests are not necessarily commit blocking for the driver.
- env: TEST=behat DRUPAL=6
- env: TEST=behat DRUPAL=7
- env: TEST=behat DRUPAL=8

install:
- composer install
- composer self-update
# This project (drupal/drupal-driver) requires drupal/drupal-extension, but drupal-extension:dev-master
# requires drupal-driver:dev-master. This causes composer installation to fail when travis tests branches
# (including forks) other than master. COMPOSER_ROOT_VERSION solves this by always treating the root project
# as being drupal-driver/dev-master, whatever the branch actually is.
- COMPOSER_ROOT_VERSION=dev-master composer install
- if [[ ${TRAVIS_PHP_VERSION:0:3} == "7.2" ]]; then COMPOSER_ROOT_VERSION=dev-master composer update phpunit/phpunit --with-dependencies; fi

before_script:
- if [[ "${DRUPAL}" == "6" || "${DRUPAL}" == "7" ]]; then composer install-D6orD7; fi
- if [[ "${DRUPAL}" == "8" ]]; then composer install-D8; fi
- if [[ "${TEST}" == "behat" ]]; then drush runserver :8888 --yes --root=${PWD}/web > ~/debug.txt 2>&1 && sleep 4s; fi &
# DriverPluginManagers have a temporary dependence on D8 core, so unit and syntax tests require it for now.
- if [[ "${TEST}" == "syntax" || "${TEST}" == "unit" ]]; then COMPOSER_ROOT_VERSION=dev-master composer require drupal/core:^8.5 symfony/dependency-injection:3.4.11 symfony/translation:3.4.11 symfony/console:3.4.11; fi

script:
- composer test
- composer test-${TEST}

after_failure:
- cat ~/debug.txt

# Enable Travis containers.
sudo: false
80 changes: 80 additions & 0 deletions behat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
default:
autoload: %paths.base%/vendor/drupal/drupal-extension/features/bootstrap/
suites:
default:
paths:
- %paths.base%/vendor/drupal/drupal-extension/features
extensions:
Drupal\MinkExtension:
goutte: ~
Drupal\DrupalExtension:
api_driver: "drupal"
drupal:
# Change this to the absolute path to Drupal install.
drupal_root: "web"
region_map:
content: "#content"
footer: "#footer"
navigation: "#nav-header"
left header: "#header-left"
right header: "#header-right"
right sidebar: "#aside-region"
left sidebar: "#sidebar-first"
content: "#content"
selectors:
message_selector: '.messages'
error_message_selector: '.messages.error'
success_message_selector: '.messages.status'
warning_message_selector: '.messages.warning'

# Testing D6 using API driver. Assumes a standard Drupal 6 install.
drupal6:
suites:
default:
contexts:
- FeatureContext
- Drupal\DrupalExtension\Context\DrupalContext
- Drupal\DrupalExtension\Context\MinkContext
- Drupal\DrupalExtension\Context\MarkupContext
filters:
tags: "@d6&&~@javascript"
extensions:
Behat\MinkExtension:
base_url: http://127.0.0.1:8888

# Testing D7 using API driver. Assumes a standard Drupal 7 install.
drupal7:
suites:
default:
contexts:
- FeatureContext
- Drupal\DrupalExtension\Context\DrupalContext
- Drupal\DrupalExtension\Context\MinkContext
- Drupal\DrupalExtension\Context\MarkupContext
filters:
tags: "@d7&&~@javascript"
extensions:
Behat\MinkExtension:
base_url: http://127.0.0.1:8888

# Testing D8 using API driver. Assumes a standard Drupal 8 install.
drupal8:
suites:
default:
contexts:
- FeatureContext
- Drupal\DrupalExtension\Context\ConfigContext
- Drupal\DrupalExtension\Context\DrupalContext
- Drupal\DrupalExtension\Context\MinkContext
- Drupal\DrupalExtension\Context\MarkupContext
- Drupal\DrupalExtension\Context\MessageContext
- Drupal\DrupalExtension\Context\MailContext
- Drupal\DrupalExtension\Context\RandomContext
filters:
tags: "@d8&&~@d8wip&&~@javascript"
extensions:
Behat\MinkExtension:
base_url: http://127.0.0.1:8888
Drupal\DrupalExtension:
selectors:
error_message_selector: '.messages--error'
53 changes: 46 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,74 @@
"php": ">=5.5.9",
"symfony/process": "~2.5|~3.0",
"symfony/dependency-injection": "~2.6|~3.0",
"drupal/core-utility": "^8.4"
"drupal/core-utility": "^8.4",
"drupal/core-plugin": "^8.0"
},
"require-dev": {
"drupal/coder": "~8.2.0",
"phpspec/phpspec": "~2.0 || ~4.0",
"phpunit/phpunit": "~4.0",
"mockery/mockery": "0.9.4",
"drush-ops/behat-drush-endpoint": "*",
"jakub-onderka/php-parallel-lint": "^0.9.2"
"jakub-onderka/php-parallel-lint": "^0.9.2",
"mikey179/vfsStream": "^1.2",
"composer/installers": "^1.5",
"drupal-composer/drupal-scaffold": "^2.4",
"drupal/drupal-extension": "dev-master"
},
"scripts": {
"test": [
"test-syntax": [
"composer validate --no-interaction",
"parallel-lint src spec tests",
"phpunit --coverage-html=reports/coverage",
"phpunit --testsuite Unit --coverage-html=reports/coverage",
"phpspec run -f pretty --no-interaction",
"phpcs --standard=./phpcs-ruleset.xml ."

],
"test-unit": [
"phpunit --testsuite Unit --coverage-html=reports/coverage"
],
"test-kernel": [
"phpunit --testsuite KernelD${DRUPAL} --bootstrap web/core/tests/bootstrap.php"
],
"test-behat": [
"behat -fprogress --profile=drupal${DRUPAL}"
],
"install-D8": [
"COMPOSER_ROOT_VERSION=dev-master composer require drupal/core:^8.5 symfony/dependency-injection:3.4.11 symfony/translation:3.4.11 symfony/console:3.4.11",
"composer global require drush/drush:~9.0",
"mkdir web/modules web/profiles web/themes",
"drush --yes site-install standard --db-url=mysql://travis:@127.0.0.1/drupal",
"cp -r vendor/drupal/drupal-extension/fixtures/drupal8/modules/behat_test web/modules",
"drush --yes en behat_test",
"drush --yes pmu page_cache",
"drush cr"
],
"install-D6orD7": [
"composer global require drush/drush:~8.0",
"drush dl --quiet --yes drupal-${DRUPAL}.x --all --drupal-project-rename=web",
"drush --yes --root=${PWD}/web site-install --db-url=mysql://travis:@127.0.0.1/drupal",
"cp -r vendor/drupal/drupal-extension/fixtures/drupal${DRUPAL}/modules/behat_test web/sites/all/modules",
"drush en behat_test --yes --root=${PWD}/web",
"if [[ '${DRUPAL}' == '7' ]]; then drush cc drush && drush help behat --root=${PWD}/web && drush --yes fr behat_test --root=${PWD}/web; fi",
"drush cc all --root=${PWD}/web"
]
},
"autoload": {
"psr-0": {
"Drupal\\Driver": "src/",
"Drupal\\Tests\\Driver" : "tests/"
"Drupal\\Driver\\": "src/",
"Drupal\\Tests\\Driver\\" : "tests/",
"Drupal\\KernelTests\\" : "web/core/tests/Drupal/KernelTests"
}
},
"config": {
"process-timeout":0
},
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
},
"installer-paths": {
"web/core": ["type:drupal-core"]
}
}
}
1 change: 1 addition & 0 deletions phpcs-ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<exclude-pattern>*/reports/*</exclude-pattern>
<exclude-pattern>*/spec/*</exclude-pattern>
<exclude-pattern>*/vendor/*</exclude-pattern>
<exclude-pattern>*/web/*</exclude-pattern>
<exclude-pattern>*/CHANGELOG.md</exclude-pattern>
<exclude-pattern>*/README.md</exclude-pattern>

Expand Down
13 changes: 11 additions & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit colors="true" bootstrap="vendor/autoload.php">
<php>
<!-- Example SIMPLETEST_BASE_URL value: http://localhost -->
<env name="SIMPLETEST_BASE_URL" value="http://127.0.0.1:8888"/>
<!-- Example SIMPLETEST_DB value: mysql://drupal:database@localhost/databasename#table_prefix -->
<env name="SIMPLETEST_DB" value="mysql://travis:@127.0.0.1/drupal"/>
</php>
<testsuites>
<testsuite name="Drupal Driver test suite">
<directory>./tests/Drupal/</directory>
<testsuite name="KernelD8">
<directory>./tests/Drupal/Tests/Driver/Kernel/Drupal8/</directory>
</testsuite>
<testsuite name="Unit">
<directory>./tests/Drupal/Tests/Driver/Unit/</directory>
</testsuite>
</testsuites>

Expand Down
63 changes: 63 additions & 0 deletions src/Drupal/Driver/Annotation/DriverEntity.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php

namespace Drupal\Driver\Annotation;

use Drupal\Component\Annotation\Plugin;

/**
* Defines a Driver entity plugin annotation object.
*
* @see \Drupal\Driver\Plugin\DriverEntityPluginManager
* @see plugin_api
*
* @Annotation
*/
class DriverEntity extends Plugin {

/**
* The plugin id.
*
* @var string
*/
public $id;

/**
* The priority to give to this plugin.
*
* @var int
*/
public $weight = 0;

/**
* The Drupal major version being driven.
*
* @var int
*/
public $version;

/**
* The machines names of the entity types the plugin targets.
*
* @var array
*/
public $entityTypes;

/**
* The machine names of the entity bundles the plugin targets.
*
* @var array
*/
public $entityBundles;

/**
* The machine names of the fields this entity might be identified by.
*
* Typically an entity is identified in BDD by its label, but some Drupal
* entities (e.g. user) don't declare a label, or could usefully be identified
* to in other ways (e.g. for a user, either name or email address).
*
* @var array
*/
public $labelKeys;

}
Loading