setState() public method

Sets the state
public setState ( string $state, string $message = null ) : boolan
$state string
$message string optional message. this can be used by the persistence adapter to be part of the transition history to provide extra information about the transition.
return boolan true if there was never any state persisted for this machine before (just added for the first time), false otherwise
 /**
  * test the factory method with all parameters provided
  * implicitely tests the constructor
  */
 public function testContext()
 {
     $entity_id = "id1";
     $machine = "test machine";
     $identifier = new Identifier($entity_id, $machine);
     $builder = new EntityBuilder();
     $io = new Memory();
     // all parameters
     $o = new Context($identifier, $builder, $io);
     $this->assertEquals($entity_id, $o->getEntityId());
     $this->assertEquals($machine, $o->getMachine());
     $this->assertNull($o->getStateMachine());
     $this->assertTrue(is_a($o->getPersistenceAdapter(), 'izzum\\statemachine\\persistence\\Memory'));
     $this->assertTrue(is_a($o->getBuilder(), 'izzum\\statemachine\\EntityBuilder'));
     $this->assertEquals($identifier, $o->getEntity());
     $this->assertTrue(is_string($o->getEntityId()));
     $this->assertTrue(is_string($o->toString()));
     $this->assertContains($entity_id, $o->toString());
     $this->assertContains($machine, $o->toString());
     $this->assertContains('izzum\\statemachine\\Context', $o->toString());
     // even though we have a valid reader, the state machine does not exist.
     $this->assertEquals(State::STATE_UNKNOWN, $o->getState());
     $this->assertTrue($o->setState(State::STATE_NEW, 'this is an informational message about why we set this state: we set this state to new for a unittest'), 'added');
     $this->assertFalse($o->setState(State::STATE_NEW), 'already there');
     // for coverage.
     $statemachine = new StateMachine($o);
     $this->assertNull($o->setStateMachine($statemachine));
     $this->assertContains('Context', $o . '', '__toString()');
 }