Exemplo n.º 1
0
    protected function install($appBasePath, $appNamespace, $path)
    {
        $installer = new SkeletonBuilder($appBasePath, __DIR__ . '/../skeleton');
        $replacers = ['YourOwnApp' => $appNamespace, '{path}' => $path, '%%origin%%' => new OriginReplacer()];
        $installer->build($replacers);
        file_put_contents($appBasePath . '/.wandu.php', <<<PHP
<?php
return new {$appNamespace}\\ApplicationDefinition();

PHP
);
    }
Exemplo n.º 2
0
    public function testBuild()
    {
        $builder = new SkeletonBuilder(__DIR__ . '/target', __DIR__ . '/skeleton');
        $randNumber = rand(0, 100);
        $builder->build(['___NAMESPACE___' => 'Wandu\\App', '___controller(\\d+)___' => function ($matches) use($randNumber) {
            return 'User' . ($matches[1] + $randNumber);
        }, '%%source%%' => new OriginReplacer()]);
        $this->assertTrue(is_dir(__DIR__ . '/target'));
        $this->assertTrue(is_dir(__DIR__ . '/target/cache'));
        $this->assertTrue(file_exists(__DIR__ . '/target/cache/.gitkeep'));
        $assertNumber = 30 + $randNumber;
        $this->assertEquals(<<<PHP
<?php
namespace Wandu\\App;

class Hello
{
    public function getUser{$assertNumber}()
    {
        return 'user';
    }
}

PHP
, file_get_contents(__DIR__ . '/target/Hello.php'));
        $this->assertEquals(<<<GITIGNORE
composer.lock
others


/new
/what

GITIGNORE
, file_get_contents(__DIR__ . '/target/.gitignore'));
    }