Commit Graph

44 Commits

Author SHA1 Message Date
dependabot[bot]
37a882118a
chore(deps): bump glob-parent from 3.1.0 to 5.1.2 in /extensions/emoji/js (#3345)
* chore(deps): bump glob-parent in /extensions/emoji/js

Bumps [glob-parent](https://github.com/gulpjs/glob-parent) from 3.1.0 to 5.1.2.
- [Release notes](https://github.com/gulpjs/glob-parent/releases)
- [Changelog](https://github.com/gulpjs/glob-parent/blob/main/CHANGELOG.md)
- [Commits](https://github.com/gulpjs/glob-parent/compare/v3.1.0...v5.1.2)

---
updated-dependencies:
- dependency-name: glob-parent
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

* Apply fixes from StyleCI

[ci skip] [skip ci]

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: StyleCI Bot <bot@styleci.io>
2022-03-11 18:11:20 -05:00
Alexander Skvortsov
ce7484e2c8 Extensions should be considered enabled after boot.
Before boot, we consider them "disabled" so they get migrated.
2021-05-11 19:31:35 -04:00
Alexander Skvortsov
d68d551e16 Ensure that migrations run 2021-05-11 17:15:11 -04:00
Alexander Skvortsov
148f810d96 Don't resolve routes early.
In normal Flarum, extensions are only enabled during requests. Here, however, we enable some during boot. This resolves the FilesystemManager early, which resolves the Url Generator early. To fix this, we directly provide a filesystem disk for assets instead of getting it from the filesystem manager.
2021-04-23 18:26:41 -04:00
Alexander Skvortsov
8fd1cc4f0d TestCase Config method (#13)
Similarly to `settings`, this allows setting/overriding config prior to application boot.
2021-04-14 16:27:59 -04:00
Alexander Skvortsov
76a869a198 Start transactions before the app is fully booted. (#11)
This make a cleaner state more likely, and ensures that settings set via `$this->setting` are cleaned up after the test case runs.
2021-04-12 10:26:05 -04:00
Alexander Skvortsov
675627ac15 Add a few more automated tests 2021-04-11 23:00:36 -04:00
Alexander Skvortsov
f13d45f77b Test against dev version of core
Since we're making changes for the dev version of core, we should test against that too.

For now, this fixes issues with the `extensions` method of `Installation` being undefined.
2021-04-11 22:47:09 -04:00
Alexander Skvortsov
9ed29cd35e Add automated tests for flarum/testing 2021-04-07 22:38:58 +01:00
Alexander Skvortsov
ba0fbd71e6 Move test infrastructure to Testing namespace in src directory 2021-01-13 01:27:05 -05:00
Alexander Skvortsov
1afbb07037 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-13 01:21:38 -05:00
Alexander Skvortsov
ab43c31ff5 Add @inheritDoc to all setUp and tearDown methods 2021-01-13 01:21:38 -05:00
Franz Liedke
6ca9191f42 Tests: Always start transaction before seeding 2021-01-13 01:21:38 -05:00
Franz Liedke
663f7a5d32 Tests: Stop using Eloquent models for seeding data 2021-01-13 01:21:38 -05:00
Franz Liedke
b1a18971ca Tests: Rely on admin user, groups, permissions from test setup script 2021-01-13 01:21:38 -05:00
Franz Liedke
31028e0bf9 Run integration tests in a transaction 2021-01-13 01:21:38 -05:00
Franz Liedke
d1462571ed Use Config class for data from config.php 2021-01-13 01:21:38 -05:00
Franz Liedke
99eeaf0be5 Clean up usages / deprecate path helpers (#2155)
* Write source map without creating temp file

Less I/O, and one less place where we access the global path helpers.

* Drop useless app_path() helper

This was probably taken straight from Laravel. There is no equivalent
concept in Flarum, so this should be safe to remove.

* Deprecate global path helpers

Developers using these helpers can inject the `Paths` class instead.

* Stop storing paths as strings in container

* Avoid using path helpers from Application class

* Deprecate path helpers from Application class

* Avoid using public_path() in prerequisite check

a) The comparison was already outdated, as a different path was passed.
b) We're trying to get rid of these global helpers.
2021-01-13 01:21:38 -05:00
Franz Liedke
3224aeabac Tests: Actually accept multiple extenders
We did pass multiple extenders to this method in the tests for the
`Model` extender - now this actually has the desired effect.
2021-01-13 01:21:38 -05:00
Franz Liedke
fe0159ecd1 Test setup: Do not use env() helper
Not needed, and not working without a full Laravel installation.
2021-01-13 01:21:38 -05:00
Franz Liedke
f45a1608df Split up Application and Container
- Stop trying to implement Laravel's Application contract, which
  has no value for us.
- Stop inheriting from the Container, injecting one works equally
  well and does not clutter up the interfaces.
- Inject the Paths collection instead of unwrapping it again, for
  better encapsulation.

This brings us one step closer toward upgrading our Laravel
components (#2055), because we no longer need to adopt the changes
to the Application contract.
2021-01-13 01:21:38 -05:00
Alexander Skvortsov
915a428973 Add console extender (#2057)
* Made the console command system extender-friendly

* Added console extender

* Added ConsoleTestCase to integration tests

* Added integration tests for console extender

* Marked event-based console extension system as deprecated

* Moved trimming command output of whitespace into superclass

* Renamed 'add' to 'command'

* Added special processing for laravel commands

* Code style fixes

* More style fixes

* Fixed $this->container
2021-01-13 01:21:38 -05:00
Franz Liedke
21f4c3f6dd Apply fixes from StyleCI
[ci skip] [skip ci]
2021-01-13 01:21:38 -05:00
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