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

Add tests, docblocks for Logs endpoints #270

Merged
merged 4 commits into from
Jul 2, 2018

Conversation

joshcanhelp
Copy link
Contributor

  • Add tests for the Logs endpoint, including fields and pagination
  • Add docblocks for Logs class, minor refactor to conform to latest methods
  • Minor tweaks to code standards

@joshcanhelp joshcanhelp added this to the v5-Next milestone Jun 27, 2018
@joshcanhelp joshcanhelp force-pushed the add-tests-docs-pagination-logs branch from e250de5 to 83079ef Compare June 27, 2018 20:37
*/
public function search($params = [])
public function search(array $params = [])
Copy link
Contributor

Choose a reason for hiding this comment

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

what's the array word doing here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Type hinting, will throw an error if an array is not passed in.

*/
public function testGetOne()
{
$one_log = self::$api->get(self::$log_id);
Copy link
Contributor

Choose a reason for hiding this comment

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

this value is set on the testLogSearch test. So don't depend on that. The order of execution of this tests shouldn't be a premise. e.g. Running this test alone would fail. If you want to achieve something like that, merge both calls in a single test.

$search_results = self::$api->search();
$this->assertNotEmpty($search_results);

// Get the 10th log entry to test pagination in self::testLogSearchPagination().
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see this being used in the test testLogSearchPagination as this comment mentions. Anyway, it shouldn't depend on it. Please write tests that are independent from each other.

]);
$this->assertNotEmpty($search_results);
$this->assertNotEmpty($search_results[0]['date']);
$this->assertNotEmpty($search_results[0]['log_id']);
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you missing _id on purpose?

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 but not a good reason ... I'll add that :)

*
* @return void
*/
public function testLogSearchPagination()
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand how this one is "testing pagination". It only does a request and asserts that the response size is 10 items (per_page). Is not like other tests you've made before where you first ask for the first page of 2 items, and then ask for the second page of 1 items and compare that call 1[1].id==call 2[0].id

@joshcanhelp joshcanhelp force-pushed the add-tests-docs-pagination-logs branch from 0197314 to 25f6517 Compare June 28, 2018 18:56
'fields' => '_id,log_id',
'include_fields' => true,

// First page of 10 results.
Copy link
Contributor

Choose a reason for hiding this comment

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

comment should be 2 results

$this->assertCount($expected_count, $search_results_1);

// Now get one page of a single result and make sure it matches the second result above.
$expected_count = $expected_count / 2;
Copy link
Contributor

Choose a reason for hiding this comment

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

this math seems a little bit odd since changing the $expected_count value to something else will definitely mess up the whole test. I think it's clearer to just use "1" here and in the lines below. More straightforward

@joshcanhelp joshcanhelp force-pushed the add-tests-docs-pagination-logs branch from 25f6517 to a472085 Compare July 2, 2018 15:30
Copy link
Contributor

@lbalmaceda lbalmaceda left a comment

Choose a reason for hiding this comment

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

LGTM 👨‍🎓

@joshcanhelp joshcanhelp merged commit 8ce7ab5 into master Jul 2, 2018
@joshcanhelp joshcanhelp deleted the add-tests-docs-pagination-logs branch July 2, 2018 17:02
@github-actions
Copy link
Contributor

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants