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

(NFC) dev/core#2029 - Make assertions in PrevNextTest more skimmable #18822

Merged
merged 1 commit into from
Oct 21, 2020

Conversation

totten
Copy link
Member

@totten totten commented Oct 21, 2020

Overview

The test appears to have a random failure. Making it more readable may help figure out why.

Before

testDeleteByCacheKey() and the related testFillArray() both have some assertions in these two forms:

// Form #1, more verbose
$all = ...getSelections($cacheKey, $action = 'get');
$this->assertEquals([...expected...], array_keys($all)...);

// Form #2, more pithy
$this->assertSelections([...expected...], $action = 'get', $cacheKey = NULL);

After

The verbose form is replaced with the pithier form.

In the pithier form, some of the default inputs are made explicit.

Comment

It is confusing that the method getSelections() has a parameter $action which can be get or getall -- and that getall does not (in fact) return selections. It returns all! (The fact that the contract is weird makes the unit-test helpful imho...)

Overview
--------

The test appears to have a random failure. Making it more readable may help figure out why.

Before
------

`testDeleteByCacheKey()` and the related `testFillArray()` both have some assertions in these two forms:

```
// Form #1, more verbose
$all = ...getSelections($cacheKey, $action);
$this->assertEquals([...expected...], array_keys($all)...);

// Form #2, more pithy
$this->assertSelections([...expected...], $action, $cacheKey);
```

After
-----

The verbose form is replaced with the pithier form.

In the pithier form, some of the default inputs are made explicit.

Comment
-------

It is confusing that the method `getSelections()` has a parameter `$action`
which can be `get` or `getall` -- and that `getall` does not (in fact) return
selections.  It returns all!  (The fact that the contract is weird makes the
unit-test helpful imho...)
@civibot
Copy link

civibot bot commented Oct 21, 2020

(Standard links)

@civibot civibot bot added the master label Oct 21, 2020
@eileenmcnaughton eileenmcnaughton merged commit 54cded9 into civicrm:master Oct 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants