Skip to content

Commit

Permalink
Make test more of a real-world example
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Jan 16, 2022
1 parent e8c8161 commit 9190294
Showing 1 changed file with 59 additions and 31 deletions.
90 changes: 59 additions & 31 deletions tests/Template/FunctionTemplateAssertTest.php
Expand Up @@ -233,16 +233,19 @@ function takesA(A $a) : void {
*/
function assertSame($expected, $actual) : void {}
$a = rand(0, 1) ? "goodbye" : "hello";
$b = rand(0, 1) ? "hello" : "goodbye";
class Hello {}
class Goodbye {}
$a = rand(0, 1) ? new Goodbye() : new Hello();
$b = rand(0, 1) ? new Hello() : new Goodbye();
assertSame($a, $b);
$c = "hello";
$d = rand(0, 1) ? "hello" : "goodbye";
$c = new Hello();
$d = rand(0, 1) ? new Hello() : new Goodbye();
assertSame($c, $d);
$c = "hello";
$d = rand(0, 1) ? "hello" : "goodbye";
$c = new Hello();
$d = rand(0, 1) ? new Hello() : new Goodbye();
assertSame($d, $c);
$c = 4;
Expand Down Expand Up @@ -282,8 +285,11 @@ class Assertion {
public static function assertSame($expected, $actual) : void {}
}
$a = rand(0, 1) ? "goodbye" : "hello";
$b = rand(0, 1) ? "hello" : "goodbye";
class Hello {}
class Goodbye {}
$a = rand(0, 1) ? new Goodbye() : new Hello();
$b = rand(0, 1) ? new Hello() : new Goodbye();
Assertion::assertSame($a, $b);',
],
'allowCanBeNotSameAfterAssertion' => [
Expand All @@ -300,17 +306,20 @@ public static function assertSame($expected, $actual) : void {}
*/
function assertNotSame($expected, $actual) : void {}
$a = rand(0, 1) ? "goodbye" : "hello";
$b = rand(0, 1) ? "hello" : "goodbye";
assertNotSame($a, $b);
class Hello {}
class Goodbye {}
$c = "hello";
$d = rand(0, 1) ? "hello" : "goodbye";
assertNotSame($c, $d);
$goodbye_or_hello = rand(0, 1) ? new Goodbye() : new Hello();
$hello_or_goodbye = rand(0, 1) ? new Hello() : new Goodbye();
assertNotSame($goodbye_or_hello, $hello_or_goodbye);
$c = "hello";
$d = rand(0, 1) ? "hello" : "goodbye";
assertNotSame($d, $c);
$hello = new Hello();
$hello_or_goodbye = rand(0, 1) ? new Hello() : new Goodbye();
assertNotSame($hello, $hello_or_goodbye);
$hello = new Hello();
$hello_or_goodbye = rand(0, 1) ? new Hello() : new Goodbye();
assertNotSame($hello_or_goodbye, $hello);
$c = 4;
$d = rand(0, 1) ? 4 : 5;
Expand All @@ -333,16 +342,19 @@ function foo(string $a, string $b) : void {
*/
function assertEqual($expected, $actual) : void {}
$a = rand(0, 1) ? "goodbye" : "hello";
$b = rand(0, 1) ? "hello" : "goodbye";
class Hello {}
class Goodbye {}
$a = rand(0, 1) ? new Goodbye() : new Hello();
$b = rand(0, 1) ? new Hello() : new Goodbye();
assertEqual($a, $b);
$c = "hello";
$d = rand(0, 1) ? "hello" : "goodbye";
$c = new Hello();
$d = rand(0, 1) ? new Hello() : new Goodbye();
assertEqual($c, $d);
$c = "hello";
$d = rand(0, 1) ? "hello" : "goodbye";
$c = new Hello();
$d = rand(0, 1) ? new Hello() : new Goodbye();
assertEqual($d, $c);
$c = 4;
Expand Down Expand Up @@ -903,8 +915,10 @@ function takesA(A $a) : void {
*/
function assertSame($expected, $actual) : void {}
class Hello {}
$a = 5;
$b = "hello";
$b = new Hello();
assertSame($a, $b);',
'error_message' => 'TypeDoesNotContainType',
],
Expand Down Expand Up @@ -939,8 +953,12 @@ function assertSame($expected, $actual) : void {}
*/
function assertSame($expected, $actual) : void {}
$c = "helloa";
$d = rand(0, 1) ? "hello" : "goodbye";
class Hello {}
class Helloa {}
class Goodbye {}
$c = new Helloa();
$d = rand(0, 1) ? new Hello() : new Goodbye();
assertSame($c, $d);',
'error_message' => 'TypeDoesNotContainType',
],
Expand All @@ -957,8 +975,12 @@ function assertSame($expected, $actual) : void {}
*/
function assertNotSame($expected, $actual) : void {}
$c = "helloa";
$d = rand(0, 1) ? "hello" : "goodbye";
class Hello {}
class Helloa {}
class Goodbye {}
$c = new Helloa();
$d = rand(0, 1) ? new Hello() : new Goodbye();
assertNotSame($c, $d);',
'error_message' => 'RedundantCondition',
],
Expand All @@ -975,8 +997,12 @@ function assertNotSame($expected, $actual) : void {}
*/
function assertEqual($expected, $actual) : void {}
$c = "helloa";
$d = rand(0, 1) ? "hello" : "goodbye";
class Hello {}
class Helloa {}
class Goodbye {}
$c = new Helloa();
$d = rand(0, 1) ? new Hello() : new Goodbye();
assertEqual($c, $d);',
'error_message' => 'TypeDoesNotContainType',
],
Expand Down Expand Up @@ -1045,8 +1071,10 @@ function bar(string $i, array $j) : void {
*/
function assertNotSame($expected, $actual, $message = "") {}
class Hello {}
function bar(array $j) : void {
assertNotSame("hello", $j);
assertNotSame(new Hello(), $j);
}',
'error_message' => 'RedundantCondition',
],
Expand Down

0 comments on commit 9190294

Please sign in to comment.