li3 create test model Posts li3 create --library=li3_plugin test model Posts
Наследование: extends lithium\console\command\Create
Пример #1
0
    public function testTestModelWithMethods()
    {
        $this->_cleanUp();
        mkdir($this->_testPath . '/create_test/models/', 0755, true);
        file_put_contents($this->_testPath . '/create_test/models/Post.php', "<?php\nnamespace create_test\\models;\n\nclass Post {\n\tpublic function someMethod() {}\n}");
        $this->request->params += array('command' => 'create', 'action' => 'test', 'args' => array('model', 'Post'));
        $test = new Test(array('request' => $this->request, 'classes' => $this->classes));
        $test->path = $this->_testPath;
        $test->run('test');
        $expected = "PostTest created in create_test\\tests\\cases\\models.\n";
        $result = $test->response->output;
        $this->assertEqual($expected, $result);
        $expected = <<<'test'


namespace create_test\tests\cases\models;

use \create_test\models\Post;

class PostTest extends \lithium\test\Unit {

	public function setUp() {}

	public function tearDown() {}

	public function testSomeMethod() {}
}


test;
        $replace = array("<?php", "?>");
        $result = str_replace($replace, '', file_get_contents($this->_testPath . '/create_test/tests/cases/models/PostTest.php'));
        $this->assertEqual($expected, $result);
    }
Пример #2
0
    public function testMockModel()
    {
        $test = new Test(array('request' => $this->request, 'classes' => $this->classes));
        $test->path = $this->_testPath;
        $test->mock('model', 'Post');
        $expected = "MockPost created for Post in create_test\\tests\\mocks\\models.\n";
        $result = $test->response->output;
        $this->assertEqual($expected, $result);
        $expected = <<<'test'


namespace create_test\tests\mocks\models;

class MockPost extends \create_test\models\Post {


}


test;
        $replace = array("<?php", "?>");
        $result = str_replace($replace, '', file_get_contents($this->_testPath . '/create_test/tests/mocks/models/MockPost.php'));
        $this->assertEqual($expected, $result);
    }
Пример #3
0
    public function testTestModelWithMethods()
    {
        $this->_cleanUp();
        mkdir($this->_testPath . '/create_test/models/', 0755, true);
        $id = rand();
        $path = "create_test/models/Post{$id}s.php";
        $body = <<<EOD
<?php
namespace create_test\\models;

class Post{$id}s {
\tpublic function someMethod() {}
}
EOD;
        file_put_contents("{$this->_testPath}/{$path}", $body);
        $this->request->params += array('command' => 'create', 'action' => 'test', 'args' => array('model', "Post{$id}s"));
        $test = new Test(array('request' => $this->request, 'classes' => $this->classes));
        $test->path = $this->_testPath;
        $test->run('test');
        $expected = "Post{$id}sTest created in tests/cases/models/Post{$id}sTest.php.\n";
        $result = $test->response->output;
        $this->assertEqual($expected, $result);
        $expected = <<<EOD


namespace create_test\\tests\\cases\\models;

use create_test\\models\\Post{$id}s;

class Post{$id}sTest extends \\lithium\\test\\Unit {

\tpublic function setUp() {}

\tpublic function tearDown() {}

\tpublic function testSomeMethod() {}
}


EOD;
        $replace = array("<?php", "?>");
        $path = "create_test/tests/cases/models/Post{$id}sTest.php";
        $result = str_replace($replace, '', file_get_contents("{$this->_testPath}/{$path}"));
        $this->assertEqual($expected, $result);
    }