1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- <?php
- /**
- * Lithium: the most rad php framework
- *
- * @copyright Copyright 2013, Union of RAD (http://union-of-rad.org)
- * @license http://opensource.org/licenses/bsd-license.php The BSD License
- */
- namespace lithium\tests\cases\console\command\create;
- use lithium\console\command\create\Model;
- use lithium\console\Request;
- use lithium\core\Libraries;
- class ModelTest extends \lithium\test\Unit {
- public $request;
- protected $_backup = array();
- protected $_testPath = null;
- public function skip() {
- $this->_testPath = Libraries::get(true, 'resources') . '/tmp/tests';
- $this->skipIf(!is_writable($this->_testPath), "Path `{$this->_testPath}` is not writable.");
- }
- public function setUp() {
- $this->classes = array('response' => 'lithium\tests\mocks\console\MockResponse');
- $this->_backup['cwd'] = getcwd();
- $this->_backup['_SERVER'] = $_SERVER;
- $_SERVER['argv'] = array();
- Libraries::add('create_test', array('path' => $this->_testPath . '/create_test'));
- $this->request = new Request(array('input' => fopen('php://temp', 'w+')));
- $this->request->params = array('library' => 'create_test');
- }
- public function tearDown() {
- $_SERVER = $this->_backup['_SERVER'];
- chdir($this->_backup['cwd']);
- $this->_cleanUp();
- }
- public function testClass() {
- $this->request->params = array(
- 'command' => 'model', 'action' => 'Posts'
- );
- $model = new Model(array(
- 'request' => $this->request, 'classes' => $this->classes
- ));
- $expected = 'Posts';
- $result = $model->invokeMethod('_class', array($this->request));
- $this->assertEqual($expected, $result);
- }
- }
- ?>
|