izzum\statemachine\loader\ArrayLoaderTest::testLoaderArray PHP Метод

testLoaderArray() публичный Метод

public testLoaderArray ( )
    public function testLoaderArray()
    {
        //scenario: test loader supported stuff
        $loader = new LoaderArray();
        $this->assertContains('LoaderArray', $loader->toString());
        $this->assertContains('LoaderArray', $loader . '', '__toString');
        $this->assertEquals(0, $loader->count());
        //scenario: configure loader
        $transitions = array();
        $s1 = new State("1");
        $s2 = new State("2");
        $s3 = new State("3");
        $transitions[] = new Transition($s1, $s2);
        $transitions[] = new Transition($s2, $s3);
        $loader = new LoaderArray($transitions);
        $this->assertEquals(count($transitions), $loader->count());
        //scenario: configure loader with bad object types
        $transitions = array();
        $transitions[] = new Transition($s2, $s3);
        $transitions[] = new \stdClass();
        try {
            $loader = new LoaderArray($transitions);
            $this->fail('fails cause not the right type');
        } catch (Exception $e) {
            $this->assertEquals(Exception::BAD_LOADERDATA, $e->getCode());
        }
    }