Skip to content

Commit

Permalink
Fix PHPStan errors for PHPUnit assert methods
Browse files Browse the repository at this point in the history
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
  • Loading branch information
MauricioFauth committed Aug 10, 2020
1 parent c33d35f commit ba09c84
Show file tree
Hide file tree
Showing 19 changed files with 87 additions and 125 deletions.
105 changes: 0 additions & 105 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -2965,11 +2965,6 @@ parameters:
count: 1
path: test/classes/Config/DescriptionTest.php

-
message: "#^Parameter \\#2 \\$haystack of method PHPUnit\\\\Framework\\\\Assert\\:\\:assertStringContainsString\\(\\) expects string, null given\\.$#"
count: 5
path: test/classes/Config/FormDisplayTest.php

-
message: "#^Parameter \\#1 \\$str of function strip_tags expects string, string\\|false given\\.$#"
count: 1
Expand Down Expand Up @@ -3010,16 +3005,6 @@ parameters:
count: 1
path: test/classes/FileTest.php

-
message: "#^Parameter \\#1 \\$expected of method PHPUnit\\\\Framework\\\\Assert\\:\\:assertInstanceOf\\(\\) expects class\\-string\\<object\\>, string given\\.$#"
count: 1
path: test/classes/Gis/GisFactoryTest.php

-
message: "#^Unable to resolve the template type ExpectedType in call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertInstanceOf\\(\\)$#"
count: 1
path: test/classes/Gis/GisFactoryTest.php

-
message: "#^Call to an undefined method object\\:\\:generateParams\\(\\)\\.$#"
count: 2
Expand Down Expand Up @@ -3085,96 +3070,31 @@ parameters:
count: 1
path: test/classes/LanguageTest.php

-
message: "#^Parameter \\#2 \\$haystack of method PHPUnit\\\\Framework\\\\Assert\\:\\:assertStringContainsString\\(\\) expects string, string\\|false given\\.$#"
count: 1
path: test/classes/Navigation/NavigationTreeTest.php

-
message: "#^Parameter \\#2 \\$name of static method PhpMyAdmin\\\\Navigation\\\\NodeFactory\\:\\:getInstance\\(\\) expects string, array\\<string, string\\> given\\.$#"
count: 1
path: test/classes/Navigation/Nodes/NodeColumnTest.php

-
message: "#^Parameter \\#2 \\$haystack of method PHPUnit\\\\Framework\\\\Assert\\:\\:assertStringContainsString\\(\\) expects string, string\\|false given\\.$#"
count: 4
path: test/classes/Plugins/Auth/AuthenticationConfigTest.php

-
message: "#^Parameter \\#2 \\$haystack of method PHPUnit\\\\Framework\\\\Assert\\:\\:assertStringContainsString\\(\\) expects string, string\\|false given\\.$#"
count: 1
path: test/classes/Plugins/Auth/AuthenticationHttpTest.php

-
message: "#^Parameter \\#2 \\$haystack of method PHPUnit\\\\Framework\\\\Assert\\:\\:assertStringContainsString\\(\\) expects string, string\\|false given\\.$#"
count: 1
path: test/classes/Plugins/Auth/AuthenticationSignonTest.php

-
message: "#^Parameter \\#1 \\$version1 of function version_compare expects string, string\\|false given\\.$#"
count: 1
path: test/classes/Plugins/Auth/AuthenticationSignonTest.php

-
message: "#^Parameter \\#2 \\$haystack of method PHPUnit\\\\Framework\\\\Assert\\:\\:assertStringContainsString\\(\\) expects string, string\\|false given\\.$#"
count: 4
path: test/classes/Plugins/Export/ExportCodegenTest.php

-
message: "#^Parameter \\#1 \\$string of function htmlspecialchars_decode expects string, string\\|false given\\.$#"
count: 1
path: test/classes/Plugins/Export/ExportHtmlwordTest.php

-
message: "#^Parameter \\#2 \\$haystack of method PHPUnit\\\\Framework\\\\Assert\\:\\:assertStringContainsString\\(\\) expects string, string\\|false given\\.$#"
count: 5
path: test/classes/Plugins/Export/ExportLatexTest.php

-
message: "#^Parameter \\#2 \\$haystack of method PHPUnit\\\\Framework\\\\Assert\\:\\:assertStringContainsString\\(\\) expects string, string\\|false given\\.$#"
count: 3
path: test/classes/Plugins/Export/ExportPhparrayTest.php

-
message: "#^Parameter \\#2 \\$haystack of method PHPUnit\\\\Framework\\\\Assert\\:\\:assertStringContainsString\\(\\) expects string, string\\|false given\\.$#"
count: 35
path: test/classes/Plugins/Export/ExportSqlTest.php

