Пример #1
0
 public function testReadFromTmpFile()
 {
     $yamlFile = MockTest::mockFile('anyFile.yml');
     $structure = MockTest::mockFileSystem([md5($yamlFile) . '.php' => "<?php return ['anyArray'];"]);
     MockTest::inject($this->yaml, 'tmpDir', $structure);
     $this->assertEquals(['anyArray'], $this->yaml->parse($yamlFile));
 }
Пример #2
0
 public function testGetAdminExtensionsRouteYaml()
 {
     $structure = ['Menu' => ['router.yml' => '', 'conf.yml' => ''], 'Post' => ['router.yml' => '', 'conf.yml' => ''], 'Page' => ['conf.yml' => '']];
     $this->_adminExtension = new AdminExtension(MockTest::mockFileSystem($structure));
     MockTest::inject($this->_adminExtension, 'extensionsArray', ['Menu', 'Page', 'Post']);
     $this->assertEquals(['vfs://mock/Menu/router.yml', 'vfs://mock/Post/router.yml'], $this->_adminExtension->getAdminExtensionsRouteYaml());
 }
Пример #3
0
 public function testLoadHttp()
 {
     MockTest::inject($this->_load, 'conf', ['conf' => ['tmp' => ['router' => MockTest::mockFileSystem([''])]]]);
     MockTest::inject($this->_load, 'routerYaml', MockTest::mockFile('router.yml'));
     $this->_load->loadHttp();
     $this->assertInstanceOf('App\\Resource\\Http', \PHPUnit_Framework_Assert::readAttribute($this->_load, 'http'));
 }
Пример #4
0
    public function testActive()
    {
        RegistryFactory::start()->set('http', $this->mockHttp('Page', 'admin-post-add'));
        $structure = ['Post' => ['conf.yml' => ''], 'Page' => ['conf.yml' => <<<EOT
menu:
    - {title: Add new post, url: admin-post-add, tokens: {action: add}}
    - {title: Add new post 2, url: admin-post-add-2, tokens: {action: add-2}}
EOT
]];
        $this->admin = new Admin($this->mockAdminExtension(MockTest::mockFileSystem($structure), ['Post', 'Page']), new Yaml());
        $this->assertEquals([0 => ['active' => false], 1 => ['active' => true, 'menu' => [0 => ['active' => true, 'title' => 'Add new post', 'url' => 'generatedUrl'], 1 => ['active' => false, 'title' => 'Add new post 2', 'url' => 'generatedUrl']]]], $this->admin->getAdminMenu());
    }