Backpack URLs (web and API) can have up to 255. However, the form
for creating/editing them, doesn't allow URLs with more than 50
characters. This patch align limitation to DB value (255).
Manage backpacks page wasn't displaying the navigation and administration
menus when using classic theme (it's unrelated to changes done here).
This patch fixes this unexpected behaviour (raised thanks to behat tests).
In all cases changes have been kept to a minimum while not making
the code completely horrible. For example, there are many instances
where it would probably be better to rewrite a query entirely, but
I have not done that (in order to reduce the risk of changes).
The $CFG->badges_site_backpack setting has been completely removed
because it's not required anymore. From now, the primary site
backpack will be the first one in the "Manage backpacks" list (so,
the one with lower sortorder value).
Before removing $CFG->badges_site_backpack setting, admins should be
able to re-order the existing site-backpacks (because then, the first
one will be treated as the default one).
This patch adds the sort order feature to the backpack list.
Setting "External backpack connection" has been moved from "Backpack
settings" to "Badges settings" in order to make easier to find and
configure it.
Some extra tests have been added to cover existing behaviour and
confirm is still working as expected.
Some of the current behat tests were wrong but not failing because of the bug in 'should not exist' step.
Once the bug is fixed, we must fix also wrong behats.
Sortorder field in badge_external_backpack was updated with a wrong
value. This patch fixes this behaviour and adds sortorder as
sorting criteria for displaying the list of site backpacks.
In the phpunit method reviewed for covering this, a couple of
assertEquals() calls have been changed too to put the expected value
first.
High-resolution image for a badge (f3) should be sent to external
backpacks through JSON and WS methods.
Besides, when a badge is cloned, the high-resolution image should be
used to avoid the copied looks blurry.
File badges/oauth2callback.php has been removed and now badges
API will use admin/oauth2callback.php because it makes no sense having
it twice.
Credits go to Andrew Nicols for raising it!
Having mixed $data in badge exporters is causing some issues.
As all these exporters are using $data as an object, $data can be
converted to object in the constructor, to avoid errors and get
the expected behaviour always.
When 2 or more backpack were created without credentials,
a "Duplicate key value violates unique constraint" error
was raised because externalbackpackid was not taking the
correct value.
Other improvements have been done to the code too in order
to make it more readable.
With PHPUnit 8 a good number of assertions, all them related with
operations on non-public attributes have been deprecated. And will
be removed with PHPUnit 9.
The main point is that unit tests shouldn't be testing non-public
APIs (good practice) and those assertions were an error originally.
See https://github.com/sebastianbergmann/phpunit/issues/3338 for
the complete list and other details.
When possible (the attributes being checked are public), the change
is simple, just switching to normal assertions.
When the attributes are not public we need to find a workaround
to be able to test the same using public APIs, or use Reflection,
or remove the tests.
For the records, this is the regexp used to find all the cases:
ag '>(assertAttribute|attribute\(|readAttributte|getStaticAttribute| \
getObjectAttribute)' -G "test.php"
While this is not strictly required, because removal will
happen in PHPUnit 9.0, we are already getting rid of all
uses in core.
From release notes:https://phpunit.de/announcements/phpunit-8.html
assertInternalType() is deprecated and will be removed in
PHPUnit 9. Refactor your test to use assertIsArray(), assertIsBool(),
assertIsFloat(), assertIsInt(), assertIsNumeric(), assertIsObject(),
assertIsResource(), assertIsString(), assertIsScalar(),
assertIsCallable(), or assertIsIterable() instead.
All the setup/teardown/pre/post/conditions template methods
now are required to return void. This was warned with phpunit 7
and now is enforced.
At the same time, fix a few wrong function names,
provider data and param types, return statements...
Instead of running the site backpack validation every time badges/backpacks.php
page is loaded, an action button has been added to the backpacks with OB set
to 2.0 to let admins running manually this verification when needed.
A more generic method has been added to the API to validate the
backpack connection (for now, there was only one method for
validating current backpack).
Besides, a renderer has been added to display this information
depending on the backpackid.
In MDL-68746 issuer details fields were removed from the badges
form, because they are filled from the site settings.
This is a regression because these fields should be removed also
from the edit page.