-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
108 additions
and
114 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,75 @@ | ||
<?php | ||
|
||
namespace Stoic\Utilities\Tests; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Stoic\Utilities\ReturnHelper; | ||
|
||
class ReturnHelperTest extends TestCase { | ||
public function test_MessageHandling() { | ||
$ret = new ReturnHelper(); | ||
self::assertEquals(0, count($ret->getMessages()), "ReturnHelper returns the correct number of messages"); | ||
self::assertFalse($ret->hasMessages(), "ReturnHelper notes absence of messages correctly"); | ||
|
||
$ret->addMessage("Testing"); | ||
self::assertEquals(1, count($ret->getMessages()), "ReturnHelper returns the correct number of messages"); | ||
|
||
$ret->addMessages(array( | ||
"Testing2", | ||
"Testing3" | ||
)); | ||
self::assertEquals(3, count($ret->getMessages()), "ReturnHelper returns the correct number of messages"); | ||
self::assertTrue($ret->hasMessages(), "ReturnHelper notes presence of messages correctly"); | ||
self::assertArraySubset(array("Testing", "Testing2", "Testing3"), $ret->getMessages(), true, "ReturnHelper returns the correct messages"); | ||
|
||
try { | ||
$ret->addMessages([]); | ||
self::assertTrue(false); | ||
} catch (\InvalidArgumentException $ex) { | ||
self::assertEquals("Messages array to ReturnHelper::addMessages() must be array with elements", $ex->getMessage()); | ||
} | ||
|
||
return; | ||
} | ||
|
||
public function test_ResultHandling() { | ||
$ret = new ReturnHelper(); | ||
self::assertEquals(0, count($ret->getResults()), "ReturnHelper returns the correct number of results"); | ||
self::assertFalse($ret->hasResults(), "ReturnHelper notes absence of results correctly"); | ||
|
||
$ret->addResult("Testing"); | ||
self::assertEquals(1, count($ret->getResults()), "ReturnHelper returns the correct number of results"); | ||
|
||
$ret->addResults(array( | ||
"Testing2", | ||
"Testing3" | ||
)); | ||
self::assertEquals(3, count($ret->getResults()), "ReturnHelper returns the correct number of results"); | ||
self::assertTrue($ret->hasResults(), "ReturnHelper notes presence of results correctly"); | ||
self::assertArraySubset(array("Testing", "Testing2", "Testing3"), $ret->getResults(), true, "ReturnHelper returns the correct results"); | ||
|
||
try { | ||
$ret->addResults([]); | ||
self::assertTrue(false); | ||
} catch (\InvalidArgumentException $ex) { | ||
self::assertEquals("Results array to ReturnHelper::addResults() must be array with elements", $ex->getMessage()); | ||
} | ||
|
||
return; | ||
} | ||
|
||
public function test_GoodVsBad() { | ||
$ret = new ReturnHelper(); | ||
self::assertTrue($ret->isBad(), "ReturnHelper initializes as STATUS_BAD"); | ||
|
||
$ret->makeGood(); | ||
self::assertTrue($ret->isGood(), "ReturnHelper is made STATUS_GOOD"); | ||
|
||
$ret->makeBad(); | ||
self::assertTrue($ret->isBad(), "ReturnHelper is made STATUS_BAD"); | ||
|
||
return; | ||
} | ||
} | ||
<?php | ||
|
||
namespace Stoic\Utilities\Tests; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Stoic\Utilities\ReturnHelper; | ||
|
||
class ReturnHelperTest extends TestCase { | ||
public function test_MessageHandling() { | ||
$ret = new ReturnHelper(); | ||
self::assertEquals(0, count($ret->getMessages()), "ReturnHelper returns the correct number of messages"); | ||
self::assertFalse($ret->hasMessages(), "ReturnHelper notes absence of messages correctly"); | ||
|
||
$ret->addMessage("Testing"); | ||
self::assertEquals(1, count($ret->getMessages()), "ReturnHelper returns the correct number of messages"); | ||
|
||
$ret->addMessages(["Testing2", "Testing3"]); | ||
self::assertEquals(3, count($ret->getMessages()), "ReturnHelper returns the correct number of messages"); | ||
self::assertTrue($ret->hasMessages(), "ReturnHelper notes presence of messages correctly"); | ||
|
||
$messages = $ret->getMessages(); | ||
self::assertEquals("Testing", $messages[0], "ReturnHelper returned the correct messages"); | ||
self::assertEquals("Testing2", $messages[1], "ReturnHelper returned the correct messages"); | ||
self::assertEquals("Testing3", $messages[2], "ReturnHelper returned the correct messages"); | ||
|
||
try { | ||
$ret->addMessages([]); | ||
self::assertTrue(false); | ||
} catch (\InvalidArgumentException $ex) { | ||
self::assertEquals("Messages array to ReturnHelper::addMessages() must be array with elements", $ex->getMessage()); | ||
} | ||
|
||
return; | ||
} | ||
|
||
public function test_ResultHandling() { | ||
$ret = new ReturnHelper(); | ||
self::assertEquals(0, count($ret->getResults()), "ReturnHelper returns the correct number of results"); | ||
self::assertFalse($ret->hasResults(), "ReturnHelper notes absence of results correctly"); | ||
|
||
$ret->addResult("Testing"); | ||
self::assertEquals(1, count($ret->getResults()), "ReturnHelper returns the correct number of results"); | ||
|
||
$ret->addResults(["Testing2", "Testing3"]); | ||
self::assertEquals(3, count($ret->getResults()), "ReturnHelper returns the correct number of results"); | ||
self::assertTrue($ret->hasResults(), "ReturnHelper notes presence of results correctly"); | ||
|
||
$results = $ret->getResults(); | ||
self::assertEquals("Testing", $results[0], "ReturnHelper returned the correct messages"); | ||
self::assertEquals("Testing2", $results[1], "ReturnHelper returned the correct messages"); | ||
self::assertEquals("Testing3", $results[2], "ReturnHelper returned the correct messages"); | ||
|
||
try { | ||
$ret->addResults([]); | ||
self::assertTrue(false); | ||
} catch (\InvalidArgumentException $ex) { | ||
self::assertEquals("Results array to ReturnHelper::addResults() must be array with elements", $ex->getMessage()); | ||
} | ||
|
||
return; | ||
} | ||
|
||
public function test_GoodVsBad() { | ||
$ret = new ReturnHelper(); | ||
self::assertTrue($ret->isBad(), "ReturnHelper initializes as STATUS_BAD"); | ||
|
||
$ret->makeGood(); | ||
self::assertTrue($ret->isGood(), "ReturnHelper is made STATUS_GOOD"); | ||
|
||
$ret->makeBad(); | ||
self::assertTrue($ret->isBad(), "ReturnHelper is made STATUS_BAD"); | ||
|
||
return; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,39 +1,31 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<phpunit | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.5/phpunit.xsd" | ||
bootstrap="vendor/autoload.php" | ||
colors="false" | ||
stopOnError="false" | ||
stopOnFailure="false" | ||
stopOnIncomplete="false" | ||
stopOnSkipped="false" | ||
stopOnRisky="false"> | ||
<php> | ||
<ini name="error_reporting" value="-1" /> | ||
</php> | ||
<testsuites> | ||
<testsuite name="Chain Tests"> | ||
<directory suffix="Test.php">./Tests/Chain/</directory> | ||
</testsuite> | ||
<testsuite name="Logger Tests"> | ||
<directory suffix="Test.php">./Tests/Log/</directory> | ||
</testsuite> | ||
<testsuite name="Utility Tests"> | ||
<directory suffix="Test.php">./Tests/Utilities/</directory> | ||
</testsuite> | ||
</testsuites> | ||
<filter> | ||
<whitelist addUncoveredFilesFromWhitelist="true" processUncoveredFilesFromWhitelist="true"> | ||
<directory suffix=".php">./Chain</directory> | ||
<directory suffix=".php">./Log</directory> | ||
<directory suffix=".php">./Utilities</directory> | ||
</whitelist> | ||
</filter> | ||
<logging> | ||
<log type="junit" target="reports/phpunit.xml" /> | ||
<log type="coverage-clover" target="coverage/phpunit.xml" /> | ||
<log type="coverage-html" target="coverage/" /> | ||
</logging> | ||
</phpunit> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" bootstrap="vendor/autoload.php" colors="false" stopOnError="false" stopOnFailure="false" stopOnIncomplete="false" stopOnSkipped="false" stopOnRisky="false"> | ||
<coverage includeUncoveredFiles="true" processUncoveredFiles="true"> | ||
<include> | ||
<directory suffix=".php">./Chain</directory> | ||
<directory suffix=".php">./Log</directory> | ||
<directory suffix=".php">./Utilities</directory> | ||
</include> | ||
<report> | ||
<clover outputFile="coverage/phpunit.xml"/> | ||
<html outputDirectory="coverage/"/> | ||
</report> | ||
</coverage> | ||
<php> | ||
<ini name="error_reporting" value="-1"/> | ||
</php> | ||
<testsuites> | ||
<testsuite name="Chain Tests"> | ||
<directory suffix="Test.php">./Tests/Chain/</directory> | ||
</testsuite> | ||
<testsuite name="Logger Tests"> | ||
<directory suffix="Test.php">./Tests/Log/</directory> | ||
</testsuite> | ||
<testsuite name="Utility Tests"> | ||
<directory suffix="Test.php">./Tests/Utilities/</directory> | ||
</testsuite> | ||
</testsuites> | ||
<logging> | ||
<junit outputFile="reports/phpunit.xml"/> | ||
</logging> | ||
</phpunit> |