Skip to content

Commit

Permalink
infection#654 add test for calling functions via variable
Browse files Browse the repository at this point in the history
  • Loading branch information
majkel89 committed Mar 30, 2019
1 parent a6a4e4b commit 2205316
Showing 1 changed file with 68 additions and 0 deletions.
68 changes: 68 additions & 0 deletions tests/Mutator/Extensions/MBStringTest.php
Expand Up @@ -135,6 +135,10 @@ private function provideMutationCasesForChr(): Generator
"<?php mb_chr(74, 'utf-8');",
"<?php\n\nchr(74);",
];

yield 'It does not mutate mb_chr called via variable' => [
'<?php $a = "mb_chr"; $a(74);',
];
}

private function provideMutationCasesForOrd(): Generator
Expand All @@ -153,6 +157,10 @@ private function provideMutationCasesForOrd(): Generator
"<?php mb_ord('T', 'utf-8');",
"<?php\n\nord('T');",
];

yield 'It does not mutate mb_ord called via variable' => [
'<?php $a = "mb_ord"; $a("T");',
];
}

private function provideMutationCasesForParseStr(): Generator
Expand All @@ -171,6 +179,10 @@ private function provideMutationCasesForParseStr(): Generator
"<?php mb_parse_str('T', \$params);",
"<?php\n\nparse_str('T', \$params);",
];

yield 'It does not mutate mb_parse_str called via variable' => [
'<?php $a = "mb_parse_str"; $a("T");',
];
}

private function provideMutationCasesForSendMail(): Generator
Expand All @@ -189,6 +201,10 @@ private function provideMutationCasesForSendMail(): Generator
"<?php mb_send_mail('to', 'subject', 'msg', [], []);",
"<?php\n\nmail('to', 'subject', 'msg', [], []);",
];

yield 'It does not mutate mb_send_mail called via variable' => [
'<?php $a = "mb_send_mail"; $a("to", "subject", "msg");',
];
}

private function provideMutationCasesForStrCut(): Generator
Expand All @@ -212,6 +228,10 @@ private function provideMutationCasesForStrCut(): Generator
"<?php mb_strcut('subject', 1, 20, 'utf-8');",
"<?php\n\nsubstr('subject', 1, 20);",
];

yield 'It does not mutate mb_strcut called via variable' => [
'<?php $a = "mb_strcut"; $a("subject", 1);',
];
}

private function provideMutationCasesForStrPos(): Generator
Expand All @@ -235,6 +255,10 @@ private function provideMutationCasesForStrPos(): Generator
"<?php mb_strpos('subject', 'b', 3, 'utf-8');",
"<?php\n\nstrpos('subject', 'b', 3);",
];

yield 'It does not mutate mb_strpos called via variable' => [
'<?php $a = "mb_strpos"; $a("subject", "b");',
];
}

private function provideMutationCasesForStrIPos(): Generator
Expand All @@ -258,6 +282,10 @@ private function provideMutationCasesForStrIPos(): Generator
"<?php mb_stripos('subject', 'b', 3, 'utf-8');",
"<?php\n\nstripos('subject', 'b', 3);",
];

yield 'It does not mutate mb_stripos called via variable' => [
'<?php $a = "mb_stripos"; $a("subject", "b");',
];
}

private function provideMutationCasesForStrIStr(): Generator
Expand All @@ -281,6 +309,10 @@ private function provideMutationCasesForStrIStr(): Generator
"<?php mb_stristr('subject', 'b', false, 'utf-8');",
"<?php\n\nstristr('subject', 'b', false);",
];

yield 'It does not mutate mb_stristr called via variable' => [
'<?php $a = "mb_stristr"; $a("subject", "b");',
];
}

private function provideMutationCasesForStrRiPos(): Generator
Expand All @@ -304,6 +336,10 @@ private function provideMutationCasesForStrRiPos(): Generator
"<?php mb_strripos('subject', 'b', 2, 'utf-8');",
"<?php\n\nstrripos('subject', 'b', 2);",
];

yield 'It does not mutate mb_strripos called via variable' => [
'<?php $a = "mb_strripos"; $a("subject", "b");',
];
}

private function provideMutationCasesForStrRPos(): Generator
Expand All @@ -327,6 +363,10 @@ private function provideMutationCasesForStrRPos(): Generator
"<?php mb_strrpos('subject', 'b', 2, 'utf-8');",
"<?php\n\nstrrpos('subject', 'b', 2);",
];

yield 'It does not mutate mb_strrpos called via variable' => [
'<?php $a = "mb_strrpos"; $a("subject", "b");',
];
}

private function provideMutationCasesForStrStr(): Generator
Expand All @@ -350,6 +390,10 @@ private function provideMutationCasesForStrStr(): Generator
"<?php mb_strstr('subject', 'b', false, 'utf-8');",
"<?php\n\nstrstr('subject', 'b', false);",
];

yield 'It does not mutate mb_strstr called via variable' => [
'<?php $a = "mb_strstr"; $a("subject", "b");',
];
}

private function provideMutationCasesForStrToLower(): Generator
Expand All @@ -368,6 +412,10 @@ private function provideMutationCasesForStrToLower(): Generator
"<?php mb_strtolower('test', 'utf-8');",
"<?php\n\nstrtolower('test');",
];

yield 'It does not mutate mb_strtolower called via variable' => [
'<?php $a = "mb_strtolower"; $a("test");',
];
}

private function provideMutationCasesForStrToUpper(): Generator
Expand All @@ -386,6 +434,10 @@ private function provideMutationCasesForStrToUpper(): Generator
"<?php mb_strtoupper('test', 'utf-8');",
"<?php\n\nstrtoupper('test');",
];

yield 'It does not mutate mb_strtoupper called via variable' => [
'<?php $a = "mb_strtoupper"; $a("test");',
];
}

private function provideMutationCasesForSubStrCount(): Generator
Expand All @@ -404,6 +456,10 @@ private function provideMutationCasesForSubStrCount(): Generator
"<?php mb_substr_count('test', 't', 'utf-8');",
"<?php\n\nsubstr_count('test', 't');",
];

yield 'It does not mutate mb_substr_count called via variable' => [
'<?php $a = "mb_substr_count"; $a("test", "t");',
];
}

private function provideMutationCasesForSubStr(): Generator
Expand All @@ -427,6 +483,10 @@ private function provideMutationCasesForSubStr(): Generator
"<?php mb_substr('test', 2, 10, 'utf-8');",
"<?php\n\nsubstr('test', 2, 10);",
];

yield 'It does not mutate mb_substr called via variable' => [
'<?php $a = "mb_substr"; $a("test", 2, 10);',
];
}

private function provideMutationCasesForStrRChr(): Generator
Expand All @@ -450,6 +510,10 @@ private function provideMutationCasesForStrRChr(): Generator
"<?php mb_strrchr('subject', 'b', false, 'utf-8');",
"<?php\n\nstrrchr('subject', 'b');",
];

yield 'It does not mutate mb_strrchr called via variable' => [
'<?php $a = "mb_strrchr"; $a("subject", "b");',
];
}

private function provideMutationCasesForConvertCase(): Generator
Expand Down Expand Up @@ -511,6 +575,10 @@ private function provideMutationCasesForConvertCase(): Generator
yield 'It does not convert mb_convert_case with missing mode argument' => [
"<?php mb_convert_case('test');",
];

yield 'It does not mutate mb_convert_case called via variable' => [
'<?php $a = "mb_convert_case"; $a("test");',
];
}

private static function defineMissingMbCaseConstants(): void
Expand Down

0 comments on commit 2205316

Please sign in to comment.