Repository navigation
Fixes and improvements to tests - #1258
Draft
outdooracorn wants to merge 9 commits into
Draft
outdooracorn wants to merge 9 commits into
outdooracorn wants to merge 9 commits into
Conversation
outdooracorn
added this pull request to stack #1259
September 21, 2026 03:50
outdooracorn
marked this pull request as draft
October 8, 2026 14:56
outdooracorn
force-pushed
the
ollie-fixes-and-improvements
branch
from
October 8, 2026 14:59
83ed93d to
4ea19a9
Compare
* Make the `verified` attribute defualt to `true`, as that is what is used everywhere * Remove `'verified' => true` from all references of `User::factory()` * Add an `unverified()` method for easily setting `verified` to `false * Add an `admin` method for easily setting `is_admin` to `1` * Add type declarations to method parameters and return values
Use the `DatabaseTransactions` trait to keep the tests from poluting the database rather than manually removing *all* `Wiki`s and `WikiDb`s from the database in the `tearDown()` method. `Wiki::query()->delete();` doesn't even clean the database properly as `Wiki`s are soft-deleted. The `->forceDelete()` method should have been used.
Quick fix to prevent the test from polluting the database with a soft-deleted `Wiki`. This test, and the `PlatformStatsSummaryJob` it is testing, should be improved so that wiping the whole database after each test isn't required.
Add `DatabaseTransactions` trait to `LogoUpdateTest` to prevent it from polluting the database
* Add the `DatabaseTransactions` trait to prevent it from polluting the database * Remove the `setUp()` method as this test shouldn't be responsible for cleaning up after other tests * Remove the `tearDown()` method as the database isn't polluted when the `DatabaseTransactions` trait is used
* Fix tests creating `Wiki`s with invalid `user_id` of `0` * Remove the `setUp()` method as `DeletedWikiMetricsControllerTest` shouldn't be responsible for cleaning up after other tests * Remove the `tearDown()` method as `DeletedWikiMetricsControllerTest` doesn't pollute the database * Simplify signature and implementation of `createAndDeleteTestWiki()` to remove functionality not used by the test * Make use of `User::factory()` rather than reimplementing logic in the TestCase * Replace `private function createUserWithPrivileges()` with the `UserFactory::admin()` method * Refactor out the requests to `auth/login` by using `->actingAs()` on the requests under test * Rely on the `Wiki::factory()` to set the `sitename` attribute * Add type declarations to method parameters and return values * Inline variables that are only used once * Rename test methods for clarity
outdooracorn
force-pushed
the
ollie-fixes-and-improvements
branch
from
October 8, 2026 15:01
4ea19a9 to
e6f0bf4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.