-
message: "#^Parameter \\#2 \\$haystack of method PHPUnit\\\\Framework\\\\Assert\\:\\:assertStringContainsString\\(\\) expects string, string\\|false given\\.$#"
count: 3
path: test/classes/Plugins/Export/ExportTexytextTest.php

-
message: "#^Parameter \\#2 \\$haystack of method PHPUnit\\\\Framework\\\\Assert\\:\\:assertStringContainsString\\(\\) expects string, string\\|false given\\.$#"
count: 11
path: test/classes/Plugins/Export/ExportXmlTest.php

-
message: "#^Parameter \\#2 \\$haystack of method PHPUnit\\\\Framework\\\\Assert\\:\\:assertStringContainsString\\(\\) expects string, string\\|false given\\.$#"
count: 1
path: test/classes/Plugins/Export/ExportYamlTest.php

-
message: "#^Parameter \\#1 \\$subgroupHeader of method PhpMyAdmin\\\\Properties\\\\Options\\\\Groups\\\\OptionsPropertySubgroup\\:\\:setSubgroupHeader\\(\\) expects PhpMyAdmin\\\\Properties\\\\PropertyItem, string given\\.$#"
count: 1
path: test/classes/Properties/Options/Groups/OptionsPropertySubgroupTest.php

-
message: "#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertNull\\(\\) with void will always evaluate to false\\.$#"
count: 1
path: test/classes/Properties/Options/OptionsPropertyGroupTest.php

-
message: "#^Parameter \\#1 \\$property of method PhpMyAdmin\\\\Properties\\\\Options\\\\OptionsPropertyGroup\\:\\:addProperty\\(\\) expects PhpMyAdmin\\\\Properties\\\\Options\\\\OptionsPropertyItem, int given\\.$#"
count: 1
path: test/classes/Properties/Options/OptionsPropertyGroupTest.php

-
message: "#^Result of method PhpMyAdmin\\\\Properties\\\\Options\\\\OptionsPropertyGroup\\:\\:addProperty\\(\\) \\(void\\) is used\\.$#"
count: 1
path: test/classes/Properties/Options/OptionsPropertyGroupTest.php

-
message: "#^Parameter \\#1 \\$property of method PhpMyAdmin\\\\Properties\\\\Options\\\\OptionsPropertyGroup\\:\\:addProperty\\(\\) expects PhpMyAdmin\\\\Properties\\\\Options\\\\OptionsPropertyItem, string given\\.$#"
count: 1
Expand All @@ -3190,26 +3110,6 @@ parameters:
count: 1
path: test/classes/Properties/Options/OptionsPropertyOneItemTest.php

-
message: "#^Parameter \\#1 \\$needle of method PHPUnit\\\\Framework\\\\Assert\\:\\:assertStringContainsString\\(\\) expects string, bool\\|string given\\.$#"
count: 1
path: test/classes/Server/PrivilegesTest.php

-
message: "#^Parameter \\#2 \\$haystack of method PHPUnit\\\\Framework\\\\Assert\\:\\:assertStringContainsString\\(\\) expects string, string\\|false given\\.$#"
count: 4
path: test/classes/Setup/FormProcessingTest.php

-
message: "#^Parameter \\#1 \\$expected of method PHPUnit\\\\Framework\\\\Assert\\:\\:assertInstanceOf\\(\\) expects class\\-string\\<object\\>, string given\\.$#"
count: 1
path: test/classes/StorageEngineTest.php

-
message: "#^Unable to resolve the template type ExpectedType in call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertInstanceOf\\(\\)$#"
count: 1
path: test/classes/StorageEngineTest.php

-
message: "#^Parameter \\#1 \\$str of function trim expects string, string\\|null given\\.$#"
count: 1
Expand Down Expand Up @@ -3310,11 +3210,6 @@ parameters:
count: 1
path: test/classes/TrackingTest.php

-
message: "#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertInstanceOf\\(\\) with 'PhpMyAdmin\\\\\\\\Message' and true will always evaluate to false\\.$#"
count: 1
path: test/classes/UserPreferencesTest.php

-
message: "#^Offset 0 does not exist on array\\|null\\.$#"
count: 1
Expand Down
7 changes: 4 additions & 3 deletions test/classes/Config/FormDisplayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ public function testDisplayErrors(): void
$attrIsValidated->setAccessible(true);
$attrIsValidated->setValue($this->object, []);

$this->assertNull(
$this->object->displayErrors()
);
$result = $this->object->displayErrors();

$this->assertNull($result);

