Skip to content

Commit

Permalink
Enabled Drupal 11 CI test jobs (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
tannguyen04 authored Jul 4, 2024
1 parent d269b28 commit dd68a3b
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 84 deletions.
25 changes: 5 additions & 20 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,6 @@ jobs:
DRUPAL_PROJECT_SHA: 10.x
<<: *job-test

test-php-8.2-next:
<<: *container_config
docker:
- image: cimg/php:8.2-browsers
environment:
DRUPAL_VERSION: 11@alpha
DRUPAL_PROJECT_SHA: 11.x
<<: *job-test

test-php-8.3:
<<: *container_config
docker:
Expand Down Expand Up @@ -172,26 +163,20 @@ workflows:
filters:
tags:
only: /.*/
# Enable D11 once https://www.drupal.org/project/config_filter/issues/3428542 is resolved
# - test-php-8.2-next:
# filters:
# tags:
# only: /.*/
- test-php-8.3:
filters:
tags:
only: /.*/
# - test-php-8.3-next:
# filters:
# tags:
# only: /.*/
- test-php-8.3-next:
filters:
tags:
only: /.*/
- deploy:
requires:
- test-php-8.2
- test-php-8.2-legacy
#- test-php-8.2-next
- test-php-8.3
#- test-php-8.3-next
- test-php-8.3-next
filters:
tags:
only: /.*/
Expand Down
15 changes: 13 additions & 2 deletions composer.dev.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,27 @@
"phpmd/phpmd": "^2.15",
"phpspec/prophecy-phpunit": "^2",
"phpstan/extension-installer": "^1.3",
"mglaman/composer-drupal-lenient": "^1",
"vincentlanglet/twig-cs-fixer": "^2.8"
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true,
"phpstan/extension-installer": true
"phpstan/extension-installer": true,
"mglaman/composer-drupal-lenient": true
}
},
"extra": {
"drupal-lenient": {
"allowed-list": [
"drupal/config_filter"
]
},
"phpcodesniffer-search-depth": 10,
"patches": {}
"patches": {
"drupal/config_filter": {
"Automated Drupal 11 compatibility fixes for config_filter": "https://git.drupalcode.org/project/config_filter/-/merge_requests/9.patch"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Generated Content Example 1
type: module
description: Example 1 to programmatically generate content.
core_version_requirement: ^9 || ^10
core_version_requirement: ^9 || ^10 || ^11
package: Other
dependencies:
- generated_content:generated_content
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Generated Content Example 2
type: module
description: Example 2 to programmatically generate content.
core_version_requirement: ^9 || ^10
core_version_requirement: ^9 || ^10 || ^11
package: Other
dependencies:
- generated_content:generated_content
Expand Down
60 changes: 0 additions & 60 deletions tests/src/Traits/GeneratedContentTestMockTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

namespace Drupal\Tests\generated_content\Traits;

use PHPUnit\Framework\MockObject\Stub\Stub;

/**
* Trait GeneratedContentTestHelperTrait.
*
Expand Down Expand Up @@ -80,64 +78,6 @@ protected static function getProtectedValue(object $object, string $property) {
return $property->getValue($class);
}

/**
* Helper to prepare class mock.
*
* @param class-string|object $class
* Class name to generate the mock.
* @param array<string, mixed|\PHPUnit\Framework\MockObject\Stub\Stub> $methodsMap
* Optional array of methods and values, keyed by method name.
* @param array<mixed> $args
* Optional array of constructor arguments. If omitted, a constructor will
* not be called.
*
* @return \PHPUnit\Framework\MockObject\MockObject|string
* Mocked class.
*
* @throws \ReflectionException
*/
protected function prepareMock($class, array $methodsMap = [], array $args = []) {
$methods = array_keys($methodsMap);

$reflectionClass = new \ReflectionClass($class);

$class_name = is_object($class) ? get_class($class) : $class;

if ($reflectionClass->isAbstract()) {
$mock = $this->getMockForAbstractClass(
$class_name, $args, '', !empty($args), TRUE, TRUE, $methods
);
}
else {
$mock = $this->getMockBuilder($class_name);
if (!empty($args)) {
$mock = $mock->enableOriginalConstructor()
->setConstructorArgs($args);
}
else {
$mock = $mock->disableOriginalConstructor();
}
$mock = $mock->onlyMethods($methods)
->getMock();
}

foreach ($methodsMap as $method => $value) {
// Handle callback values differently.
if ($value instanceof Stub && strpos(get_class($value), 'Callback') !== FALSE) {
$mock->expects($this->any())
->method($method)
->will($value);
}
else {
$mock->expects($this->any())
->method($method)
->willReturn($value);
}
}

return $mock;
}

/**
* Check if testing framework was ran with --debug option.
*/
Expand Down

0 comments on commit dd68a3b

Please sign in to comment.