Skip to content

Commit 7a1322d

Browse files
committed
wip
1 parent e30e9cd commit 7a1322d

File tree

6 files changed

+35
-8
lines changed

6 files changed

+35
-8
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,6 @@ jobs:
5252
- name: checkout
5353
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
5454

55-
- name: poke s3
56-
run: |
57-
curl --fail 127.0.0.1:9090 > /dev/null
58-
5955
- name: setup wordpress tests
6056
env:
6157
WP_VERSION: ${{ matrix.wordpress }}
@@ -69,5 +65,6 @@ jobs:
6965
S3_UPLOADS_SECRET: valid-secret
7066
S3_UPLOADS_BUCKET_URL: "http://127.0.0.1:9090"
7167
S3_UPLOADS_REGION: ''
68+
S3_UPLOADS_BASE_URL: "http://127.0.0.1:9090"
7269
run: |
7370
phpunit

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
.idea/
33
*.phar
44
vendor
5+
wp-test-root

compose.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
services:
2+
3+
db:
4+
image: mysql:8
5+
environment:
6+
MYSQL_RANDOM_ROOT_PASSWORD: 1
7+
MYSQL_DATABASE: wp_tests_db
8+
MYSQL_USER: wp_test
9+
MYSQL_PASSWORD: password
10+
MYSQL_HOST: 127.0.0.1
11+
ports:
12+
- 3306:3306
13+
14+
s3:
15+
image: adobe/s3mock
16+
environment:
17+
COM_ADOBE_TESTING_S3MOCK_STORE_INITIAL_BUCKETS: "test-bucket"
18+
COM_ADOBE_TESTING_S3MOCK_STORE_VALID_KMS_KEYS: "arn:aws:kms:us-east-1:1234567890:key/valid-secret"
19+
ports:
20+
- 9090:9090
21+
- 9191:9191

inc/class-s3-uploads-stream-wrapper.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ public function stream_flush() {
5050
$this->params = apply_filters( 's3_uploads_putObject_params', $this->params );
5151

5252
return parent::stream_flush();
53-
5453
}
5554

5655
/**
@@ -84,8 +83,9 @@ public function stream_open( $path, $mode, $options, &$opened_path ) {
8483
* As a work around, we attempt to write an empty object.
8584
*/
8685
try {
87-
$p = $this->params;
88-
$p['Body'] = '';
86+
$p = $this->params;
87+
$p['Body'] = '';
88+
8989
static::$client->putObject( $p );
9090
} catch ( \Exception $e ) {
9191
return $this->triggerError( $e->getMessage() );

inc/class-s3-uploads.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,10 @@ public function s3() {
196196

197197
$params = array();
198198

199+
if ( defined( 'S3_UPLOADS_BASE_URL' ) ) {
200+
$params['base_url'] = S3_UPLOADS_BASE_URL;
201+
}
202+
199203
if ( $this->key && $this->secret ) {
200204
$params['key'] = $this->key;
201205
$params['secret'] = $this->secret;

tests/bootstrap.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// 2. Plugin installed inside of WordPress.org developer checkout
1212
// 3. Tests checked out to /tmp
1313
if ( false !== getenv( 'WP_DEVELOP_DIR' ) ) {
14-
$test_root = getenv( 'WP_DEVELOP_DIR' ) . '/tests/phpunit';
14+
$test_root = getenv( 'WP_DEVELOP_DIR' );
1515
} elseif ( file_exists( '../../../../tests/phpunit/includes/bootstrap.php' ) ) {
1616
$test_root = '../../../../tests/phpunit';
1717
} elseif ( file_exists( '/tmp/wordpress-tests-lib/includes/bootstrap.php' ) ) {
@@ -45,4 +45,8 @@ function _manually_load_plugin() {
4545
define( 'S3_UPLOADS_REGION', getenv( 'S3_UPLOADS_REGION' ) );
4646
}
4747

48+
if ( getenv( 'S3_UPLOADS_BASE_URL' ) ) {
49+
define( 'S3_UPLOADS_BASE_URL', getenv( 'S3_UPLOADS_BASE_URL' ) );
50+
}
51+
4852
require $test_root . '/includes/bootstrap.php';

0 commit comments

Comments
 (0)