Skip to content

Commit 7271e7c

Browse files
committed
fix Drush phpunit bootstrap
1 parent b5e6e9a commit 7271e7c

File tree

8 files changed

+41
-28
lines changed

8 files changed

+41
-28
lines changed

.github/workflows/ci.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ubuntu-latest
1111
strategy:
1212
matrix:
13-
drupal_version: ['9.5', '10.0', '10.1', '10.2', '10.3', '10.4', '11.0', '11.1']
13+
drupal_version: ['10.4', '11.0', '11.1']
1414
module: ['entity_to_text']
1515
include:
1616
- drupal_version: '11.2'
@@ -22,6 +22,14 @@ jobs:
2222
- run: docker compose -f docker-compose.yml pull --include-deps drupal
2323
- name: Build the docker compose stack
2424
run: docker compose -f docker-compose.yml build --pull --build-arg BASE_IMAGE_TAG=${{ matrix.drupal_version }} drupal
25+
- name: Up a persistent Docker Container
26+
run: docker compose -f docker-compose.yml up -d drupal
27+
- name: wait on Docker to be ready, especially Apache that takes many seconds to be up
28+
run: docker compose exec -T drupal wait-for-it drupal:80 -t 60
29+
- name: wait on Docker to be ready, especially MariaDB that takes many seconds to be up
30+
run: docker compose exec -T drupal wait-for-it db:3306 -t 60
31+
- name: Bootstrap Drupal
32+
run: docker compose -f docker-compose.yml exec -T -u www-data drupal drush site-install standard --db-url="mysql://drupal:drupal@db/drupal" -y
2533
- name: Run unit tests
2634
run: docker compose -f docker-compose.yml run -u www-data drupal phpunit --no-coverage --group=${{ matrix.module }} --exclude-group=${{ matrix.module }}_functional --configuration=/var/www/html/phpunit.xml
2735

@@ -30,7 +38,7 @@ jobs:
3038
runs-on: ubuntu-latest
3139
strategy:
3240
matrix:
33-
drupal_version: ['9.5', '10.0', '10.1', '10.2', '10.3', '10.4', '11.0', '11.1']
41+
drupal_version: ['10.4', '11.0', '11.1']
3442
module: ['entity_to_text']
3543
include:
3644
- drupal_version: '11.2'
@@ -58,7 +66,7 @@ jobs:
5866
runs-on: ubuntu-latest
5967
strategy:
6068
matrix:
61-
drupal_version: ['10.3']
69+
drupal_version: ['10.4']
6270
module: ['entity_to_text']
6371

6472
steps:

