Esempio n. 1
0
 /**
  * @dataProvider schemaProvider
  */
 public function testResolveTimeoutsWithDifferentAttributeType($schema)
 {
     $this->machine->expects($this->exactly(1))->method('resolveTimeouts')->with();
     $factory = new Factory();
     $factory->register('foo', function () {
         return $this->machine;
     });
     $factory->resolveTimeouts($schema);
 }
Esempio n. 2
0
 public function testResolveTimeouts()
 {
     $machine = new StateMachine($this->adapter, $this->payloadHandler, $this->timeoutHandler, $this->lockHandler);
     $this->assertFalse($this->payloadHandler->wasStored());
     $this->assertFalse($this->lockHandler->isLocked('FakeIdentifier'));
     $this->assertFalse($this->lockHandler->wasLocked('FakeIdentifier'));
     $machine->triggerEvent('goPending', 'FakeIdentifier');
     usleep(800000);
     // 0.8s
     $history = $machine->resolveTimeouts();
     // no expires, nothing to do
     $this->assertEquals([], $history);
     usleep(1500000);
     // 1.5s
     $history = $machine->resolveTimeouts();
     // now expired
     $this->assertEquals(['FakeIdentifier' => ['new', 'pending', 'error', 'pending', 'done']], $history);
     $this->assertTrue($this->payloadHandler->wasStored());
     $this->assertFalse($this->lockHandler->isLocked('FakeIdentifier'));
     $this->assertTrue($this->lockHandler->wasLocked('FakeIdentifier'));
 }