JamesMoss\Flywheel\NestedRespositoryTest::testGettingNestedDocuments PHP Method

testGettingNestedDocuments() public method

    public function testGettingNestedDocuments()
    {
        exec('rm -rf /tmp/flywheel/_dummy');
        $config = new Config('/tmp/flywheel');
        $repo = new NestedRepository('_dummy', $config);
        $IDs = array_flip(array('some/asd/4364as/asa_sd', 'some/asd/4364as', 'asd/4364as/asa_sd', 'some/asd/lklkljd/as', 'nmnmn'));
        $path = '/tmp/flywheel/_dummy/';
        foreach ($IDs as $id => $index) {
            if (!is_dir(dirname($path . $id))) {
                mkdir(dirname($path . $id), 0777, true);
            }
            file_put_contents($path . $id . '.json', json_encode(array('name' => 'Joe Bloggs')));
        }
        foreach ($repo->findAll() as $doc) {
            $this->assertArrayHasKey($doc->getId(), $IDs);
            unset($IDs[$doc->getId()]);
        }
    }