As the new feature of Zend Studio it has phpUnit Gui where you can simply
click and it runs the tests. But i dont get it working with Zend Framework.
Current tests structure is same as the normal one.

Test code is taken mostly from here http://www.alexatnet.com/node/12

After running code get error, something wrong with the phpUnit libraries?
Also tested just simple $this->AssertEquals('o', 'o'); worked.

Fatal error: Uncaught exception 'InvalidArgumentException' in F:\Program
Files\Zend\Zend Studio for Eclipse -
6.0.0\plugins\com.zend.php.phpunit_6.0.0.v20080107\resources\library\PHPUnit\Framework\TestSuite.php:300
Stack trace: #0 F:\wamp\www\zend\tests\AllTests.php(34):
PHPUnit_Framework_TestSuite->addTestSuite('IndexController...') #1
F:\wamp\www\zend\tests\AllTests.php(42): AllTests->__construct() #2
[internal function]: AllTests::suite() #3 F:\Program Files\Zend\Zend Studio
for Eclipse -
6.0.0\plugins\com.zend.php.phpunit_6.0.0.v20080107\resources\ZendPHPUnit.php(76):
call_user_func(Array) #4 F:\Program Files\Zend\Zend Studio for Eclipse -
6.0.0\plugins\com.zend.php.phpunit_6.0.0.v20080107\resources\ZendPHPUnit.php(549):
ZendPHPUnitSuite::suite() #5 {main} thrown in F:\Program Files\Zend\Zend
Studio for Eclipse -
6.0.0\plugins\com.zend.php.phpunit_6.0.0.v20080107\resources\library\PHPUnit\Framework\TestSuite.php
on line 300


-application
--default
---controllers
----indexController.php
---models
---views

-html
--index.php

-library
--zend
--my

-tests
-AllTests.php
-application
--default
---controllers
----indexControllerTest.php
---models

AllTests.php code
<?php
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 'on');
ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR .
'../library' . PATH_SEPARATOR . '../application/models' . PATH_SEPARATOR .
'../library/My');
ini_set('xdebug.collect_params', '4');


require_once 'Zend/Loader.php';

Zend_Loader::registerAutoload();


$front = Zend_Controller_Front::getInstance()
        //->setBaseUrl('')
        //->setControllerDirectory(array(
        //      'default ' => '../application/default/controllers',
        //      'news'     => '../application/news/controllers'))
        ->addModuleDirectory('../application/')
        //->registerPlugin(new Zend_Controller_Plugin_ErrorHandler())
        ->setControllerDirectory('../application/default/controllers')
        ->throwExceptions(true);
        
require_once 'application/default/controllers/indexControllerTests.php';
/**
 * Static test suite.
 */
class AllTests extends PHPUnit_Framework_TestSuite {
        
        /**
         * Constructs the test suite handler.
         */
        public function __construct() {
                $this->setName ( 'AllTests' );
                $this->addTestSuite('IndexControllerTests');
        
        }
        
        /**
         * Creates the suite.
         */
        public static function suite() {
                return new self ( );
        }
}



IndexControllerTests.php code

<?php


/**
 * IndexController test case.
 */
class indexController extends PHPUnit_Framework_TestCase {
        
        /**
         * @var IndexController
         */
        private $IndexController;
        
        /**
         * Prepares the environment before running a test.
         */
        protected function setUp() {
                parent::setUp ();
                
                // TODO Auto-generated indexController::setUp()
                

                $this->IndexController = new IndexController(/* parameters */);
        
        }
        
        /**
         * Cleans up the environment after running a test.
         */
        protected function tearDown() {
                // TODO Auto-generated indexController::tearDown()
                

                $this->IndexController = null;
                
                parent::tearDown ();
        }
        
        /**
         * Constructs the test case.
         */
        public function __construct() {
                // TODO Auto-generated constructor
        }
        
        /**
         * Tests IndexController->aboutAction()
         */
        public function testAboutAction() {
                // TODO Auto-generated indexController->testAboutAction()
                $this->markTestIncomplete ( "aboutAction test not implemented" 
);
                
                $this->IndexController->aboutAction(/* parameters */);
        
        }
        
        /**
         * Tests IndexController->contactAction()
         */
    function testMainUseCase() {
        // User opens http://localhost/main/user/register 
        $front = Zend_Controller_Front::getInstance();
        $request = new
Zend_Controller_Request_Http('http://localhost/zend/demo_app/index.php');
        $response = new Zend_Controller_Response_Http();
       
$front->returnResponse(true)->setRequest($request)->setResponse($response);
        // System shows registration screen by invoking registerAction().
        // This action renders the "register.phtml" View script. 
        $front->dispatch();
        $this->assertContains('</title>', $response->getBody());
    }
        
        /**
         * Tests IndexController->indexAction()
         */
        public function testIndexAction() {
                // TODO Auto-generated indexController->testIndexAction()
                $this->markTestIncomplete ( "indexAction test not implemented" 
);
                
                $this->IndexController->indexAction(/* parameters */);
        
        }
        
        /**
         * Tests IndexController->init()
         */
        public function testInit() {
                // TODO Auto-generated indexController->testInit()
                $this->markTestIncomplete ( "init test not implemented" );
                
                $this->IndexController->init(/* parameters */);
        
        }

}



-- 
View this message in context: 
http://www.nabble.com/Zend-Studio-6-phpUnit-and-Zend-Framework-tp16763536p16763536.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to