示例#1
0
    /**
     * testExtensionProvider
     *
     * @return  void
     */
    public function testExtensionProvider()
    {
        $this->controller->getInput()->set('paths', array('extension'));
        $compare = <<<HTML
Hello, sakura
HTML;
        $this->assertStringDataEquals($compare, $this->controller->execute());
    }
示例#2
0
    /**
     * testMarkdown
     *
     * @return  void
     */
    public function testMarkdown()
    {
        $this->controller->getInput()->set('paths', array('flower', 'markdown'));
        $compare = <<<HTML
<h1>Test Heading</h1>
<p>This is paragraph</p>
<p><a href="foo.html">This is link</a></p>
HTML;
        $this->assertStringDataEquals($compare, $this->controller->execute());
    }
示例#3
0
    public function testWithLayout()
    {
        $this->controller->getInput()->set('paths', array('olive', 'layout'));
        $compare = <<<HTML
<p>
\t<h2>Hello World</h2>
\t<p>test data</p>
\t<p><img src="img.jpg" alt="img" /></p>
</p>
HTML;
        $this->assertStringDataEquals($compare, $this->controller->execute());
    }
示例#4
0
 /**
  * doExecute
  *
  * @return  integer
  */
 protected function doExecute()
 {
     DateTimeHelper::setDefaultTimezone();
     $this->out()->out('Vaseman generator')->out('-----------------------------')->out()->out('<comment>Start generating site</comment>')->out();
     $controller = new GetController();
     $event = new Event('onBeforeRenderFiles');
     $event['config'] = $this->app->getConfig();
     $event['controller'] = $controller;
     $event['io'] = $this->io;
     Ioc::getDispatcher()->triggerEvent($event);
     $dataRoot = $this->app->get('project.path.data', WINDWALKER_ROOT);
     $folders = $this->app->get('folders', array());
     $controller->setPackage(PackageHelper::getPackage('vaseman'));
     $controller->setApplication($this->app);
     $assets = array();
     $processors = array();
     foreach ($folders as $folder) {
         $files = Filesystem::files($dataRoot . '/' . $folder, true);
         foreach ($files as $file) {
             $asset = new Asset($file, $dataRoot . '/' . $folder);
             $layout = Path::clean($asset->getPath(), '/');
             $input = new Input(array('paths' => explode('/', $layout)));
             $config = $controller->getConfig();
             $config->set('layout.path', $asset->getRoot());
             $config->set('layout.folder', $folder);
             $controller->setInput($input)->execute();
             $processors[] = $controller->getProcessor();
         }
     }
     $event->setName('onAfterRenderFiles');
     $event['processors'] = $processors;
     Ioc::getDispatcher()->triggerEvent($event);
     $event->setName('onBeforeWriteFiles');
     Ioc::getDispatcher()->triggerEvent($event);
     $dir = $this->getOption('dir');
     $dir = $dir ?: $this->app->get('outer_project') ? "" : 'output';
     $dir = $this->app->get('project.path.root') . '/' . $dir;
     /** @var AbstractFileProcessor $processor */
     foreach ($processors as $processor) {
         $file = Path::clean($dir . '/' . $processor->getTarget());
         $this->out('<info>Write file</info>: ' . $file);
         Folder::create(dirname($file));
         file_put_contents($file, $processor->getOutput());
     }
     $event->setName('onAfterWriteFiles');
     Ioc::getDispatcher()->triggerEvent($event);
     $this->out()->out('<info>Complete</info>')->out();
     return 0;
 }
示例#5
0
    /**
     * testPermalinkIndex
     *
     * @return  void
     */
    public function testParentLayout()
    {
        $this->controller->getInput()->set('paths', array('flower', 'index'));
        $compare = <<<HTML
<p>
\tFile: flower/index
\turi.base: ../
\turi.media: ../media/
</p>
HTML;
        $this->assertStringDataEquals($compare, $this->controller->execute());
    }