summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjibran2018-09-22 04:56:20 (GMT)
committerJibran Ijaz2018-09-22 04:56:20 (GMT)
commit756520b8a11c92b081665ec46ee1b1cd82598eb5 (patch)
tree075493c3924feeb48a35d0c0a23b75d6338eac7b
parent21b8871a1c4f5396eac7cd304cb81e91692a4b6d (diff)
Issue #3001640 by jibran: Add drupalci.yml
-rw-r--r--drupalci.yml42
-rw-r--r--phpcs.xml12
-rw-r--r--phpcs.xml.dist287
-rw-r--r--src/DynamicEntityReferenceServiceProvider.php3
-rw-r--r--tests/src/FunctionalJavascript/DynamicEntityReferenceTest.php14
-rw-r--r--tests/src/Kernel/DynamicEntityReferenceFormatterTest.php1
-rw-r--r--tests/src/Kernel/EntityQueryRelationshipTest.php12
7 files changed, 62 insertions, 309 deletions
diff --git a/drupalci.yml b/drupalci.yml
new file mode 100644
index 0000000..5de9c8a
--- /dev/null
+++ b/drupalci.yml
@@ -0,0 +1,42 @@
+# This is the DrupalCI testbot build file for Dynamic Entity Reference.
+# Learn to make one for your own drupal.org project:
+# https://www.drupal.org/drupalorg/docs/drupal-ci/customizing-drupalci-testing
+build:
+ assessment:
+ validate_codebase:
+ phplint:
+ # Re-run composer install to ensure the dependencies resolve for the
+ # containerized PHP version.
+ container_composer:
+ options: ' install --prefer-dist --no-suggest --no-progress --no-interaction'
+ halt-on-fail: true
+ phpcs:
+ # phpcs will use core's specified version of Coder.
+ sniff-all-files: true
+ halt-on-fail: true
+ testing:
+ # run_tests task is executed several times in order of performance speeds.
+ # halt-on-fail can be set on the run_tests tasks in order to fail fast.
+ # suppress-deprecations is false in order to be alerted to usages of
+ # deprecated code.
+ run_tests.phpunit:
+ types: 'PHPUnit-Unit'
+ testgroups: '--all'
+ suppress-deprecations: false
+ halt-on-fail: false
+ run_tests.kernel:
+ types: 'PHPUnit-Kernel'
+ testgroups: '--all'
+ suppress-deprecations: false
+ halt-on-fail: false
+ run_tests.functional:
+ types: 'PHPUnit-Functional'
+ testgroups: '--all'
+ suppress-deprecations: false
+ halt-on-fail: false
+ run_tests.javascript:
+ concurrency: 15
+ types: 'PHPUnit-FunctionalJavascript'
+ testgroups: '--all'
+ suppress-deprecations: false
+ halt-on-fail: false
diff --git a/phpcs.xml b/phpcs.xml
new file mode 100644
index 0000000..01d0b82
--- /dev/null
+++ b/phpcs.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ruleset name="dynamic_entity_reference">
+ <description>Default PHP CodeSniffer configuration for Dynamic Entity Reference.</description>
+ <file>.</file>
+ <arg name="extensions" value="inc,install,module,php,profile,test,theme,yml"/>
+
+ <!--Ignore README markdown-->
+ <exclude-pattern>README\.md</exclude-pattern>
+ <exclude-pattern>CHANGELOG\.md</exclude-pattern>
+
+ <rule ref="Drupal"/>
+</ruleset>
diff --git a/phpcs.xml.dist b/phpcs.xml.dist
deleted file mode 100644
index 5e2b0d9..0000000
--- a/phpcs.xml.dist
+++ /dev/null
@@ -1,287 +0,0 @@
-<?xml version="1.0"?>
-<!-- See http://pear.php.net/manual/en/package.php.php-codesniffer.annotated-ruleset.php -->
-<ruleset name="Drupal">
- <description>Drupal coding standard</description>
- <!-- All Drupal code files must be UTF-8 encoded and we treat them as such. -->
- <arg name="encoding" value="utf-8"/>
-
- <arg name="extensions" value="php,module,inc,install,test,profile,theme,css,info,txt,md,yml"/>
-
- <rule ref="Internal.NoCodeFound">
- <!-- Empty files are fine, might be used for testing. -->
- <exclude-pattern>*</exclude-pattern>
- </rule>
-
- <rule ref="Drupal.Commenting.FileComment">
- <!-- Do not run this sniff on txt files. -->
- <exclude-pattern>*.txt</exclude-pattern>
- </rule>
- <rule ref="Drupal.Commenting.FileComment.SpacingAfterComment">
- <!-- Do not run this sniff on template files. -->
- <exclude-pattern>*.tpl.php</exclude-pattern>
- </rule>
- <rule ref="Drupal.ControlStructures.ControlSignature">
- <!-- Do not run this sniff on template files. -->
- <exclude-pattern>*.tpl.php</exclude-pattern>
- </rule>
-
- <!-- Silence deprecated sniff that will be removed in Coder 9.x. -->
- <rule ref="Drupal.Functions.FunctionDeclaration.SpaceAfter">
- <severity>0</severity>
- </rule>
- <rule ref="Drupal.Functions.FunctionDeclaration.SpaceBeforeParenthesis">
- <severity>0</severity>
- </rule>
- <!-- Silence mmethod name underscore warning which is coverd already in
- Drupal.NamingConventions.ValidFunctionName.ScopeNotCamelCaps. -->
- <rule ref="Drupal.Methods.MethodDeclaration.Underscore">
- <severity>0</severity>
- </rule>
-
- <rule ref="Drupal.WhiteSpace.ScopeIndent">
- <!-- Do not run this sniff on template files, as the indentation might follow
- the HTML -->
- <exclude-pattern>*.tpl.php</exclude-pattern>
- </rule>
-
- <rule ref="Generic.CodeAnalysis.UselessOverridingMethod" />
- <rule ref="Generic.Files.ByteOrderMark" />
- <rule ref="Generic.Formatting.SpaceAfterCast" />
-
- <rule ref="Generic.Functions.FunctionCallArgumentSpacing" />
- <rule ref="Generic.Functions.FunctionCallArgumentSpacing.NoSpaceAfterComma">
- <severity>0</severity>
- </rule>
- <rule ref="Generic.Functions.OpeningFunctionBraceKernighanRitchie">
- <properties>
- <property name="checkClosures" value="true"/>
- </properties>
- </rule>
-
- <rule ref="Generic.NamingConventions.ConstructorName" />
- <rule ref="Generic.NamingConventions.UpperCaseConstantName" />
- <rule ref="Generic.PHP.DeprecatedFunctions" />
- <rule ref="Generic.PHP.DisallowShortOpenTag" />
- <rule ref="Generic.PHP.LowerCaseKeyword" />
- <rule ref="Generic.PHP.UpperCaseConstant" />
- <rule ref="Generic.WhiteSpace.DisallowTabIndent" />
-
- <!-- Use Unix newlines -->
- <rule ref="Generic.Files.LineEndings">
- <properties>
- <property name="eolChar" value="\n"/>
- </properties>
- </rule>
-
- <rule ref="MySource.Debug.DebugCode" />
- <rule ref="PEAR.Files.IncludingFile" />
- <!-- Disable some error messages that we do not want. -->
- <rule ref="PEAR.Files.IncludingFile.UseIncludeOnce">
- <severity>0</severity>
- </rule>
- <rule ref="PEAR.Files.IncludingFile.UseInclude">
- <severity>0</severity>
- </rule>
- <rule ref="PEAR.Files.IncludingFile.UseRequireOnce">
- <severity>0</severity>
- </rule>
- <rule ref="PEAR.Files.IncludingFile.UseRequire">
- <severity>0</severity>
- </rule>
-
- <rule ref="PEAR.Functions.FunctionCallSignature"/>
- <!-- Disable some error messages that we already cover. -->
- <rule ref="PEAR.Functions.FunctionCallSignature.SpaceAfterOpenBracket">
- <severity>0</severity>
- </rule>
- <rule ref="PEAR.Functions.FunctionCallSignature.SpaceBeforeCloseBracket">
- <severity>0</severity>
- </rule>
- <!-- Disable some error messages that we do not want. -->
- <rule ref="PEAR.Functions.FunctionCallSignature.Indent">
- <severity>0</severity>
- </rule>
- <rule ref="PEAR.Functions.FunctionCallSignature.ContentAfterOpenBracket">
- <severity>0</severity>
- </rule>
- <rule ref="PEAR.Functions.FunctionCallSignature.CloseBracketLine">
- <severity>0</severity>
- </rule>
- <rule ref="PEAR.Functions.FunctionCallSignature.EmptyLine">
- <severity>0</severity>
- </rule>
-
- <rule ref="PEAR.Functions.ValidDefaultValue" />
-
- <rule ref="PSR2.Namespaces.NamespaceDeclaration" />
- <rule ref="PSR2.Namespaces.UseDeclaration" />
-
- <rule ref="Squiz.Arrays.ArrayDeclaration" />
- <!-- Disable some error messages that we do not want. -->
- <rule ref="Squiz.Arrays.ArrayDeclaration.CloseBraceNotAligned">
- <severity>0</severity>
- </rule>
- <rule ref="Squiz.Arrays.ArrayDeclaration.DoubleArrowNotAligned">
- <severity>0</severity>
- </rule>
- <rule ref="Squiz.Arrays.ArrayDeclaration.FirstValueNoNewline">
- <severity>0</severity>
- </rule>
- <rule ref="Squiz.Arrays.ArrayDeclaration.KeyNotAligned">
- <severity>0</severity>
- </rule>
- <rule ref="Squiz.Arrays.ArrayDeclaration.MultiLineNotAllowed">
- <severity>0</severity>
- </rule>
- <rule ref="Squiz.Arrays.ArrayDeclaration.NoComma">
- <severity>0</severity>
- </rule>
- <rule ref="Squiz.Arrays.ArrayDeclaration.NoCommaAfterLast">
- <severity>0</severity>
- </rule>
- <rule ref="Squiz.Arrays.ArrayDeclaration.NotLowerCase">
- <severity>0</severity>
- </rule>
- <rule ref="Squiz.Arrays.ArrayDeclaration.SingleLineNotAllowed">
- <severity>0</severity>
- </rule>
- <rule ref="Squiz.Arrays.ArrayDeclaration.ValueNotAligned">
- <severity>0</severity>
- </rule>
- <rule ref="Squiz.Arrays.ArrayDeclaration.ValueNoNewline">
- <severity>0</severity>
- </rule>
-
- <rule ref="Squiz.Arrays.ArrayBracketSpacing" />
-
- <rule ref="Squiz.ControlStructures.ForEachLoopDeclaration" />
- <!-- Disable some error messages that we already cover. -->
- <rule ref="Squiz.ControlStructures.ForEachLoopDeclaration.AsNotLower">
- <severity>0</severity>
- </rule>
- <rule ref="Squiz.ControlStructures.ForEachLoopDeclaration.SpaceAfterOpen">
- <severity>0</severity>
- </rule>
- <rule ref="Squiz.ControlStructures.ForEachLoopDeclaration.SpaceBeforeClose">
- <severity>0</severity>
- </rule>
- <rule ref="Squiz.ControlStructures.ForLoopDeclaration" />
- <!-- Disable some error messages that we already cover. -->
- <rule ref="Squiz.ControlStructures.ForLoopDeclaration.SpacingAfterOpen">
- <severity>0</severity>
- </rule>
- <rule ref="Squiz.ControlStructures.ForLoopDeclaration.SpacingBeforeClose">
- <severity>0</severity>
- </rule>
-
- <rule ref="Squiz.ControlStructures.SwitchDeclaration" />
- <!-- Disable some error messages that we do not want. -->
- <rule ref="Squiz.ControlStructures.SwitchDeclaration.BreakIndent">
- <severity>0</severity>
- </rule>
- <rule ref="Squiz.ControlStructures.SwitchDeclaration.CaseIndent">
- <severity>0</severity>
- </rule>
- <rule ref="Squiz.ControlStructures.SwitchDeclaration.CloseBraceAlign">
- <severity>0</severity>
- </rule>
- <rule ref="Squiz.ControlStructures.SwitchDeclaration.DefaultIndent">
- <severity>0</severity>
- </rule>
- <rule ref="Squiz.ControlStructures.SwitchDeclaration.DefaultNoBreak">
- <severity>0</severity>
- </rule>
- <rule ref="Squiz.ControlStructures.SwitchDeclaration.EmptyCase">
- <severity>0</severity>
- </rule>
- <rule ref="Squiz.ControlStructures.SwitchDeclaration.EmptyDefault">
- <severity>0</severity>
- </rule>
- <rule ref="Squiz.ControlStructures.SwitchDeclaration.MissingDefault">
- <severity>0</severity>
- </rule>
- <rule ref="Squiz.ControlStructures.SwitchDeclaration.SpacingAfterCase">
- <severity>0</severity>
- </rule>
- <rule ref="Squiz.ControlStructures.SwitchDeclaration.SpacingAfterDefaultBreak">
- <severity>0</severity>
- </rule>
- <rule ref="Squiz.ControlStructures.SwitchDeclaration.SpacingBeforeBreak">
- <severity>0</severity>
- </rule>
-
- <rule ref="Squiz.CSS.ClassDefinitionClosingBraceSpace" />
- <rule ref="Squiz.CSS.ClassDefinitionClosingBraceSpace.SpacingAfterClose">
- <severity>0</severity>
- </rule>
- <rule ref="Squiz.CSS.ClassDefinitionOpeningBraceSpace" />
- <rule ref="Squiz.CSS.ClassDefinitionOpeningBraceSpace.AfterNesting">
- <severity>0</severity>
- </rule>
- <rule ref="Squiz.CSS.ColonSpacing" />
- <rule ref="Squiz.CSS.DisallowMultipleStyleDefinitions" />
- <rule ref="Squiz.CSS.EmptyClassDefinition" />
- <rule ref="Squiz.CSS.EmptyStyleDefinition" />
- <rule ref="Squiz.CSS.Indentation">
- <properties>
- <property name="indent" value="2"/>
- </properties>
- </rule>
- <rule ref="Squiz.CSS.MissingColon" />
- <rule ref="Squiz.CSS.SemicolonSpacing" />
-
- <rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing">
- <properties>
- <property name="equalsSpacing" value="1"/>
- </properties>
- </rule>
- <rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing.NoSpaceBeforeArg">
- <severity>0</severity>
- </rule>
-
- <rule ref="Squiz.Functions.MultiLineFunctionDeclaration" />
- <rule ref="Squiz.Functions.MultiLineFunctionDeclaration.BraceOnSameLine">
- <severity>0</severity>
- </rule>
- <rule ref="Squiz.Functions.MultiLineFunctionDeclaration.ContentAfterBrace">
- <severity>0</severity>
- </rule>
- <!-- Standard yet to be finalized on this (https://www.drupal.org/node/1539712). -->
- <rule ref="Squiz.Functions.MultiLineFunctionDeclaration.FirstParamSpacing">
- <severity>0</severity>
- </rule>
- <rule ref="Squiz.Functions.MultiLineFunctionDeclaration.Indent">
- <severity>0</severity>
- </rule>
- <rule ref="Squiz.Functions.MultiLineFunctionDeclaration.CloseBracketLine">
- <severity>0</severity>
- </rule>
-
- <rule ref="Squiz.PHP.LowercasePHPFunctions" />
- <rule ref="Squiz.PHP.NonExecutableCode" />
- <rule ref="Squiz.Strings.ConcatenationSpacing">
- <properties>
- <property name="spacing" value="1"/>
- <property name="ignoreNewlines" value="true"/>
- </properties>
- </rule>
- <rule ref="Squiz.WhiteSpace.FunctionSpacing">
- <properties>
- <property name="spacing" value="1"/>
- </properties>
- </rule>
- <rule ref="Squiz.WhiteSpace.LanguageConstructSpacing" />
- <rule ref="Squiz.WhiteSpace.SemicolonSpacing" />
- <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace" />
-
- <rule ref="Zend.Files.ClosingTag">
- <!-- Do not run this sniff on template files. -->
- <exclude-pattern>*.tpl.php</exclude-pattern>
- </rule>
-
- <!-- Ignore various version control directories. -->
- <exclude-pattern>*/\.git/*</exclude-pattern>
- <exclude-pattern>*/\.svn/*</exclude-pattern>
- <exclude-pattern>*/\.hg/*</exclude-pattern>
- <exclude-pattern>*/\.bzr/*</exclude-pattern>
-</ruleset>
diff --git a/src/DynamicEntityReferenceServiceProvider.php b/src/DynamicEntityReferenceServiceProvider.php
index b3f76f0..906f0fe 100644
--- a/src/DynamicEntityReferenceServiceProvider.php
+++ b/src/DynamicEntityReferenceServiceProvider.php
@@ -6,7 +6,6 @@ use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\DependencyInjection\ServiceProviderBase;
use Drupal\dynamic_entity_reference\Normalizer\DynamicEntityReferenceItemNormalizer;
use Symfony\Component\DependencyInjection\Definition;
-use Symfony\Component\DependencyInjection\Reference;
/**
* Service Provider for Dynamic Entity Reference.
@@ -31,7 +30,7 @@ class DynamicEntityReferenceServiceProvider extends ServiceProviderBase {
// The priority must be higher than that of
// serializer.normalizer.entity_reference_item.hal in
// hal.services.yml.
- $service_definition->addTag('normalizer', array('priority' => $parent_definition->getTags()['normalizer'][0]['priority'] + 1));
+ $service_definition->addTag('normalizer', ['priority' => $parent_definition->getTags()['normalizer'][0]['priority'] + 1]);
$container->setDefinition('serializer.normalizer.entity.dynamic_entity_reference_item.hal', $service_definition);
}
diff --git a/tests/src/FunctionalJavascript/DynamicEntityReferenceTest.php b/tests/src/FunctionalJavascript/DynamicEntityReferenceTest.php
index 3bcb475..defb647 100644
--- a/tests/src/FunctionalJavascript/DynamicEntityReferenceTest.php
+++ b/tests/src/FunctionalJavascript/DynamicEntityReferenceTest.php
@@ -107,13 +107,10 @@ class DynamicEntityReferenceTest extends WebDriverTestBase {
$this->drupalGet('entity_test/structure/entity_test/fields/add-field');
$select = $assert_session->selectExists('new_storage_type');
$select->selectOption('dynamic_entity_reference');
- // This is needed to execute machine name JS.
$label = $assert_session->fieldExists('label');
- $label->focus();
$label->setValue('Foobar');
- $label->blur();
- $select->focus();
- sleep(1);
+ // Wait for the machine name.
+ $assert_session->waitForElementVisible('css', '[name="label"] + * .machine-name-value');
$this->submitForm([], t('Save and continue'), 'field-ui-field-storage-add-form');
$page = $this->getSession()->getPage();
$entity_type_ids_select = $assert_session->selectExists('settings[entity_type_ids][]', $page);
@@ -187,13 +184,10 @@ class DynamicEntityReferenceTest extends WebDriverTestBase {
$this->drupalGet('/admin/structure/types/manage/test_content/fields/add-field');
$select = $assert_session->selectExists('new_storage_type');
$select->selectOption('dynamic_entity_reference');
- // This is needed to execute machine name JS.
$label = $assert_session->fieldExists('label');
- $label->focus();
$label->setValue('Foobar');
- $label->blur();
- $select->focus();
- sleep(1);
+ // Wait for the machine name.
+ $assert_session->waitForElementVisible('css', '[name="label"] + * .machine-name-value');
$this->submitForm([], t('Save and continue'), 'field-ui-field-storage-add-form');
$page = $this->getSession()->getPage();
$entity_type_ids_select = $assert_session->selectExists('settings[entity_type_ids][]', $page);
diff --git a/tests/src/Kernel/DynamicEntityReferenceFormatterTest.php b/tests/src/Kernel/DynamicEntityReferenceFormatterTest.php
index b1fac36..72990b0 100644
--- a/tests/src/Kernel/DynamicEntityReferenceFormatterTest.php
+++ b/tests/src/Kernel/DynamicEntityReferenceFormatterTest.php
@@ -82,7 +82,6 @@ class DynamicEntityReferenceFormatterTest extends EntityKernelTestBase {
->save();
// The label formatter rendering generates links, so build the router.
- $this->installSchema('system', 'router');
$this->container->get('router.builder')->rebuild();
FieldStorageConfig::create([
diff --git a/tests/src/Kernel/EntityQueryRelationshipTest.php b/tests/src/Kernel/EntityQueryRelationshipTest.php
index 5de7ee9..7ae8aeb 100644
--- a/tests/src/Kernel/EntityQueryRelationshipTest.php
+++ b/tests/src/Kernel/EntityQueryRelationshipTest.php
@@ -52,13 +52,6 @@ class EntityQueryRelationshipTest extends EntityKernelTestBase {
protected $fieldName = 'field_test';
/**
- * The entity field query factory.
- *
- * @var \Drupal\Core\Entity\Query\QueryFactory
- */
- protected $factory;
-
- /**
* The results returned by EntityQuery.
*
* @var array
@@ -101,7 +94,6 @@ class EntityQueryRelationshipTest extends EntityKernelTestBase {
'label' => 'Field test',
'settings' => [],
])->save();
- $this->factory = \Drupal::service('entity.query');
}
/**
@@ -131,7 +123,9 @@ class EntityQueryRelationshipTest extends EntityKernelTestBase {
$this->entities[] = $entity;
// This returns the 0th entity as that's only one pointing to the 0th
// account.
- $this->queryResults = $this->factory->get('entity_test')
+ $this->queryResults = $this->container->get('entity_type.manager')
+ ->getStorage('entity_test')
+ ->getQuery()
->condition("field_test.0.entity:entity_test_rev.name", 'Foobar')
->condition("field_test.1.entity:entity_test_rev.name", 'Barfoo')
->execute();