-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Fix for issue #17901 - improvements in fragment handling and unittesting #17954
base: 5.next
Are you sure you want to change the base?
Conversation
BEFICENT
commented
Oct 8, 2024
if ($name[0] == '/') { | ||
$path = "..{$name}"; | ||
} else { | ||
$path = "..{$this->name}/{$name}"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the $this->name
is not correct IMO. For e.g. if the current controller name is Admins
but the template path is set to Users
then I would expect it to look for the fragment under Users
folder.
The View class is also used for rendering emails and cell where the name
property is irrelevant/empty.
"phpunit/phpunit": "^10.5.5 || ^11.1.3" | ||
"phpstan/phpstan": "1.12.3", | ||
"phpunit/phpunit": "^10.5.5 || ^11.1.3", | ||
"squizlabs/php_codesniffer": "^3.10", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we omit this. We don't need to change dependencies to add view methods.
->getMock(); | ||
|
||
// Set up the element method to return the stored fragment data | ||
$this->View->expects($this->any()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would avoid using mocks for this. Instead add more templates to the test application and use those for your tests. Our test suite is more reliable and easier to understand if we use fewer mocks and have more 'integration tests' that use the framework like applications would.
|
||
// Verify that the fragment is cleared by checking the stored fragment | ||
$clearedResult = $this->View->fragment('testFragment'); | ||
echo 'Cleared fragment: ' . $clearedResult . "\n"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests shouldn't be generating output.