DataSift\Storyplayer\ConfigLib\WrappedConfigTest::testCanGetArrayFromAnAssocArray PHP Method

testCanGetArrayFromAnAssocArray() public method

    public function testCanGetArrayFromAnAssocArray()
    {
        // ----------------------------------------------------------------
        // setup your test
        //
        // this one will need some explaining
        //
        // in PHP, we can declare associative arrays. however, these are
        // converted to objects as part of our support for expanding
        // Twig variables in the config
        //
        // - we use json_encode() to create the text that Twig operates on
        // - json_encode() has to turn assoc arrays into objects
        // - if we used serialize(), then the assoc arrays would not change
        //   into objects
        // - we cannot use serialize() because the format includes
        //   run-length encoding ... and expanding Twig variables breaks
        //   that :(
        //
        // as a workaround, we assume that the caller knows what they are
        // doing, and if the dot.notation.path resolves to an object, we
        // convert it to an array before returning it
        //
        // we *could* walk the non-Twigged data to check that it is an
        // array, but in all honesty ... why go to the extra effort?
        $obj = new WrappedConfig();
        $config = $obj->getConfig();
        $config->phases = ["Startup" => true, "Shutdown" => false];
        $expected = $config->phases;
        // ----------------------------------------------------------------
        // perform the change
        $actual = $obj->getArray("phases");
        // ----------------------------------------------------------------
        // test the results
        $this->assertEquals($expected, $actual);
    }
WrappedConfigTest