Commit 7281a6ff authored by Joe Hoyle's avatar Joe Hoyle
Browse files

Make the S3_UPLOADS_REGION constant requried

This is needed in v3 of the SDK
parent 37e30149
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -21,7 +21,12 @@ function s3_uploads_init() {
		return;
	}

	if ( ! defined( 'S3_UPLOADS_REGION' ) ) {
		wp_die( 'S3_UPLOADS_REGION constant is required. Please define it in your wp-config.php' );
	}

	$instance = S3_Uploads::get_instance();
	$instance->register_stream_wrapper();

	add_filter( 'upload_dir', array( $instance, 'filter_upload_dir' ) );
	add_filter( 'wp_image_editors', array( $instance, 'filter_editors' ), 9 );
+18 −0
Original line number Diff line number Diff line
<?php

class Test_S3_Uploads extends WP_UnitTestCase {

	function test_get_s3_bucket_location() {

		$uploads = new S3_Uploads( 'hmn-uploads', S3_UPLOADS_KEY, S3_UPLOADS_SECRET, S3_UPLOADS_REGION );

		$region = $uploads->get_s3_bucket_region();
		$this->assertEquals( 'us-east-1', $region );
	}

	function test_get_s3_bucket() {
		$uploads = new S3_Uploads( 'hmn-uploads/something', S3_UPLOADS_KEY, S3_UPLOADS_SECRET, S3_UPLOADS_REGION );

		$this->assertEquals( 'hmn-uploads', $uploads->get_s3_bucket() );
	}
}
 No newline at end of file