Skip to content

[Tests] Streamline #52365

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

Merged
merged 1 commit into from
Oct 31, 2023
Merged

[Tests] Streamline #52365

merged 1 commit into from
Oct 31, 2023

Conversation

OskarStark
Copy link
Contributor

@OskarStark OskarStark commented Oct 30, 2023

Q A
Branch? 5.4
Bug fix? no
New feature? no
Deprecations? no
Issues --
License MIT

Extracted from #52157

@OskarStark OskarStark requested a review from chalasr as a code owner October 30, 2023 10:16
@carsonbot carsonbot added this to the 5.4 milestone Oct 30, 2023
Comment on lines +35 to 53
public function testNoTwigTemplateActionMethod()
{
$controller = new TemplateController();

$this->expectException(\LogicException::class);
$this->expectExceptionMessage('You cannot use the TemplateController if the Twig Bundle is not available.');
$controller = new TemplateController();

$controller->templateAction('mytemplate')->getContent();
}

public function testNoTwigInvokeMethod()
{
$controller = new TemplateController();

$this->expectException(\LogicException::class);
$this->expectExceptionMessage('You cannot use the TemplateController if the Twig Bundle is not available.');

$controller('mytemplate')->getContent();
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should test both ways independently

@@ -125,8 +125,7 @@ public function testInvalidIpsInAccessControl()
$this->expectException(\LogicException::class);
$this->expectExceptionMessage('The given value "256.357.458.559" in the "security.access_control" config option is not a valid IP address.');

$client = $this->createClient(['test_case' => 'StandardFormLogin', 'root_config' => 'invalid_ip_access_control.yml']);
$client->request('GET', '/unprotected_resource');
$this->createClient(['test_case' => 'StandardFormLogin', 'root_config' => 'invalid_ip_access_control.yml']);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exception is thrown while creating the Client, no need to call request()

@@ -342,7 +342,7 @@ public function testPhpinfoActionWithProfilerDisabled()
$twig = $this->createMock(Environment::class);

$controller = new ProfilerController($urlGenerator, null, $twig, []);
$controller->phpinfoAction(Request::create('/_profiler/phpinfo'));
$controller->phpinfoAction();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

phpInfoAction has no parameter

@OskarStark
Copy link
Contributor Author

Ready to merge from my side

@OskarStark
Copy link
Contributor Author

@nicolas-grekas as PRs get bigger and bigger, can you please merge/upmerge this one? Thanks

Comment on lines -1022 to +1020
$table = new Table($output = $this->getOutputStream());
$table = new Table($this->getOutputStream());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused variable $output

$table
->setHeaders(['ISBN', 'Title', 'Author', 'Price'])
->setRows([
['99921-58-10-7', [], 'Dante Alighieri', '9.95'],
]);

$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('A cell must be a TableCell, a scalar or an object implementing "__toString()", "array" given.');

$table->render();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stof it seems, that this is no dead code, as the exception is raised when calling render() and not when calling setRows() 👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then in the other PR, keep setRows in initialization

@OskarStark OskarStark requested a review from stof October 31, 2023 07:27
@OskarStark
Copy link
Contributor Author

Fabbot looks unrelated

@OskarStark OskarStark requested a review from dunglas as a code owner October 31, 2023 07:49
@nicolas-grekas
Copy link
Member

Thank you @OskarStark.

@nicolas-grekas nicolas-grekas merged commit b26fdd0 into symfony:5.4 Oct 31, 2023
@OskarStark OskarStark deleted the fix/tests-4 branch October 31, 2023 08:06
nicolas-grekas added a commit that referenced this pull request Oct 31, 2023
…e expectation to avoid false positives (OskarStark)

This PR was merged into the 6.4 branch.

Discussion
----------

[Tests] Move `expectException` closer to the place of the expectation to avoid false positives

| Q             | A
| ------------- | ---
| Branch?       | 6.4
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | --
| License       | MIT

If you guys like this PR, I will fix the other places as well

Should be merged after merge & upmerge of:
* #52365

Commits
-------

6115ab0 [Tests] Move expectException closer to the place of the expectation to avoid false positives
@OskarStark OskarStark mentioned this pull request Nov 1, 2023
nicolas-grekas added a commit that referenced this pull request Dec 26, 2023
This PR was squashed before being merged into the 7.1 branch.

Discussion
----------

[Tests] Streamline

| Q             | A
| ------------- | ---
| Branch?       | 7.1
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Issues        | --
| License       | MIT

Follows
* #52157
* #52365

Commits
-------

33d71aa [Tests] Streamline
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants