Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed component check in test #15290

Merged
merged 1 commit into from
Aug 13, 2024
Merged

Fixed component check in test #15290

merged 1 commit into from
Aug 13, 2024

Conversation

marcusmoore
Copy link
Collaborator

Description

This PR follows up on #15172 and gets our tests back to green.

A few test cases were incorrectly referencing a component ID when the controller actually expects the id from the components_assets table.

Some details: It was a little tricky to track down because the tests would only fail when MySQL was used and multiple components were created during the test run. The reason is that sqlite re-uses IDs so the id used in the test, 1, would work since there existed a row with an id of 1 in components and components_assets tables. But MySQL keeps on incrementing when rows are deleted and since other tests created components, the result would be (something like) 8 being passed as the id in the route (because other tests had created 7 components previously) and a row with the id of 8 did not exist in the components_assets table.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

@marcusmoore marcusmoore requested a review from snipe as a code owner August 13, 2024 22:40
Copy link

what-the-diff bot commented Aug 13, 2024

PR Summary

  • Inclusion of a new library
    The use Illuminate\Support\Facades\DB; statement has been included in the ComponentCheckinTest.php file, which allows us to use database related functions in the file with less code, helping us increase speed and efficiency.

  • Updated 'testCheckingInComponentRequiresCorrectPermission' method
    The method in the ComponentCheckinTest.php file saw the addition of two lines of code. The first creates an instance of a Component that is checked out to an Asset. The second retrieves the first Asset related to this Component from the 'components_assets' database table. Also, a change was made to use this Asset's id as the componentID.

  • Method modifications in 'testComponentCheckinPagePostIsRedirectedIfRedirectSelectionIsIndex' and 'testComponentCheckinPagePostIsRedirectedIfRedirectSelectionIsItem'
    These methods in ComponentCheckinTest.php were updated to create a Component checked out to an Asset. The change also included replacing $component occurrences with $componentAsset for testing purposes. This helps in better validation of the component check-in functionality which increases the overall reliability of our system.

@snipe
Copy link
Owner

snipe commented Aug 13, 2024

Excellent sleuthing, thank you @marcusmoore!

@snipe snipe merged commit 7a6a2e3 into snipe:develop Aug 13, 2024
9 checks passed
@marcusmoore marcusmoore deleted the test-fixes branch August 13, 2024 23:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants