[fw-general] Re: Accessing Bootstrap within Session Save Handler class

2011-01-12 Thread whisher

Hi,
If you have a _initDoctrine in your bootstrap
you could store the connession in  Zend_Registry::set('db',$dottrineConn);
what  about putting your class in a  controller plugin ?

Bye.
-- 
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/Accessing-Bootstrap-within-Session-Save-Handler-class-tp3208482p3214721.html
Sent from the Zend Framework mailing list archive at Nabble.com.


Re: [fw-general] Unit Test - Plugins loaded multiple times

2011-01-12 Thread Dennis Winter
> Hi !
> 
> So, here is my problem :
> 
> I try to test a Zend Framework application with PHPUnit.
> 
> All my tests extend the class "TestsController" you can see below :
> 
> class TestsController extends Zend_Test_PHPUnit_ControllerTestCase
> {
> 
>public function setUp()
>{  
> 
>$this->bootstrap = new
> Zend_Application(APPLICATION_ENV,APPLICATION_PATH .
> '/configs/application.ini');
>$this->bootstrap->bootstrap(array(...module list...));
>   //Setup Test's database
>}
> 
>public function tearDown()
>{
>  //delete test's database  
>}
> }
> 
> Then, in an other file, I create my test Class which extends TestsController
> :
> 
> class SomethingControllerTest extends TestsController
> {
>public function Test1()
>{
>}
> 
>public function Test2()
>{
>}
> 
>public function Test3()
>{
>}
> }
> 
> Every time a Test method is executed (Test1, Test2...), the plugins defined
> in my config.ini are registered one more time by the Broker
> (Zend_Controller_Plugin_Broker).
> 
> // config.ini excerpt
> resources.frontController.plugins[] = "Plugin_First"
> resources.frontController.plugins[] = "Plugin_Second"
> 
> How can I avoid it ?

Hi,

First: In your TestController::setUp() method you probably forgot to call 
parent::setUp();
Second: Are your tests running in process isolation? You can turn this on in 
your phpunit.xml.

I've no real experience unit-testing a ZF application, but maybe it helps.

Cheers, Dennis

[fw-general] Unit Test - Plugins loaded multiple times

2011-01-12 Thread Jeace

(I re-post the subject because I wasn't in the mailing list when I first
posted it ! Sorry)

Hi !

So, here is my problem :

I try to test a Zend Framework application with PHPUnit.

All my tests extend the class "TestsController" you can see below :

class TestsController extends Zend_Test_PHPUnit_ControllerTestCase
{
   
public function setUp()
{  
   
$this->bootstrap = new
Zend_Application(APPLICATION_ENV,APPLICATION_PATH .
'/configs/application.ini');
$this->bootstrap->bootstrap(array(...module list...));
   //Setup Test's database
}
   
public function tearDown()
{
  //delete test's database  
}
}

Then, in an other file, I create my test Class which extends TestsController
:

class SomethingControllerTest extends TestsController
{
public function Test1()
{
}

public function Test2()
{
}

public function Test3()
{
}
}

Every time a Test method is executed (Test1, Test2...), the plugins defined
in my config.ini are registered one more time by the Broker
(Zend_Controller_Plugin_Broker).

// config.ini excerpt
resources.frontController.plugins[] = "Plugin_First"
resources.frontController.plugins[] = "Plugin_Second"

How can I avoid it ?

Thanks for your help ! 
-- 
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/Unit-Test-Plugins-loaded-multiple-times-tp3213501p3213501.html
Sent from the Zend Framework mailing list archive at Nabble.com.