Error when using SimpleTest Mock::generate()
Posted: Thu Jun 01, 2006 9:43 am
Wondering if anyone has any idea what the following error is in relation to...
Relevant parts (only started writing the test so not sure if that is a possible cause):
This could be a PHP error (not caused by test) but I ran several other test suites using Mocks under the same environment (using PHP 5.1.4) and no similar error occured. This test, like the others which ran without error, had error_reporting() set to E_ALL.
Anyone have any ideas?
Code: Select all
Fail: /opt/lampp/htdocs/quantumstar/trunk/Tests/Partholan/Test_DataObject.php -> Bad GroupTest [/opt/lampp/htdocs/quantumstar/trunk/Tests/Partholan/Test_DataObject.php] with error [Non-static method Mock::generate() should not be called statically, assuming $this from incompatible context]Code: Select all
<?php
// Simple Test files included earlier: unit_tester.php, mock_objects.php, reporter.php
require_once(APPROOT . 'Partholan/Abstracts/Parth_DataObject.php');
require_once(APPROOT . 'Partholan/Classes/Parth_DataAccess.php');
require_once(TESTROOT . 'Other/Item.php'); // simple Parth_DataObject child for testing
Mock::generate('Parth_DataAccess');
class Test_DataObject extends UnitTestCase {
private $item1;
private $item2;
public function __construct() {
$this->UnitTestCase('Test of DataObject');
// return values for future mocked DataAccess classes
$this->item1 = new Item(array('item_id'=>1,'item_name'=>'Test Item','item_text'=>'Test Item 001'), new MockParth_DataAccess());
$this->item2 = new Item(array('item_id'=>2,'item_name'=>'Test Item','item_text'=>'Test Item 002'), new MockParth_DataAccess());
}
public function setUp() {
}
public function tearDown() {
}
public function testGetByPk() {
$dao = new MockParth_DataAccess();
$do = new Item(array(), $dao);
$dao->expectOnce('getByPk', array($do, 1));
$dao->setReturnValue('getByPk', $this->item1);
$do->getByPk(1);
// DAO overwrites $do reference
$this->assertIsA($do, 'Parth_DataObject');
$this->assertEqual($do->getItemId(), 1);
$this->assertEqual($do->getItemName(), 'Test Item');
$this->assertEqual($do->getItemText(), 'Test Item 001');
}
}Anyone have any ideas?