ZS PHPUnit db test error with DefaultTableIterator

General discussion on Zend Studio

ZS PHPUnit db test error with DefaultTableIterator

Postby chiefbeef on Sun Oct 28, 2012 8:30 pm

Hi, i'm having some problems trying to run my unit tests on Zend Studio 8 with phpunit and zf 1.11

The test is just a simple assertion to confirm the environment is set up correctly, but i am getting the following error:

ZendPHPUnitUserErrorException: Argument 1 passed to PHPUnit_Extensions_Database_Dataset_DefaultTableIterator::__construct() must be an array, null given, called in [path to zend studio plugin]
(then in the trace failure, underneath the above line:)
PHPUnit_Extensions_Database_Dataset_AbstractDataSet->getReverseIterator()

I am fairly sure my set up is correct.

My test bootstrap:
Code: Select all

error_reporting(E_ALL | E_STRICT);

// Define path to application directory
defined('APPLICATION_PATH')
    || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));

// Define application environment
defined('APPLICATION_ENV')
    || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'testing'));

// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
    realpath(APPLICATION_PATH . '/../library'),
    get_include_path(),
)));

require_once 'Zend/Loader/Autoloader.php';
Zend_Loader_Autoloader::getInstance();
require_once 'Zend/Application.php';


and my test case, with a simple true assertion:

Code: Select all
        class UserMapperTest extends Zend_Test_PHPUnit_DatabaseTestCase
        {
                /**
                 *
                 * @var PHPUnit_Extensions_Database_DB_IDatabaseConnection
                 */
                protected $_connection;
               
                public function testFoo(){
                        $this->assertTrue(true);
                }
               
               
                /**
                 * Returns the test database connection.
                 *
                 * @return PHPUnit_Extensions_Database_DB_IDatabaseConnection
                 */
                protected function getConnection(){
                       
                        if (empty($this->_connection)) {
                               
                    $app = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
                    $app->bootstrap();
                    $options = $app->getOptions();
                    $schema = $options['resources']['db']['params']['dbname'];
                    $db = $app->getBootstrap()->getPluginResource('db');
                    $dbAdapter = $db->getDbAdapter();
                    $this->_connection = $this->createZendDbConnection($dbAdapter, $schema);
                }
               
                return $this->_connection;
                }
               
                /**
                 * @return PHPUnit_Extensions_Database_DataSet_IDataSet
                 */
                protected function getDataSet(){
                return $this->createXmlDataSet(dirname(__FILE__) . DIRECTORY_SEPARATOR
                . 'fixtures' . DIRECTORY_SEPARATOR
                . 'seed.xml');
                }
        }



What am i doing wrong?
chiefbeef
 
Posts: 42
Joined: Wed Jul 29, 2009 9:04 pm

Re: ZS PHPUnit db test error with DefaultTableIterator

Postby chiefbeef on Thu Jan 10, 2013 3:09 pm

Has anyone got any ideas or suggestions for this problem? I'm now using Zs 9.0.4 and the problem persists, i was hoping that upgrading would have resolved it. It's very annoying.
chiefbeef
 
Posts: 42
Joined: Wed Jul 29, 2009 9:04 pm


Return to Zend Studio

Who is online

Users browsing this forum: No registered users and 8 guests