I think the application /lib/lib/Cake/Console/Command/TestShellTest.php could be a link.
1, create a file in the application /Test/Case/Console/Command/yourfile.php, specify your classes using App::uses('your class', 'relative path').
eg:
App::uses('yourShellClass', 'Console/Command'); App::uses('ShellDispatcher', 'Console'); App::uses('Shell', 'Console');
2, write a layout for class B from your wrapper class A, whose use function returns data in class A. For example:
class TestYourShellClass extends YourShellClass { public function F1 ($parms){
3, write a class A test class, you need to run it at startup. eg:
class YourShellClassTest extends CakeTestCase { public function setUp() { parent::setUp(); $out = $this->getMock('ConsoleOutput', [], [], '', false); $in = $this->getMock('ConsoleInput', [], [], '', false); $this->Shell = $this->getMock( // this is your class B, which mocks class A. 'TestYourShellClass', ['in', 'out', 'hr', 'help', 'error', 'err', '_stop', 'initialize', '_run', 'clear'], [$out, $out, $in] ); $this->Shell->OptionParser = $this->getMock('ConsoleOptionParser', [], [null, false]); } /** * tear down method. * * @return void */ public function tearDown() { parent::tearDown(); unset($this->Dispatch, $this->Shell); } }
4, the test function may be like this.
public function testF1() { $this->Shell->startup(); $return = $this->Shell->F1(); $expectedSellerCount = 14; $this->assertSame($expectedSellerCount, $return); }
and then you can view the result at http: //yourdomain/test.php