-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix dataProvider tests with user output (#117)
- Loading branch information
Showing
16 changed files
with
137 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
function helloWorld() | ||
{ | ||
echo "Some output"; | ||
throw new \BadFunctionCallException("Implement the helloWorld() function"); | ||
} |
25 changes: 25 additions & 0 deletions
25
tests/dataProvider-error-with-user-output/HelloWorldTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
class HelloWorldTest extends PHPUnit\Framework\TestCase | ||
{ | ||
public static function setUpBeforeClass(): void | ||
{ | ||
require_once 'HelloWorld.php'; | ||
} | ||
|
||
static public function input(): array | ||
{ | ||
return [ | ||
['first input'], | ||
['second input'], | ||
]; | ||
} | ||
|
||
/** @dataProvider input */ | ||
public function testHelloWorld($input): void | ||
{ | ||
$this->assertEquals('Hello, World!', helloWorld($input)); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
tests/dataProvider-error-with-user-output/expected_results.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"version":3,"status":"fail","tests":[{"name":"testHelloWorld with data set #0","status":"error","test_code":"$this->assertEquals('Hello, World!', helloWorld($input));\n","output":"Some output","message":"HelloWorldTest::testHelloWorld with data set #0\nBadFunctionCallException: Implement the helloWorld() function\n\nHelloWorld.php:6\nHelloWorldTest.php:23"},{"name":"testHelloWorld with data set #1","status":"error","test_code":"$this->assertEquals('Hello, World!', helloWorld($input));\n","output":"Some output","message":"HelloWorldTest::testHelloWorld with data set #1\nBadFunctionCallException: Implement the helloWorld() function\n\nHelloWorld.php:6\nHelloWorldTest.php:23"}]} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
function helloWorld() | ||
{ | ||
echo "Some output"; | ||
return "Goodbye, Mars!"; | ||
} |
25 changes: 25 additions & 0 deletions
25
tests/dataProvider-fail-with-user-output/HelloWorldTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
class HelloWorldTest extends PHPUnit\Framework\TestCase | ||
{ | ||
public static function setUpBeforeClass(): void | ||
{ | ||
require_once 'HelloWorld.php'; | ||
} | ||
|
||
static public function input(): array | ||
{ | ||
return [ | ||
['first input'], | ||
['second input'], | ||
]; | ||
} | ||
|
||
/** @dataProvider input */ | ||
public function testHelloWorld($input): void | ||
{ | ||
$this->assertEquals('Hello, World!', helloWorld($input)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"version":3,"status":"fail","tests":[{"name":"testHelloWorld with data set #0","status":"fail","test_code":"$this->assertEquals('Hello, World!', helloWorld($input));\n","output":"Some output","message":"HelloWorldTest::testHelloWorld with data set #0\nFailed asserting that two strings are equal.\n--- Expected\n+++ Actual\n@@ @@\n-'Hello, World!'\n+'Goodbye, Mars!'\n\nHelloWorldTest.php:23"},{"name":"testHelloWorld with data set #1","status":"fail","test_code":"$this->assertEquals('Hello, World!', helloWorld($input));\n","output":"Some output","message":"HelloWorldTest::testHelloWorld with data set #1\nFailed asserting that two strings are equal.\n--- Expected\n+++ Actual\n@@ @@\n-'Hello, World!'\n+'Goodbye, Mars!'\n\nHelloWorldTest.php:23"}]} |
10 changes: 10 additions & 0 deletions
10
tests/dataProvider-partial-fail-with-user-output/HelloWorld.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
function helloWorld($input) | ||
{ | ||
if ($input !== 'first input') { | ||
echo "Some output"; | ||
return "Goodbye, Mars!"; | ||
} | ||
return "Hello, World!"; | ||
} |
25 changes: 25 additions & 0 deletions
25
tests/dataProvider-partial-fail-with-user-output/HelloWorldTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
class HelloWorldTest extends PHPUnit\Framework\TestCase | ||
{ | ||
public static function setUpBeforeClass(): void | ||
{ | ||
require_once 'HelloWorld.php'; | ||
} | ||
|
||
static public function input(): array | ||
{ | ||
return [ | ||
['first input'], | ||
['second input'], | ||
]; | ||
} | ||
|
||
/** @dataProvider input */ | ||
public function testHelloWorld($input): void | ||
{ | ||
$this->assertEquals('Hello, World!', helloWorld($input)); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
tests/dataProvider-partial-fail-with-user-output/expected_results.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"version":3,"status":"fail","tests":[{"name":"testHelloWorld with data set #0","status":"pass","test_code":"$this->assertEquals('Hello, World!', helloWorld($input));\n"},{"name":"testHelloWorld with data set #1","status":"fail","test_code":"$this->assertEquals('Hello, World!', helloWorld($input));\n","output":"Some output","message":"HelloWorldTest::testHelloWorld with data set #1\nFailed asserting that two strings are equal.\n--- Expected\n+++ Actual\n@@ @@\n-'Hello, World!'\n+'Goodbye, Mars!'\n\nHelloWorldTest.php:23"}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
function helloWorld() | ||
{ | ||
echo "Some output"; | ||
return "Hello, World!"; | ||
} |
25 changes: 25 additions & 0 deletions
25
tests/dataProvider-success-with-user-output/HelloWorldTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
class HelloWorldTest extends PHPUnit\Framework\TestCase | ||
{ | ||
public static function setUpBeforeClass(): void | ||
{ | ||
require_once 'HelloWorld.php'; | ||
} | ||
|
||
static public function input(): array | ||
{ | ||
return [ | ||
['first input'], | ||
['second input'], | ||
]; | ||
} | ||
|
||
/** @dataProvider input */ | ||
public function testHelloWorld($input): void | ||
{ | ||
$this->assertEquals('Hello, World!', helloWorld($input)); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
tests/dataProvider-success-with-user-output/expected_results.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"version":3,"status":"pass","tests":[{"name":"testHelloWorld with data set #0","status":"pass","test_code":"$this->assertEquals('Hello, World!', helloWorld($input));\n","output":"Some output"},{"name":"testHelloWorld with data set #1","status":"pass","test_code":"$this->assertEquals('Hello, World!', helloWorld($input));\n","output":"Some output"}]} |