Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial source code #1

Merged
merged 6 commits into from
Jun 16, 2018
Merged

Conversation

LukeCarrier
Copy link
Contributor

@LukeCarrier LukeCarrier commented Jun 15, 2018

Tired (will open issues after merging):

  1. XML support for the WS client, since we don't have a serialise() implementation for it. Given that the client is currently unused, I suggest we avoid this for now. (XML support for the web service client #2)
  2. The issue with XML request payloads containing tags with duplicate names inside of external_multiple_structure values still persists. The current mitigation is to just add a unique identifier to the end of the tag, e.g. an int we just increment each time. This is left to the developer. (XML request payloads can't contain tags of the same name #3)

Wired:

  1. Parsing loaded requests with bodies, given the appropriate HTTP method (PUT!).
  2. Basic WS client.

Inspired: cleaned up Git history.

@LukeCarrier LukeCarrier self-assigned this Jun 15, 2018
Copy link

@sliute sliute left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine, have just a few questions below.

PARAM_BOOL, '', VALUE_REQUIRED);
}

public static function function($params) {}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is meant to mirror the upsert() method in auth/avadosalesforce/classes/external/upsert_v1.php, right? But do we need to define it here inside this class? And if we do, can it use a more telling name, as 'function' is pretty generic?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes in the sense that it's the implementation of a WS function, but no as they're separate plugins -- this is just a mock. If you have a better name I'll take it, but I'm keen to follow the naming convention in the external functions API.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd go with mock_upsert_parameters, mock_upsert_returns and mock_upsert, but it's not a life-and-death issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll meet you halfway with mock_external_function, since this is not directly related to auth_avadosalesforce.

$server = new webservice_loadedrest_server_mock($mockformat, $inputfile->url());
$server->run();
}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And we need to add some assertions to this test, as there currently are none.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test is intended to cover server's interactions with format, which is achieved via the PHPUnit InvokedAtIndex matcher. I can't see any value in adding additional assertions?

Copy link

@sliute sliute Jun 15, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, got it. It's just that when run, PHPUnit doesn't output any sort of status for those - it is like you had no tests whatsoever (no dots, no other notification etc.) But it does not fail.

public function data_send_response() {
return [
[
'result' => true,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we provide a key-value array as a value for 'result' here, like it happens below? As in, 'result' => ['key' => true].

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is tested in the data block immediately below -- this one's to test external_values in the root of the request.

/**
* @dataProvider data_send_response
*/
public function test_send_response($result, external_description $description, $expect) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When running this test, I get this warning:

1) Warning The data provider specified for webservice_loadedrest_xml_format_testcase::test_send_response is invalid. Class 'external_value' not found

Doesn't quite make sense, as new external_value() statements inside data_send_response() easily lead to /lib/externallib.php from inside PhpStorm.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you paste the output of $ vendor/bin/phpunit --group webservice_loadedrest here? I'm interested in seeing the version information.

Copy link

@sliute sliute Jun 15, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here it is:

Moodle 3.4.2+ (Build: 20180405)
Php: 7.0.30.0.0.16.04.1, sqlsrv: 14.00.1000, OS: Linux 4.4.0-127-generic x86_64

PHPUnit 6.5.7 by Sebastian Bergmann and contributors.

......

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed via include of externallib -- it seems data providers execute prior to the PHPUnit bootstrap, which means the classloader isn't around to load the missing external_* classes.

Copy link

@sliute sliute left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's it for now.

@LukeCarrier
Copy link
Contributor Author

Fixed the above and added a markTestSkipped() for Moodle <= 3.3, which lack vfsStream.

@LukeCarrier LukeCarrier merged commit ac23a89 into AVADOLearning:master Jun 16, 2018
@LukeCarrier LukeCarrier deleted the sourcery branch June 16, 2018 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants