Beispiel #1
0
 /**
  * Test the behavior of the proxy when it is cloned :
  * All states must be cloned
  * DI Container must be cloned
  * Registered states must be cloned
  * Active states must be cloned
  * The cloned proxy must has a new unique id.
  */
 public function testCloning()
 {
     $this->initializeProxy('state1', true);
     $obj = new \stdClass();
     $obj->foo = 'bar';
     $clonedProxy = clone $this->proxy;
     //States must be independently
     $this->assertEquals(array('state1', 'state2', 'state3'), $this->proxy->listAvailableStates());
     $this->assertEquals(array('state1'), $this->proxy->listEnabledStates());
     $this->assertEquals(array('state1', 'state2', 'state3'), $clonedProxy->listAvailableStates());
     $this->assertEquals(array('state1'), $clonedProxy->listEnabledStates());
     //List must perform independently
     $clonedProxy->switchState('state2');
     $clonedProxy->unregisterState('state3');
     $this->assertEquals(array('state1', 'state2', 'state3'), $this->proxy->listAvailableStates());
     $this->assertEquals(array('state1'), $this->proxy->listEnabledStates());
     $this->assertEquals(array('state1', 'state2'), $clonedProxy->listAvailableStates());
     $this->assertEquals(array('state2'), $clonedProxy->listEnabledStates());
 }