Browse files

Adding test cases for App folder

  • Loading branch information...
1 parent e334438 commit 8f6e55aa9721bd70d36a2cc1c6379cd5bdaa333f christophervalles committed Oct 23, 2011
Showing with 73 additions and 3 deletions.
  1. +41 −0 tests/App/DI/ContainerTest.php
  2. +25 −0 tests/App/DI/_files/ContainerWrapper.php
  3. +6 −0 tests/TestHelper.php
  4. +1 −3 tests/phpunit.xml
View
41 tests/App/DI/ContainerTest.php
@@ -0,0 +1,41 @@
+<?php
+
+require_once 'Zend/Config/Ini.php';
+require_once 'App/DI/Definition/ConfigObject.php';
+require_once dirname(__FILE__) . '/_files/ContainerWrapper.php';
+/**
+ * Test the dependency injector
+ *
+ * @category App
+ * @package App_DI
+ * @copyright company
+ */
+class App_DI_ContainerTest extends PHPUnit_Framework_TestCase
+{
+ /**
+ * Test the initial state of the dependency injection container
+ *
+ * @access public
+ * @return void
+ **/
+ public function testInitialState(){
+ $internalInstanceProperty = ContainerWrapper::getStaticVariableInstances();
+
+ $this->assertTrue(empty($internalInstanceProperty));
+ }
+
+ /**
+ * Test the get function and check if the container stores it on the
+ * instances array by asking for the ConfigObject
+ *
+ * @access public
+ * @return void
+ **/
+ public function testGetMethod(){
+ $objectFromContainer = ContainerWrapper::get('ConfigObject');
+ $internalInstanceProperty = ContainerWrapper::getStaticVariableInstances();
+
+ $this->assertTrue(array_key_exists('configobject', $internalInstanceProperty));
+ $this->assertEquals($objectFromContainer, $internalInstanceProperty['configobject']);
+ }
+}
View
25 tests/App/DI/_files/ContainerWrapper.php
@@ -0,0 +1,25 @@
+<?php
+
+require_once('App/DI/Container.php');
+
+/**
+ * This class just provides a method to be able to access the objects stored
+ * on the static instance array
+ *
+ * @category App
+ * @package App_DI
+ * @copyright company
+ */
+class ContainerWrapper extends App_DI_Container{
+
+ /**
+ * Method to access the protected static property that holds the
+ * objects
+ *
+ * @access public
+ * @return mixed
+ **/
+ public static function getStaticVariableInstances(){
+ return self::$_instances;
+ }
+}
View
6 tests/TestHelper.php
@@ -50,6 +50,12 @@
$zfCoreTests = "$zfRoot/tests";
/*
+ * Set few constants needed on the tests
+ */
+define('APPLICATION_ENV', 'development');
+define('APPLICATION_PATH', "$zfRoot/application");
+
+/*
* Prepend the Zend Framework library/ and tests/ directories to the
* include_path. This allows the tests to run out of the box and helps prevent
* loading other copies of the framework code and tests that would supersede
View
4 tests/phpunit.xml
@@ -2,12 +2,10 @@
<testsuite name="Zend Framework - Testsuite">
<directory>./</directory>
</testsuite>
-
- <!-- Enable this for proper unit testing code coverage reports
+
<filter>
<whitelist>
<directory suffix=".php">../library/Zend</directory>
</whitelist>
</filter>
- -->
</phpunit>

0 comments on commit 8f6e55a

Please sign in to comment.