composer.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,11 @@
3232
},
3333
"require-dev": {
3434
"drupal/coder": "^8.3.1",
35-
"drupal/paragraphs": "^1.0",
36-
"vaites/php-apache-tika": "^1"
35+
"drupal/paragraphs": "^1.14",
36+
"vaites/php-apache-tika": "^1",
37+
"drupal/feeds": "^3.0",
38+
"drupal/pathauto": "^1.13",
39+
"drupal/entity_browser": "^2.12"
3740
},
3841
"config": {
3942
"allow-plugins": {

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ services:
88
volumes:
99
# Mount the module in the proper contrib module directory.
1010
- .:/var/www/html/modules/contrib/entity_to_text
11+
1112
restart: unless-stopped
1213

1314
db:

modules/entity_to_text_tika/src/Commands/OcrLocalFileCacheWarmup.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,9 @@ public function warmup(
172172
$progressbar_objects->setMessage((string) $page, 'page_current');
173173
$base_query->range($page * self::LIMIT_PAGER, self::LIMIT_PAGER);
174174
$files = $base_query->execute();
175-
foreach ($files as $file) {
176-
$file = $this->fileStorage->load($file);
175+
176+
foreach ($files as $fid) {
177+
$file = $this->fileStorage->load($fid);
177178

178179
$this->output()->writeln(sprintf('Processing file (%s) "%s".', $file->id(), $file->getFileUri()), OutputInterface::VERBOSITY_VERBOSE);
179180

modules/entity_to_text_tika/tests/src/Kernel/LocalFileStorageTest.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
namespace Drupal\Tests\entity_to_text_tika\Kernel;
44

55
use Drupal\Core\File\FileSystemInterface;
6+
use Drupal\Core\StreamWrapper\PrivateStream;
7+
use Drupal\Core\StreamWrapper\StreamWrapperInterface;
68
use Drupal\entity_to_text_tika\Storage\LocalFileStorage;
79
use Drupal\file\Entity\File;
810
use Drupal\KernelTests\Core\File\FileTestBase;
11+
use Drupal\Core\File\FileExists;
912

1013
/**
1114
* Tests the Plaintext File Storage.
@@ -22,7 +25,7 @@ final class LocalFileStorageTest extends FileTestBase {
2225
/**
2326
* {@inheritdoc}
2427
*/
25-
protected static $modules = ['file', 'entity_to_text_tika', 'user'];
28+
protected static $modules = ['system', 'file', 'entity_to_text_tika', 'user'];
2629

2730
/**
2831
* The file system service.
@@ -61,7 +64,7 @@ protected function setUp(): void {
6164
public function testloadPublic(): void {
6265
// Create an OCR file for testing.
6366
$file_uri = $this->createUri('390-foo.txt.en.ocr.txt', 'Ipsum excepteur id cupidatat commodo', 'private');
64-
$this->fileSystem->move($file_uri, 'private://entity-to-text/ocr/390-foo.txt.en.ocr.txt', FileSystemInterface::EXISTS_REPLACE);
67+
$this->fileSystem->move($file_uri, 'private://entity-to-text/ocr/390-foo.txt.en.ocr.txt', FileExists::Replace);
6568

6669
// Create a file that correspond to the previous OCR file.
6770
$file = File::create([
@@ -79,7 +82,7 @@ public function testloadPublic(): void {
7982
public function testloadPrivate(): void {
8083
// Create an OCR file for testing.
8184
$file_uri = $this->createUri('390-foo.txt.en.ocr.txt', 'Ipsum excepteur id cupidatat commodo', 'private');
82-
$this->fileSystem->move($file_uri, 'private://entity-to-text/ocr/390-foo.txt.en.ocr.txt', FileSystemInterface::EXISTS_REPLACE);
85+
$this->fileSystem->move($file_uri, 'private://entity-to-text/ocr/390-foo.txt.en.ocr.txt', FileExists::Replace);
8386

8487
// Create a file that correspond to the previous OCR file.
8588
$file = File::create([
@@ -97,7 +100,7 @@ public function testloadPrivate(): void {
97100
public function testloadSubDirectory(): void {
98101
// Create an OCR file for testing.
99102
$file_uri = $this->createUri('420-foo.txt.en.ocr.txt', 'Ipsum excepteur id cupidatat commodo', 'private');
100-
$this->fileSystem->move($file_uri, 'private://entity-to-text/ocr/420-foo.txt.en.ocr.txt', FileSystemInterface::EXISTS_REPLACE);
103+
$this->fileSystem->move($file_uri, 'private://entity-to-text/ocr/420-foo.txt.en.ocr.txt', FileExists::Replace);
101104

102105
// Create a file that correspond to the previous OCR file.
103106
$file = File::create([
@@ -148,7 +151,7 @@ public function testSave(): void {
148151
public function testSaveWhenOcrFileAlreadyExists(): void {
149152
// Create an OCR file for testing.
150153
$file_ocr_uri = $this->createUri('400-foo.txt.en.ocr.txt', 'Ipsum excepteur id cupidatat commodo', 'private');
151-
$this->fileSystem->move($file_ocr_uri, 'private://entity-to-text/ocr/400-foo.txt.en.ocr.txt', FileSystemInterface::EXISTS_REPLACE);
154+
$this->fileSystem->move($file_ocr_uri, 'private://entity-to-text/ocr/400-foo.txt.en.ocr.txt', FileExists::Replace);
152155

153156
// Create a file for testing.
154157
$file = File::create([

modules/entity_to_text_tika/tests/src/Unit/EntityToTextTikaEventsTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class EntityToTextTikaEventsTest extends UnitTestCase {
1818
*
1919
* @dataProvider eventNames
2020
*/
21-
public function testEventNames($event_name, $expected) {
21+
public function testEventNames($event_name, $expected): void {
2222
$this->assertEquals($expected, $event_name);
2323
}
2424

@@ -28,7 +28,7 @@ public function testEventNames($event_name, $expected) {
2828
* @return array
2929
* The list of CONST names & string expected value.
3030
*/
31-
public function eventNames() {
31+
public static function eventNames(): iterable {
3232
return [
3333
[
3434
EntityToTextTikaEvents::PRE_PROCESS_FILE,

modules/entity_to_text_tika/tests/src/Unit/OcrLocalFileCacheWarmupTest.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ public function testWarmupForce(): void {
282282
$file200->expects(self::once())
283283
->method('getFileUri')
284284
->willReturn('public://file/test.txt');
285-
$file200->expects(self::once())
285+
$file200->expects(self::any())
286286
->method('id')
287287
->willReturn(200);
288288

@@ -291,7 +291,7 @@ public function testWarmupForce(): void {
291291
$file2039->expects(self::once())
292292
->method('getFileUri')
293293
->willReturn('public://file/foo.pdf');
294-
$file2039->expects(self::once())
294+
$file2039->expects(self::any())
295295
->method('id')
296296
->willReturn(2039);
297297

@@ -319,10 +319,16 @@ public function testWarmupForce(): void {
319319
$this->localFileStorage->expects($this->exactly(2))
320320
->method('save')
321321
->with(
322+
$this->callback(function ($arg) use ($file200, $file2039) {
323+
// First arg should be a File object (one of our two mocks)
324+
$isCorrectFile = ($arg === $file200 || $arg === $file2039);
325+
return $isCorrectFile;
326+
}),
322327
$this->logicalOr(
323-
$this->equalTo([$file2039, 'doloreum', 'eng+fra']),
324-
$this->equalTo([$file2039, 'ipsum', 'eng+fra'])
325-
)
328+
$this->equalTo('doloreum'),
329+
$this->equalTo('ipsum')
330+
),
331+
$this->equalTo('eng+fra')
326332
);
327333

328334
$this->warmupCommand->warmup([

phpstan.neon

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,3 @@ includes:
44
parameters:
55
level: 1
66
reportUnmatchedIgnoredErrors: false
7-
ignoreErrors:
8-
# The module support Drupal 9, 10 and Drupal 11, so we cannot fix that deprecation without dropping support of 10.3.x and below.
9-
-
10-
message: """
11-
#^Fetching deprecated class constant EXISTS_REPLACE of interface#
12-
"""
13-
count: 4
14-
path: tests/src/Kernel/LocalFileStorageTest.php
15-

0 commit comments

Comments
 (0)