Skip to content

Commit 5ddd6c7

Browse files
committed
Adds the package and template unit tests
1 parent 56047ed commit 5ddd6c7

File tree

2 files changed

+173
-0
lines changed

2 files changed

+173
-0
lines changed

tests/PackageTest.php

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
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 Package concrete class
15+
*/
16+
class PackageTest extends \PHPUnit_Framework_TestCase
17+
{
18+
/**
19+
* Test for getPackage
20+
*/
21+
public function testGetPackage()
22+
{
23+
// Arrange
24+
$a = new Package();
25+
26+
// Act
27+
$b = $a->getPackage('bootstrap');
28+
29+
$c = array(
30+
'js' => array('public/components/bootstrap/dist/js/bootstrap.min.js'),
31+
'css' => array('public/components/bootstrap/dist/css/bootstrap.min.css')
32+
);
33+
34+
// Assert
35+
$this->assertEquals($c, $b);
36+
}
37+
38+
/**
39+
* Test for getPackages
40+
*/
41+
public function testGetPackages()
42+
{
43+
// Arrange
44+
$a = new Package();
45+
46+
// Act
47+
$b = $a->getPackages(array('bootstrap', 'jquery-ui'));
48+
49+
$c = array(
50+
'js' => array(
51+
'public/components/bootstrap/dist/js/bootstrap.min.js',
52+
'public/components/jquery-ui/jquery-ui.min.js'
53+
),
54+
'css' => array(
55+
'public/components/bootstrap/dist/css/bootstrap.min.css',
56+
'public/components/jquery-ui/themes/base/theme.css',
57+
)
58+
59+
);
60+
61+
// Assert
62+
$this->assertEquals($c, $b);
63+
}
64+
65+
/**
66+
* Test for addPackage
67+
*/
68+
public function testAddPackage()
69+
{
70+
// Arrange
71+
$a = new Package();
72+
73+
// Act
74+
$package = array(
75+
'js' => array(
76+
'/this/is/a/test/js.js',
77+
),
78+
'css' => array(
79+
'/this/is/a/test/js.css',
80+
)
81+
);
82+
83+
$b = $a->addPackage('testPackage', $package);
84+
85+
// Assert
86+
$this->assertEquals($package, $a->getPackage('testPackage'));
87+
}
88+
}

tests/TemplateTest.php

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
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 Template concrete class
15+
*/
16+
class TemplateTest extends \PHPUnit_Framework_TestCase
17+
{
18+
public function testSetValueGetValue()
19+
{
20+
// Arrange
21+
$a = new Template();
22+
23+
// Act
24+
$b = $a->setValue('testKey', 'testValue');
25+
26+
// Assert
27+
$this->assertEquals(true, $b);
28+
29+
// Arrange
30+
$a = new Template();
31+
32+
// Act
33+
$b = $a->setValue('testKey', 'testValue');
34+
$c = $a->getValue('testKey');
35+
36+
// Assert
37+
$this->assertEquals('testValue', $c);
38+
}
39+
40+
public function testExistValue()
41+
{
42+
// Arrange
43+
$a = new Template();
44+
45+
// Act
46+
$b = $a->setValue('testKey', 'testValue');
47+
48+
$c = $a->existValue('testKey');
49+
50+
// Assert
51+
$this->assertEquals(true, $c);
52+
}
53+
54+
public function testAddGetJs()
55+
{
56+
// Arrange
57+
$a = new Template();
58+
59+
// Act
60+
$b = $a->addJs('/test/js/file.js');
61+
62+
$c = $a->getJs();
63+
64+
$d = '<script type="text/javascript" src="/test/js/file.js"></script>' . "\r\n";
65+
66+
// Assert
67+
$this->assertEquals($d, $c);
68+
}
69+
70+
public function testAddGetCSS()
71+
{
72+
// Arrange
73+
$a = new Template();
74+
75+
// Act
76+
$b = $a->addCSS('/test/css/file.css');
77+
78+
$c = $a->getCSS();
79+
80+
$d = '<link href="/test/css/file.css" rel="stylesheet">' . "\r\n";
81+
82+
// Assert
83+
$this->assertEquals($d, $c);
84+
}
85+
}

0 commit comments

Comments
 (0)