| 1 |
<?php |
| 2 |
/** |
| 3 |
* |
| 4 |
* Class BasicUtilityTest |
| 5 |
*/ |
| 6 |
class BasicUtilityTest extends PHPUnit_Framework_TestCase { |
| 7 |
|
| 8 |
/** |
| 9 |
* Test Object Extending with Defaults |
| 10 |
* |
| 11 |
*/ |
| 12 |
public function testDefaults() { |
| 13 |
|
| 14 |
$myConfiguration = array( |
| 15 |
"someOther" => 10 |
| 16 |
); |
| 17 |
|
| 18 |
$defaultsSettings = array( |
| 19 |
"someDefault" => 7 |
| 20 |
); |
| 21 |
|
| 22 |
$finalConfiguration = UsabilityDynamics\Utility::defaults( $myConfiguration, $defaultsSettings ); |
| 23 |
|
| 24 |
$this->assertEquals( 7, $finalConfiguration->someDefault ); |
| 25 |
$this->assertEquals( 10, $finalConfiguration->someOther ); |
| 26 |
|
| 27 |
} |
| 28 |
|
| 29 |
/** |
| 30 |
* Test Utility::findUp(); |
| 31 |
* |
| 32 |
*/ |
| 33 |
public function testFindUp() { |
| 34 |
|
| 35 |
// Traverse upward directory tree until fixtures/sample.json is found. |
| 36 |
$sampleJSON = UsabilityDynamics\Utility::findUp( 'fixtures/sample.json' ); |
| 37 |
|
| 38 |
// Traverse upward directory tree until fixtures/sample.xml is found. |
| 39 |
$sampleXML = UsabilityDynamics\Utility::findUp( 'fixtures/sample.xml' ); |
| 40 |
|
| 41 |
// Traverse upward directory tree until fixtures/sample.php is found. |
| 42 |
UsabilityDynamics\Utility::findUp( 'fixtures/sample.php' ); |
| 43 |
|
| 44 |
// JSON Formatted properly. |
| 45 |
$this->assertEquals( 1.1, $sampleJSON->anagrafica->{"@version"} ); |
| 46 |
|
| 47 |
// XML Formatted properly. |
| 48 |
$this->assertEquals( 1.1, (string) $sampleXML->version ); |
| 49 |
|
| 50 |
// Custom class loaded. |
| 51 |
$this->assertEquals( true, class_exists( 'MySampleClass' ) ); |
| 52 |
|
| 53 |
// Custom class method is accessible. |
| 54 |
$this->assertEquals( true, method_exists( 'MySampleClass', 'test_method' ) ); |
| 55 |
|
| 56 |
} |
| 57 |
|
| 58 |
} |
| 59 |
|