Skip to content

Commit

Permalink
Run tests on Drupal 11 (#127)
Browse files Browse the repository at this point in the history
* Run tests on Drupal 11

* update unit tests
  • Loading branch information
pookmish authored Aug 29, 2024
1 parent c4da0f6 commit 52609f7
Show file tree
Hide file tree
Showing 13 changed files with 64 additions and 99 deletions.
65 changes: 50 additions & 15 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
name: PHPUnit and Acceptance Tests
on: [push]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
phpunit:
name: PHPUnit Coverage Tests
runs-on: ubuntu-latest
container:
image: pookmish/drupal8ci:latest
image: pookmish/drupal8ci:php8.3
services:
mysql:
image: mysql:5.7
image: mysql:8.0
env:
MYSQL_DATABASE: drupal
MYSQL_USER: drupal
Expand All @@ -18,17 +21,49 @@ jobs:
- 33306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
path: project
- name: Build project
env:
CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}}
run: |
composer global require su-sws/stanford-caravan:10.x-dev
~/.composer/vendor/bin/sws-caravan phpunit /var/www/html --extension-dir=$GITHUB_WORKSPACE/project --with-coverage
~/.config/composer/vendor/bin/sws-caravan phpunit /var/www/html --extension-dir=$GITHUB_WORKSPACE/project --with-coverage
- name: Save Test Results
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: failure()
with:
name: unit-tests-results
path: /var/www/html/artifacts
phpunit_d11:
name: PHPUnit Coverage Tests Drupal 11
runs-on: ubuntu-latest
container:
image: pookmish/drupal8ci:php8.3
services:
mysql:
image: mysql:8.0
env:
MYSQL_DATABASE: drupal
MYSQL_USER: drupal
MYSQL_PASSWORD: drupal
MYSQL_ROOT_PASSWORD: drupal
ports:
- 33306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- uses: actions/checkout@v4
with:
path: project
- name: Build project
env:
CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}}
run: |
composer global require su-sws/stanford-caravan:11.x-dev
~/.config/composer/vendor/bin/sws-caravan phpunit /var/www/html --extension-dir=$GITHUB_WORKSPACE/project --with-coverage
- name: Save Test Results
uses: actions/upload-artifact@v4
if: failure()
with:
name: unit-tests-results
Expand All @@ -46,7 +81,7 @@ jobs:
# options: '--network-alias drupal8ci'
# services:
# mysql:
# image: mysql:5.7
# image: mysql:8.0
# env:
# MYSQL_DATABASE: drupal
# MYSQL_USER: drupal
Expand All @@ -56,15 +91,15 @@ jobs:
# - 33306:3306
# options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
# steps:
# - uses: actions/checkout@v3
# - uses: actions/checkout@v4
# with:
# path: project
# - name: Run tests
# run: |
# composer global require su-sws/stanford-caravan:10.x-dev
# ~/.composer/vendor/bin/sws-caravan codeception /var/www/html --extension-dir=$GITHUB_WORKSPACE/project --suites=acceptance
# composer global require su-sws/stanford-caravan:11.x-dev
# ~/.config/composer/vendor/bin/sws-caravan codeception /var/www/html --extension-dir=$GITHUB_WORKSPACE/project --suites=acceptance
# - name: Save Test Results
# uses: actions/upload-artifact@v3
# uses: actions/upload-artifact@v4
# if: always()
# with:
# name: acceptance-tests-results
Expand All @@ -85,7 +120,7 @@ jobs:
# image: selenium/standalone-chrome
# options: '--shm-size="2g"'
# mysql:
# image: mysql:5.7
# image: mysql:8.0
# env:
# MYSQL_DATABASE: drupal
# MYSQL_USER: drupal
Expand All @@ -95,15 +130,15 @@ jobs:
# - 33306:3306
# options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
# steps:
# - uses: actions/checkout@v3
# - uses: actions/checkout@v4
# with:
# path: project
# - name: Run tests
# run: |
# composer global require su-sws/stanford-caravan:10.x-dev
# ~/.composer/vendor/bin/sws-caravan codeception /var/www/html --extension-dir=$GITHUB_WORKSPACE/project --suites=functional
# composer global require su-sws/stanford-caravan:11.x-dev
# ~/.config/composer/vendor/bin/sws-caravan codeception /var/www/html --extension-dir=$GITHUB_WORKSPACE/project --suites=functional
# - name: Save Test Results
# uses: actions/upload-artifact@v3
# uses: actions/upload-artifact@v4
# if: always()
# with:
# name: functional-tests-results
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"type": "drupal-custom-module",
"license": "GPL-2.0-or-later",
"minimum-stability": "dev",
"prefer-stable": true,
"authors": [
{
"name": "Mike Decker",
Expand All @@ -17,7 +18,7 @@
}
],
"require": {
"drupal/core": "^9.0 || ^10.0",
"drupal/core": "^9 || ^10 || ^11",
"drupal/paragraphs": "^1.1"
},
"autoload-dev": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: 'React Paragraphs Behaviors'
type: module
description: 'Provides behavior plugin interface for paragraphs and rows.'
core_version_requirement: ^9.4 || ^10
core_version_requirement: ^9.4 || ^10 || ^11
package: 'Custom'
dependencies:
- react_paragraphs:react_paragraphs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function testBehaviorForm() {
$form_state = new FormState();
$paragraph = $this->createMock(ParagraphInterface::class);
$paragraph->method('getBehaviorSetting')
->will($this->returnCallback([$this, 'getBehaviorSettingCallback']));
->willReturnCallback([$this, 'getBehaviorSettingCallback']);
$element = $this->paragraphType->getEnabledBehaviorPlugins()['react_paragraphs:first']
->buildBehaviorForm($paragraph, $form, $form_state);

Expand Down
2 changes: 1 addition & 1 deletion react_paragraphs.info.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: React Paragraphs
description: 'React based paragraphs fields'
type: module
core_version_requirement: ^9.4 || ^10
core_version_requirement: ^9.4 || ^10 || ^11
version: 8.2.17
package: Paragraphs
dependencies:
Expand Down
72 changes: 0 additions & 72 deletions tests/src/Kernel/Controller/ReactMediaLibraryTest.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ protected function getFieldConfig(){
$field_config->method('getFieldStorageDefinition')->willReturn($field_storage);

$field_config->method('getSetting')
->will($this->returnCallback([$this,'getSettingCallback']));
->willReturnCallback([$this,'getSettingCallback']);
return $field_config;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function testPlugin() {
* @return \PHPUnit\Framework\MockObject\MockObject
* Mocked object.
*/
public function getStorageCallback() {
public function getStorageCallback($type) {
$filter = $this->createMock(FilterFormatInterface::class);
$filter->method('label')->willReturn('Foo Bar');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function testPluginMediaLibrary() {
/**
* Entity type manager get storage callback.
*/
public function getStorageCallback() {
public function getStorageCallback($type) {
$media_type = $this->createMock(MediaTypeInterface::class);
$media_type->method('label')->willReturn('Image');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function setup(): void {

$entity_type_manager = $this->createMock(EntityTypeManagerInterface::class);
$entity_type_manager->method('getStorage')
->will($this->returnCallback([$this, 'getStorageCallback']));
->willReturnCallback([$this, 'getStorageCallback']);

$this->container->set('entity_type.manager', $entity_type_manager);
$this->container->set('current_user', $this->createMock(AccountProxyInterface::class));
Expand Down Expand Up @@ -91,5 +91,6 @@ public function testPlugin() {
$this->assertEquals($expected, $data);
}

public function getStorageCallback($type) {}

}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function testWebforms() {
$this->assertEquals($expected, $data);
}

public function getStorageCallback() {
public function getStorageCallback($type) {
$webform_storage = $this->createMock(TestWebformEntityStorageInterface::class);
$webform_storage->method('getOptions')->willReturn([]);
return $webform_storage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function testPlugin() {
/**
* Get View storage callback.
*/
public function getStorageCallback() {
public function getStorageCallback($type) {
$displays = [
'master' => [
'display_plugin' => 'master',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function setup(): void {

$entity_type_manager = $this->createMock(EntityTypeManagerInterface::class);
$entity_type_manager->method('getDefinition')->willReturn($entity_definition);
$entity_type_manager->method('getStorage')->will($this->returnCallback([$this, 'getEntityStorageCallback']));
$entity_type_manager->method('getStorage')->willReturnCallback([$this, 'getEntityStorageCallback']);

$form = [
'field_foo' => [],
Expand Down Expand Up @@ -113,7 +113,7 @@ public function getEntityStorageCallback($type) {
$paragraph->method('access')->willReturnReference($this->entityAccess);

$entity_storage->method('create')->willReturn($paragraph);
$entity_storage->method('load')->will($this->returnCallback([$this, 'loadEntityCallback']));
$entity_storage->method('load')->willReturnCallback([$this, 'loadEntityCallback']);

return $entity_storage;
}
Expand Down

0 comments on commit 52609f7

Please sign in to comment.