Commit Graph

8565 Commits

Author SHA1 Message Date
Franz Liedke
30450687b9 Replace authenticatedRequest() by request() option
I feel this makes the parameters a bit more clear, does not rely on
inheritance (you can only inherit from one class, but we might want more
of these helpers in the future), and has less side effects (e.g. no
creation and, more importantly, deletion of users in the database).

Refs #2052.
2021-01-13 01:21:38 -05:00
Franz Liedke
0c4ab20b50 Tests: Extract trait for building requests 2021-01-13 01:21:38 -05:00
Alexander Skvortsov
232a431b50 Add Authenticated Test Case utility 2021-01-13 01:21:38 -05:00
Franz Liedke
b0711b18c7 Integration tests: Allow registering extenders 2021-01-13 01:21:38 -05:00
Franz Liedke
23ad5bcc6b Integration tests: Add lazy server helper
This allows sending requests directly in an integration test, without
having *explicitly* booted the app.
2021-01-13 01:21:38 -05:00
Franz Liedke
1ca610d96a Integration tests: Create app lazily when needed
This will allow registering extenders in test scenarios. Previously,
this would not have had any effect as the app would have booted already.
2021-01-13 01:21:38 -05:00
Matt Kilgore
924a2e5efa Change Zend namespace to Laminas (#1963)
Also ensure backwards compatibility for extensions that use the Zend framework but don't explicitly require it.
2021-01-13 01:21:38 -05:00
Franz Liedke
48d996d948 Apply fixes from StyleCI
[ci skip] [skip ci]
2021-01-13 01:21:38 -05:00
Franz Liedke
c869417759 Automatically set up Mockery for unit tests
- Use provided PhpUnit listener to enforce verification of expectations.
- Include Mockery's trait to auto-close Mockery after each test.
2021-01-13 01:21:38 -05:00
Stefan Totev
3decf1b658 Normalize Base URL during installation
- Fix base url when is appended with a script filename
- Add default base url http://flarum.local when CLI wizard used
- Remove some code duplication
- Add minor improvement to the UX when CLI wizard used
- Add tests
- Extract base url normalisation into its own value object
2021-01-13 01:21:38 -05:00
Daniël Klabbers
93d6b235e3 fixed tests on master, missing views directory and suppressing notices from tempnam when storing files in tmp 2021-01-13 01:21:38 -05:00
Daniël Klabbers
c772029af9 Apply fixes from StyleCI (#1800)
[ci skip] [skip ci]
2021-01-13 01:21:38 -05:00
Daniël Klabbers
f47d739aac Using a different setting key now, so that it won't break tests whenever you re-run them once smtp is set.
Fixed, badly, the test to create users etc caused by the prepareDatabase flushing all settings by default.
2021-01-13 01:21:38 -05:00
Daniël Klabbers
f686fd3e57 Fixed issue with tmp/storage/views not existing, this caused tmpname to notice.
Fixed csrf test that assumed an access token allows application access, which is actually api token.
Improved return type hinting in the StartSession middleware
2021-01-13 01:21:38 -05:00
Franz Liedke
c5d042929f Refactor tests to shorten HTTP requests
Multiple tests now provide JSON request bodies, and others copy cookies
from previous responses, so let's provide convenient helpers for these.
2021-01-13 01:21:38 -05:00
Franz Liedke
05b4d8076b Integration tests: Configure vendor path
Now that this is possible, make the easy change...
2021-01-13 01:21:38 -05:00
Franz Liedke
e6d4c66933 Integration tests: Memoize request handler as well
This is useful to send HTTP requests (or their PSR-7 equivalents)
through the entire application's middleware stack (instead of
talking to specific controllers, which should be considered
implementation detail).
2021-01-13 01:21:38 -05:00
Franz Liedke
e20961dabc Integration tests: Fix test setup 2021-01-13 01:21:38 -05:00
Franz Liedke
cc3d0d6d0a Add helpful (?) output to test setup script 2021-01-13 01:21:38 -05:00
Franz Liedke
d90b77073e Setup Composer commands for testing and setup 2021-01-13 01:21:38 -05:00
Toby Zerner
0b657c0b4c Restore Initial Meaningful Test Infrastructure
This testing package was initially a part of flarum/core, but was
extracted during the 0.1.0-beta.16 release cycle. The extraction was
made through git's filter-branch tool to preserve some useful history in
the repository.
2021-01-13 01:21:33 -05:00
SychO9
5291c969a4 Null positions refer to secondary tags 2021-01-12 21:28:44 -05:00
SychO9
550a04df83 Use the correct setting keys 2021-01-12 21:28:44 -05:00
Alexander Skvortsov
c1778d5dd6 Merge pull request #2304 from flarum/fl/tests-in-transaction
Run Backend Tests in Transactions
2021-01-12 21:26:59 -05:00
Alexander Skvortsov
a5a8b075dd Apply fixes from StyleCI
[ci skip] [skip ci]
2021-01-09 00:36:07 -05:00
Alexander Skvortsov
54e0d1b7da Fix fulltext search tests
Under InnoDB, database entries created in transactions are not processed by fulltext indexes until the transaction is committed. To work around this, cases that test fulltext search have been split off into a separate class that adds and removes seed discussions/posts outside of transactions during setUp/tearDown.
2021-01-09 00:35:55 -05:00
Alexander Skvortsov
7c0d98c63d Tests: purge settings cache
Some tests need to change settings, but since MemoryCacheSettingsRepository caches settings in-memory, those changes aren't reflected. The new `purgeSettingsCache` removes it from the container, eliminating that cache.

For UserTest, we also need to regenerate the display name driver, since that's set statically on boot, before we'll get a change to clear the settings cache.
2021-01-09 00:35:55 -05:00
Alexander Skvortsov
eeac5ffce9 Tests: Add missing instantiation of data 2021-01-09 00:35:55 -05:00
Alexander Skvortsov
17e2dc21ec Tests: Comply with default permissions
Before transactions, each test class would need to explicitly state starting state for permissions, which made the initial permission configuration somewhat arbitrary. Now, we might as well use the initial state of the default installation.

One of the User show_test tests has been commented out until
2021-01-09 00:35:55 -05:00
Alexander Skvortsov
b92695a9c2 Tests: remove prepDb workaround
Previously, the `prepareDatabase` method would directly modify the database, booting the app in the process. This would prevent any extenders from being applied, since `->extend()` has no effect once the app is booted.

Since the new implementation of `prepareDatabase` simply registers seed data to be applied during app boot, the workaround of sticking this seed data into `prepDb` is no longer necessary, and seed data common to all test cases in a class can be provided in `setUp`.

When needed, app boot is explicitly triggered in individual test cases by calling `$this->app()`.
2021-01-09 00:35:55 -05:00
Alexander Skvortsov
823e6cbd2e Add @inheritDoc to all setUp and tearDown methods 2021-01-09 00:35:55 -05:00
Franz Liedke
450ca99325 Boot app explicitly to run seeds in time 2021-01-09 00:35:47 -05:00
Alexander Skvortsov
d5bf544668 Add vscode config to gitignore 2021-01-07 23:27:32 -05:00
Alexander Skvortsov
a1a2598c03 Fix deleting posts/discussions by deleted user (#2521)
Making the $user argument nullable prevents this unnecessary exception, and doesn't introduce any issues since we check that $user exists as part of the method.
2021-01-07 17:46:14 -05:00
Franz Liedke
956050c643 Tests: Always start transaction before seeding 2021-01-07 17:34:13 -05:00
Franz Liedke
9b2383fe20 Tests: Stop using Eloquent models for seeding data 2021-01-07 17:34:13 -05:00
Franz Liedke
1b98526e89 Tests: Rely on admin user, groups, permissions from test setup script 2021-01-07 17:34:06 -05:00
flarum-bot
403ee77c6c Bundled output for commit f6478096ee [skip ci] 2021-01-07 15:26:14 +00:00
flarum-bot
293b2e31cf Bundled output for commit b222856744 [skip ci] 2021-01-07 15:25:43 +00:00
Sami Mazouz
f6478096ee Fix composer header hidden by mobile browser (#2279) 2021-01-07 10:25:12 -05:00
Alexander Skvortsov
b222856744 Add an onFollowing param to GlobalSearchState (#38)
Add an `onFollowing` param to GlobalSearchState

This ensures that it will be taken into account by IndexPage's `refreshParams` call, preventing the following page from being shown if the user:

1. goes to following
2. goes to any other page not inheriting IndexPage
3. goes to 'all discussions'

Ref https://github.com/flarum/core/issues/2516 for a full explanation.
2021-01-07 10:24:41 -05:00
Franz Liedke
a42ce7045d Tests: DB tables no longer need to be truncated 2021-01-05 22:48:09 -05:00
Franz Liedke
b14da91a98 Run integration tests in a transaction 2021-01-05 22:47:19 -05:00
Alexander Skvortsov
fb7ffc2351 Fix IOS scroll menu bug (#2527)
Fixes https://github.com/flarum/core/issues/1959

These transform lines are known to cause issues on iOS, and were added to hack around chrome issues that have since been fixed upstream.
2021-01-05 19:40:11 -05:00
flarum-bot
ed6035c674 Bundled output for commit 3b838dfd01 [skip ci] 2021-01-05 21:41:50 +00:00
SKmedix
3b838dfd01 🐛 Make sure summed value is a number (#14) 2021-01-05 16:41:00 -05:00
Sami Mazouz
111f615c60 Add default value to Settings extender (#2495) 2021-01-05 01:28:25 -05:00
Robert Korulczyk
be9d498614 Register locale extender to refresh translations after enabling extension (#2) 2020-12-23 16:10:51 -05:00
Qiaeru
135c662cf7 Fix some typos (#181) 2020-12-23 15:05:09 -05:00
Ian Morland
d368aa4e55 Fix incorrect display_name showing in email notifications (#59) 2020-12-21 12:43:27 -05:00