-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #67 from sarahjcotton/moodle401-fixes
Fix to use correct DEBUG_ const causing unit test to fail
- Loading branch information
Showing
11 changed files
with
59 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,9 @@ | |
* @copyright 2018 Matt Porritt <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
namespace fileconverter_librelambda; | ||
|
||
defined('MOODLE_INTERNAL') || die(); | ||
|
||
global $CFG; | ||
|
@@ -33,6 +36,8 @@ | |
use Psr\Http\Message\RequestInterface; | ||
use Aws\S3\Exception\S3Exception; | ||
use \core_files\conversion; | ||
use \context_module; | ||
use \ReflectionMethod; | ||
|
||
/** | ||
* PHPUnit tests for Libre Lambda file converter. | ||
|
@@ -41,7 +46,7 @@ | |
* @copyright 2018 Matt Porritt <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class fileconverter_librelambda_converter_testcase extends advanced_testcase { | ||
class converter_test extends \advanced_testcase { | ||
|
||
/** | ||
* Test is_config_set method with missing configuration. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,9 @@ | |
* @copyright 2018 Matt Porritt <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
namespace fileconverter_librelambda; | ||
|
||
defined('MOODLE_INTERNAL') || die(); | ||
|
||
global $CFG; | ||
|
@@ -33,6 +36,7 @@ | |
use Psr\Http\Message\RequestInterface; | ||
use Aws\S3\Exception\S3Exception; | ||
use \core_files\conversion; | ||
use \context_module; | ||
|
||
/** | ||
* PHPUnit tests for Libre Lambda file converter. | ||
|
@@ -41,7 +45,7 @@ | |
* @copyright 2018 Matt Porritt <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class fileconverter_librelambda_events_testcase extends advanced_testcase { | ||
class events_test extends \advanced_testcase { | ||
|
||
/** | ||
* Test start document conversion method. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,13 +22,16 @@ | |
* @copyright 2018 Matt Porritt <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
namespace fileconverter_librelambda; | ||
|
||
defined('MOODLE_INTERNAL') || die(); | ||
|
||
global $CFG; | ||
require_once($CFG->dirroot . '/local/aws/sdk/aws-autoloader.php'); | ||
|
||
use Aws\Result; | ||
use Aws\MockHandler; | ||
use Aws\Result; | ||
use Aws\CommandInterface; | ||
use Psr\Http\Message\RequestInterface; | ||
use Aws\S3\Exception\S3Exception; | ||
|
@@ -41,7 +44,7 @@ | |
* @copyright 2018 Matt Porritt <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class mock_provision extends \fileconverter_librelambda\provision { | ||
class provision_mock extends provision { | ||
/** | ||
* | ||
* @var MockHandler | ||
|
@@ -100,29 +103,29 @@ public function check_bucket_exists($bucketname) { | |
* Create an S3 Bucket in AWS. | ||
* Upgrade to public. | ||
* | ||
* @param string $bucketname The name to use for the S3 bucket. | ||
* @return \stdClass $result The result of the bucket creation. | ||
*/ | ||
public function create_resource_bucket() { | ||
return parent::create_resource_bucket(); | ||
} | ||
} | ||
|
||
|
||
/** | ||
* PHPUnit tests for Libre Lambda AWS provision. | ||
* | ||
* @package fileconverter_librelambda | ||
* @copyright 2018 Matt Porritt <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class fileconverter_librelambda_provision_testcase extends advanced_testcase { | ||
class provision_test extends \advanced_testcase { | ||
|
||
/** | ||
* Test the does bucket exist method. Should return false. | ||
* We mock out the S3 client response as we are not trying to connect to the live AWS API. | ||
*/ | ||
public function test_create_resource_bucket_exists_false() { | ||
$provisioner = new mock_provision(); | ||
$provisioner = new provision_mock(); | ||
|
||
$provisioner->mocks3handler->append(function (CommandInterface $cmd, RequestInterface $req) { | ||
return new S3Exception('Mock exception', $cmd, ['code' => 'NotFound']); | ||
|
@@ -144,7 +147,7 @@ public function test_create_resource_bucket_exists_false() { | |
* We mock out the S3 client response as we are not trying to connect to the live AWS API. | ||
*/ | ||
public function test_create_resource_bucket_exists_true() { | ||
$provisioner = new mock_provision(); | ||
$provisioner = new provision_mock(); | ||
|
||
$provisioner->mocks3handler->append(new Result([])); | ||
|
||
|
@@ -161,7 +164,7 @@ public function test_create_resource_bucket_exists_true() { | |
* We mock out the S3 client response as we are not trying to connect to the live AWS API. | ||
*/ | ||
public function test_create_resource_bucket_exists_forbidden() { | ||
$provisioner = new mock_provision(); | ||
$provisioner = new provision_mock(); | ||
|
||
$bucketname = 'foobar'; | ||
$provisioner->mocks3handler->append(function (CommandInterface $cmd, RequestInterface $req) { | ||
|
@@ -179,7 +182,7 @@ public function test_create_resource_bucket_exists_forbidden() { | |
public function test_provision_stack_exists_no_replace() { | ||
global $CFG; | ||
|
||
$provisioner = new mock_provision(); | ||
$provisioner = new provision_mock(); | ||
|
||
$provisioner->mocks3handler->append(new Result([])); | ||
$provisioner->mocks3handler->append(new Result(['ObjectURL' => "https://amazon/lambdaconvert.zip"])); | ||
|
@@ -212,7 +215,7 @@ public function test_provision_stack_exists_replace() { | |
global $CFG; | ||
|
||
$lambdazip = 'lambdaconvert.zip'; | ||
$provisioner = new mock_provision(); | ||
$provisioner = new provision_mock(); | ||
|
||
$provisioner->mocks3handler->append(new Result([])); | ||
$provisioner->mocks3handler->append(new Result(['ObjectURL' => "https://amazon/$lambdazip"])); | ||
|
@@ -268,7 +271,7 @@ public function test_provision_stack_not_exists() { | |
|
||
$stack = 'AnotherStack'; | ||
$lambdazip = 'lambdaconvert.zip'; | ||
$provisioner = new mock_provision($stack); | ||
$provisioner = new provision_mock($stack); | ||
|
||
$provisioner->mocks3handler->append(new Result([])); | ||
$provisioner->mocks3handler->append(new Result(['ObjectURL' => "https://amazon/$lambdazip"])); | ||
|
@@ -323,7 +326,7 @@ public function test_remove_stack_remove_objects_ok() { | |
global $CFG; | ||
|
||
$filename = 'some.file'; | ||
$provisioner = new mock_provision(); | ||
$provisioner = new provision_mock(); | ||
|
||
$cloudformationpath = $CFG->dirroot . '/files/converter/librelambda/lambda/stack.template'; | ||
$provisioner->mockcloudformationhandler->append(new Result([ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters