Exemplo n.º 1
0
 public function testGet()
 {
     $object = $this->getMock('Finite\\StatefulInterface');
     $object->expects($this->once())->method('getFiniteState')->will($this->returnValue('s2'));
     $sm = $this->object->get($object);
     $this->assertInstanceOf('Finite\\StateMachine\\StateMachine', $sm);
     $this->assertSame('s2', $sm->getCurrentState()->getName());
     $object2 = $this->getMock('Finite\\StatefulInterface');
     $object2->expects($this->once())->method('getFiniteState')->will($this->returnValue('s2'));
     $sm2 = $this->object->get($object2);
     $this->assertNotSame($sm, $sm2);
 }
Exemplo n.º 2
0
 public function testLoad()
 {
     $object = $this->getMock('Finite\\StatefulInterface');
     $this->accessor->expects($this->any())->method('getState')->will($this->returnValue('s1'));
     $loader1 = $this->getMock('Finite\\Loader\\LoaderInterface');
     $loader1->expects($this->at(0))->method('supports')->with($object, 'foo')->will($this->returnValue(false));
     $loader1->expects($this->at(1))->method('supports')->with($object, 'bar')->will($this->returnValue(true));
     $loader2 = $this->getMock('Finite\\Loader\\LoaderInterface');
     $loader2->expects($this->at(0))->method('supports')->with($object, 'foo')->will($this->returnValue(true));
     $loader2->expects($this->at(1))->method('load');
     $this->object->addLoader($loader1);
     $this->object->addLoader($loader2);
     $this->object->get($object, 'foo');
     $this->object->get($object, 'bar');
 }