$arr = [
'Servers/1/test' => ['e1'],
Expand All @@ -190,6 +190,7 @@ public function testDisplayErrors(): void

$result = $this->object->displayErrors();

$this->assertIsString($result);
$this->assertStringContainsString('<dt>Servers/1/test2</dt>', $result);
$this->assertStringContainsString('<dd>e1</dd>', $result);
$this->assertStringContainsString('<dt>Form_foobar</dt>', $result);
Expand Down
2 changes: 2 additions & 0 deletions test/classes/Gis/GisFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class GisFactoryTest extends AbstractTestCase
* @param string $type geometry type
* @param string $geom geometry object
*
* @psalm-param class-string $geom
*
* @dataProvider providerForTestFactory
*/
public function testFactory(string $type, string $geom): void
Expand Down
1 change: 1 addition & 0 deletions test/classes/Navigation/NavigationTreeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public function testRenderState(): void
public function testRenderPath(): void
{
$result = $this->object->renderPath();
$this->assertIsString($result);
$this->assertStringContainsString('list_container', $result);
}

Expand Down
2 changes: 2 additions & 0 deletions test/classes/Plugins/Auth/AuthenticationConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ public function testAuthFails(): void
$this->object->showFailure('');
$html = ob_get_clean();

$this->assertIsString($html);

$this->assertStringContainsString(
'You probably did not create a configuration file. You might want ' .
'to use the <a href="setup/">setup script</a> to create one.',
Expand Down
2 changes: 2 additions & 0 deletions test/classes/Plugins/Auth/AuthenticationHttpTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,8 @@ public function testAuthFails(): void
$this->object->showFailure('');
$result = ob_get_clean();

$this->assertIsString($result);

$this->assertStringContainsString(
'<p>error 123</p>',
$result
Expand Down
2 changes: 2 additions & 0 deletions test/classes/Plugins/Auth/AuthenticationSignonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ public function testAuth(): void
$this->object->showLoginForm();
$result = ob_get_clean();

$this->assertIsString($result);

$this->assertStringContainsString(
'You must set SignonURL!',
$result
Expand Down
2 changes: 2 additions & 0 deletions test/classes/Plugins/Export/ExportCodegenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ public function testExportData(): void
);
$result = ob_get_clean();

$this->assertIsString($result);

$this->assertStringContainsString(
'<?xml version="1.0" encoding="utf-8" ?>',
$result
Expand Down
12 changes: 8 additions & 4 deletions test/classes/Plugins/Export/ExportLatexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,8 @@ public function testExportHeader(): void
);
$result = ob_get_clean();

$this->assertIsString($result);

$this->assertStringContainsString(
"\n% Host: localhost:80",
$result
Expand Down Expand Up @@ -647,6 +649,8 @@ public function testExportData(): void
);
$result = ob_get_clean();

$this->assertIsString($result);

$this->assertStringContainsString(
'{datalabel} \\\\\\\\ \hlinefoo',
$result
Expand All @@ -658,10 +662,6 @@ public function testExportData(): void
*/
public function testExportStructure(): void
{
// $this->object = $this->getMockBuilder(ExportHtmlword::class)
// ->setMethods(array('formatOneColumnDefinition'))
// ->getMock();

$keys = [
[
'Non_unique' => 0,
Expand Down Expand Up @@ -875,6 +875,8 @@ public function testExportStructure(): void
);
$result = ob_get_clean();

$this->assertIsString($result);

$this->assertStringContainsString(
'\\textbf{\\textit{name1}} & set(abc) & Yes & NULL & ' .
'ftable (ffield) & & \\\\ \\hline',
Expand Down Expand Up @@ -948,6 +950,8 @@ public function testExportStructure(): void
);
$result = ob_get_clean();

$this->assertIsString($result);

$this->assertStringContainsString(
'\\caption{latexstructure} \\label{latexlabel}',
$result
Expand Down
6 changes: 6 additions & 0 deletions test/classes/Plugins/Export/ExportPhparrayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ public function testExportHeader(): void
);
$result = ob_get_clean();

$this->assertIsString($result);

$this->assertStringContainsString(
'<?php ',
$result
Expand Down Expand Up @@ -170,6 +172,8 @@ public function testExportDBHeader(): void
);
$result = ob_get_clean();

$this->assertIsString($result);

$this->assertStringContainsString(
"/**\n * Database `db`\n */",
$result
Expand Down Expand Up @@ -291,6 +295,8 @@ public function testExportData(): void
);
$result = ob_get_clean();

$this->assertIsString($result);

$this->assertStringContainsString(
'$_0_932table',
$result
Expand Down
Loading

0 comments on commit ba09c84

Please sign in to comment.