Odyssey
mcEstatementTest.php
1 <?php
2 
3 use PHPUnit\Framework\TestCase;
4 
5 $dir = "/var/www/html";
6 $monIncludes = "$dir/monitor/scripts";
7 require_once("$monIncludes/mcEstmntMntc.data");
8 
9 /**
10  * @var McEstatementTest
11  * Tests the functions in mcEstmntMntc.data.
12  * (It could possibly be expanded in the future.)
13  */
14 class McEstatementTest extends TestCase {
15 
16  /**
17  * function test_IsPeriodValid()
18  * This tests the function IsPeriodValid().
19  * The regex wasn't validating correctly so I decided to add to testcases.
20  */
21  function test_IsPeriodValid() {
22  $periodText = "wrong";
23  $isCcConfigReadable = false;
24  $test = IsPeriodValid($periodText, $isCcConfigReadable);
25  $this->assertEquals($test, false);
26 
27  $periodText = "Jan 2019";
28  $test = IsPeriodValid($periodText, $isCcConfigReadable);
29  $this->assertEquals($test, true);
30 
31  $periodText = "CREDIT CARD Dec 2019";
32  $test = IsPeriodValid($periodText, $isCcConfigReadable);
33  $this->assertEquals($test, false);
34 
35  $isCcConfigReadable = true;
36  $test = IsPeriodValid($periodText, $isCcConfigReadable);
37  $this->assertEquals($test, true);
38 
39  $periodText = "Quarter 3 2018";
40  $test = IsPeriodValid($periodText, $isCcConfigReadable);
41  $this->assertEquals($test, true);
42 
43  $periodText = "1st Half 9999";
44  $test = IsPeriodValid($periodText, $isCcConfigReadable);
45  $this->assertEquals($test, true);
46 
47  $periodText = "CREDIT CARD 2nd Half 1000";
48  $test = IsPeriodValid($periodText, $isCcConfigReadable);
49  $this->assertEquals($test, true);
50  }
51 }