/** * @test */ public function shouldBeAbleToLoadConfigurationAndTestSomeGettersAndSetters() { $redis = new Redis(); $redis->setDatabase(15); //clear the redis database for testing $redis->flushdb(); $machine = new StateMachine(new Context(new Identifier(1, 'test-machine'), null, $redis)); //create the loader //get the configuration from the json file $configuration = file_get_contents(__DIR__ . '/../loader/fixture-example.json'); //set it. normally, this would be done by a seperate process that has already loaded the configuration $redis->set(Redis::KEY_CONFIGURATION, $configuration); //load the machine $count = $redis->load($machine); $this->assertEquals(4, $count, 'expect 4 transitions to be loaded'); $this->assertCount(4, $machine->getTransitions(), 'there is a regex transition that adds 2 transitions (a-c and b-c)'); $this->assertCount(4, $machine->getStates()); $this->assertNotNull($redis->toString()); $this->assertNotNull($redis . ''); $redis->setConfigurationKey("bogus"); $this->assertEquals("bogus", $redis->getConfigurationKey()); $redis->setPrefix("foobar"); $this->assertEquals("foobar", $redis->getPrefix()); }