Skip to content

Commit fbf3f56

Browse files
committed
Adds Globals Unit Test
1 parent 3d622b2 commit fbf3f56

File tree

1 file changed

+164
-0
lines changed

1 file changed

+164
-0
lines changed

tests/GlobalsTest.php

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
<?php
2+
/**
3+
* @package Strider
4+
* @author Ryan Rentfro & Isaac Mendoza
5+
* @license MIT
6+
*/
7+
namespace Strider;
8+
9+
$path = str_replace('\tests','', __DIR__);
10+
require_once($path . '/system/trait/singleton.php');
11+
require_once($path . '/system/abstract/datastore.php');
12+
13+
/**
14+
* Test for Globals concrete class
15+
*/
16+
class GlobalsTest extends \PHPUnit_Framework_TestCase
17+
{
18+
19+
/**
20+
* Tests Getters and Setters
21+
*/
22+
public function testSettersGetters()
23+
{
24+
// Arrange
25+
$a = new Globals();
26+
27+
// Act
28+
$b = $a->setApplication('Application');
29+
30+
//get value back
31+
$c = $a->app();
32+
33+
// Assert
34+
$this->assertEquals('Application', $c);
35+
36+
// Arrange
37+
$a = new Globals();
38+
39+
// Act
40+
$b = $a->setController('Controller');
41+
42+
//get value back
43+
$c = $a->controller();
44+
45+
// Assert
46+
$this->assertEquals('Controller', $c);
47+
48+
// Arrange
49+
$a = new Globals();
50+
51+
// Act
52+
$b = $a->setModule('Module');
53+
54+
//get value back
55+
$c = $a->module();
56+
57+
// Assert
58+
$this->assertEquals('Module', $c);
59+
60+
}
61+
62+
/**
63+
* Tests Parameter Getters and Setters
64+
*/
65+
public function testSetParm()
66+
{
67+
// Arrange
68+
$a = new Globals();
69+
70+
// Act
71+
$b = $a->setParm(1, 'test1value');
72+
73+
//get value back
74+
$c = $a->getParm(1);
75+
76+
// Assert
77+
$this->assertEquals('test1value', $c);
78+
}
79+
80+
/**
81+
* Tests Initialization of the class and properties
82+
*/
83+
public function testInit()
84+
{
85+
// Arrange
86+
$a = new Globals();
87+
88+
// Act
89+
$b = $a->url();
90+
91+
//No url path will be present at CLI
92+
$c = '';
93+
94+
// Assert
95+
$this->assertEquals($c, $b);
96+
97+
// Arrange
98+
$a = new Globals();
99+
100+
// Act
101+
$b = $a->filepath();
102+
103+
$c = Config::$filePath;
104+
105+
// Assert
106+
$this->assertEquals($c, $b);
107+
108+
// Arrange
109+
$a = new Globals();
110+
111+
// Act
112+
$b = $a->webpath();
113+
114+
$c = Config::$webPath;
115+
116+
// Assert
117+
$this->assertEquals($c, $b);
118+
119+
// Arrange
120+
$a = new Globals();
121+
122+
// Act
123+
$b = $a->get();
124+
125+
$c = $_GET;
126+
127+
// Assert
128+
$this->assertEquals($c, $b);
129+
130+
// Arrange
131+
$a = new Globals();
132+
133+
// Act
134+
$b = $a->post();
135+
136+
$c = $_POST;
137+
138+
// Assert
139+
$this->assertEquals($c, $b);
140+
141+
// Arrange
142+
$a = new Globals();
143+
144+
// Act
145+
$b = $a->request();
146+
147+
$c = $_REQUEST;
148+
149+
// Assert
150+
$this->assertEquals($c, $b);
151+
152+
// Arrange
153+
$a = new Globals();
154+
155+
// Act
156+
$b = $a->files();
157+
158+
$c = $_FILES;
159+
160+
// Assert
161+
$this->assertEquals($c, $b);
162+
}
163+
164+
}

0 commit comments

Comments
 (0)