I created the shell program app/Console/Command/TestShell.php in cakephp2.x.
The shell itself works, but when I launch the PHPUnit test code from my browser, it turns white and error.log shows the following error:
Error: Fatal Error (1): Class 'AppShell' not found in
Error: [FatalErrorException] Class 'AppShell' not found
The PHPUnit setUp() is written on the Internet without knowing it well, so please let me know if you know anything.
■ Shell Program app/Console/Command/TestShell.php
App::uses('ComponentCollection', 'Controller');
App::uses('TestCommonComponent', 'Controller/Component');
class TestShell extensions AppShell {
public$uses=array(
'TestModel 1',
'TestModel 2'
);
public function startup() {
parent::startup();
}
public function main() {
■ PHPUnit
app/Test/Case/Console/Command/TestShellTest.php
<?php
App::uses('ConsoleOutput','Console');
App::uses('ShellDispatcher', 'Console');
App::uses('Shell', 'Console');
App::uses('Folder', 'Utility');
App::uses('TestShell', 'Console/Command');
class TestShellTest extensions CakeTestCase {
public$target;
public function setUp(){
parent::setUp();
$output=$this->getMock('ConsoleOutput', array(), array(), '', false);
$error=$this->getMock('ConsoleOutput', array(), array(), '', false);
$in = $this->getMock('ConsoleInput', array(), array(), '', false);
$this->target=new TestShell($output,$error,$in);
$this->target->initialize();
}
public function tearDown(){
parent::tearDown();
}
public function testCommon() {
// Write a test here
$this->assertEquals(0,0);
}
}
The PHPUnit is now working by adding App::uses('AppShell', 'Console/Command'); on the shell side.
911 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
581 PHP ssh2_scp_send fails to send files as intended
610 GDB gets version error when attempting to debug with the Presense SDK (IDE)
572 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
© 2024 OneMinuteCode. All rights reserved.