Commit Graph

119 Commits

Author SHA1 Message Date
Alexander Skvortsov
c1aa1455d3 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
ae280016e7 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
0a8816938a Add @inheritDoc to all setUp and tearDown methods 2021-01-09 00:35:55 -05:00
Franz Liedke
008ec95505 Boot app explicitly to run seeds in time 2021-01-09 00:35:47 -05:00
Franz Liedke
cacc8b4945 Tests: Always start transaction before seeding 2021-01-07 17:34:13 -05:00
Franz Liedke
31765388c1 Tests: Stop using Eloquent models for seeding data 2021-01-07 17:34:13 -05:00
Franz Liedke
a08fd3e475 Tests: Rely on admin user, groups, permissions from test setup script 2021-01-07 17:34:06 -05:00
Franz Liedke
a47187462d Tests: DB tables no longer need to be truncated 2021-01-05 22:48:09 -05:00
Franz Liedke
843a149b80 Run integration tests in a transaction 2021-01-05 22:47:19 -05:00
Sami Mazouz
a2d5dd3397
Add default value to Settings extender (#2495) 2021-01-05 01:28:25 -05:00
Alexander Skvortsov
d1dfa758e4
Policy Extender and Tests (#2461)
Policy application has also been refactored, so that policies return one of `allow`, `deny`, `forceAllow`, `forceDeny`. The result of a set of policies is no longer the first non-null result, but rather the highest priority result (forceDeny > forceAllow > deny > allow, so if a single forceDeny is present, that beats out all other returned results). This removes order in which extensions boot as a factor.
2020-12-08 19:10:06 -05:00
Alexander Skvortsov
8901073d12
Model Visibility Scoping Extender and Tests (#2460) 2020-12-07 20:02:46 -05:00
Matt Kilgore
4679448300
Slug Driver Support (#2456)
- Support slug drivers for core's sluggable models, easily extends to other models
- Add automated testing for affected single-model API routes
- Fix nickname selection UI
- Serialize slugs as `slug` attribute
- Make min search length a constant
2020-12-07 13:33:42 -05:00
Sami Mazouz
51a97fb12e
ApiController Extender and Tests (#2451) 2020-12-06 15:07:48 -05:00
Sami Mazouz
cfa533ebd6
Add Settings Extender (#2452) 2020-12-04 17:20:06 -05:00
Alexander Skvortsov
eed407812f
User Preferences Extender and Tests (#2463) 2020-12-04 15:45:08 -05:00
Alexander Skvortsov
984f751c71
Use process isolation for integration tests 2020-12-01 19:33:24 -05:00
Sami Mazouz
8c813bc340
ApiSerializer Extender (#2438) 2020-11-30 19:24:50 -05:00
Alexander Skvortsov
1a5e4d454e
Move floodgate to middleware, add extender + integration tests (#2170) 2020-11-29 17:13:22 -05:00
Alexander Skvortsov
0c95774333
Refactor Route Resolving and Dispatch (#2425)
- Split DispatchRoute. This allows us to run middleware after we figure out which route we're on, but before we actually execute the controller for that route.
- By making the route name explicitly available to middlewares, applications like CSRF and floodgate can set patterns based on route names instead of the path, which is an implementation detail.
- Support using route name match for CSRF extender, deprecate path match
2020-11-10 12:52:12 -05:00
Alexander Skvortsov
47d2eee9ce
Fix Callables for Extenders (#2423)
- Standardize signatures and variable names for extenders that take callbacks
- Adjust model extender docblock to clarify that default calue can't be an invokable class.
- Make invokable classes provided to Model->relationship
- Add integration tests to ensure Model->relationship and User->groupProcessor extenders accept callbacks
- Extract code for wrapping callbacks into central util
2020-11-08 21:36:38 -05:00
Sami Mazouz
529d2edcaf
Add Service Provider Extender (#2437) 2020-11-06 13:30:10 -05:00
Sami Mazouz
f0e77a5789
Add Notification Channel Extender (#2432) 2020-11-05 12:09:06 -05:00
Alexander Skvortsov
87c258b2f8
Refactor and improve formatter extender (#2098)
- Deprecated all events involved with Formatter
- Refactor ->configure() method on extender not to use events
- Add extender methods for ->render() and ->parse()
- Add integration tests
2020-11-03 13:05:33 -05:00
Alexander Skvortsov
cee87848fe
Added post extender with type method, deprecated ConfigurePostTypes (#2101) 2020-11-03 10:43:49 -05:00
Alexander Skvortsov
5842dd1200
Validator extender (#2102)
Added validator extender, integration tests, and deprecated related Validating event
2020-11-01 11:31:16 -05:00
Sami Mazouz
b311512502
Add Notification Type Extender and Tests (#2424) 2020-10-31 17:17:14 -04:00
Daniël Klabbers
561e8c6b6a Add test for model object argument in callable for attribute defaults 2020-10-07 11:38:52 +02:00
Alexander Skvortsov
97c36f2f7d Use Symfony TranslatorInterface for tests
This seems to be a leftover change missed in https://github.com/flarum/core/pull/2243
2020-10-05 16:02:12 -04:00
Franz Liedke
9ea57e6329
Use Config class for data from config.php 2020-09-25 11:10:52 +02:00
Alexander Skvortsov
6d38de9c8f
Revert https://github.com/flarum/core/pull/1536 (#2305) 2020-09-24 11:30:27 -04:00
Alexander Skvortsov
37ebeb5705
User Extender (prepareGroups functionality) (#2110) 2020-07-17 12:18:35 +02:00
Franz Liedke
71abac0323
Rename view extender
As discussed in my initial review, it seems unlikely that we need
the ability to remove (or otherwise modify) namespaces again.
Therefore, it seems more consistent with other extenders to go
for a "View" extender with a "namespace" method.

Sorry for the back and forth. ;)

Refs #1891, #2134.
2020-07-17 12:05:49 +02:00
Alexander Skvortsov
b5e891df30
View Extender (add namespace) (#2134) 2020-07-17 11:59:00 +02:00
Franz Liedke
88366fe8af
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.
2020-06-19 16:16:03 -04:00
Alexander Skvortsov
d1750fecc0
Send Test Mail Feature (#2023)
- Add UI, backend for sending test emails
- Change mail settings endpoint to /api/mail/settings
2020-05-30 22:49:36 -04:00
Franz Liedke
c4f4f218bf
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.
2020-05-23 02:00:25 +02:00
Franz Liedke
4866e7d9ba
Stop using app() helper in tests 2020-05-23 01:56:21 +02:00
Alexander Skvortsov
b0822df759
Use drivers for display names, add display name extender (#2174)
* Deprecate GetDisplayName event

* Add interface for display name driver

* Add username driver as default

* Add code to register supported drivers / used driver as singletons

* Configured User class to use new driver-based system for display names

* Add extender for adding display name driver

* Add integration test for user display name driver

* Add frontend UI for selecting display name driver
2020-05-19 18:45:56 -04:00
Franz Liedke
484933db7d
Test setup: Do not use env() helper
Not needed, and not working without a full Laravel installation.
2020-05-08 23:30:17 +02:00
Franz Liedke
365eb15d29
Merge pull request #2142 from flarum/fl/2055-prepare-for-laravel-58
Split up Application and Container
2020-05-07 22:49:36 +02:00
Franz Liedke
a9470b463f Make two more tests compatible with PHPUnit 8 2020-05-07 09:18:04 +02:00
Franz Liedke
41a56c4ad1
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.
2020-05-01 15:47:35 +02:00
Alexander Skvortsov
7794546845
Model extender: Fix inheritance (#2132)
This ensures that default values, date attributes and relationships are properly inherited, when we have deeper model class hierarchies.

This also adds test cases to ensure that inheritance order is honored for relationship and default attribute extender. As there's no way to remove date attributes, the order of evaluation there doesn't matter.
2020-04-24 21:17:31 +02:00
Franz Liedke
c43cc874ee
Model extender: Add failing test
We determined that child classes are not properly affected when
extending the parent classes.

Refs #2100.
2020-04-24 17:54:30 +02:00
Franz Liedke
33cf94c192
Fix test to match its description
Refs #2100.
2020-04-24 17:31:08 +02:00
Franz Liedke
036e519865 Apply fixes from StyleCI
[ci skip] [skip ci]
2020-04-24 14:56:37 +00:00
Franz Liedke
9386c91af9
Tweak model extender tests
- Format code
- Reorder methods
- Test a different scenario to avoid the use of sleep()

Refs #2100.
2020-04-24 16:55:04 +02:00
Alexander Skvortsov
15bed971e6
Add model extender (#2100)
This covers default attribute values, date attributes and custom relationships.
2020-04-24 15:10:24 +02:00
Alexander Skvortsov
6e8884f190
Implement hidden permission groups (#2129)
Only users that have the new `viewHiddenGroups` permissions will be able to see these groups.

You might want this when you want to give certain users special permissions, but don't want to make your authorization scheme public to regular users.

Co-authored-by: luceos <daniel+github@klabbers.email>
2020-04-21 17:49:53 +02:00