Missing abstract methods error when testing database with DbUnit extension in Zend Framework

I have the following error after starting a basic database test in Zend Framework with phpUnit

PHP Fatal error:  Class Zend_Test_PHPUnit_Db_Metadata_Generic contains 2 abstract methods and must therefore be declared abstract or implement the remaining methods (PHPUnit_Extensions_Database_DB_IMetaData::disablePrimaryKeys, PHPUnit_Extensions_Database_DB_IMetaData::enablePrimaryKeys) in D:\www\~library\zend_latest\library\Zend\Test\PHPUnit\Db\Metadata\Generic.php on line 167

My test is very similar to one of the ZF documentation:

class BugsTest extends Zend_Test_PHPUnit_DatabaseTestCase
{
private $_connectionMock;

/**
 * Returns the test database connection.
 *
 * @return PHPUnit_Extensions_Database_DB_IDatabaseConnection
 */
protected function getConnection()
{
    if($this->_connectionMock == null) {
        $connection = Zend_Db::factory(...);
        $this->_connectionMock = $this->createZendDbConnection(
            $connection, 'zfunittests'
        );
        Zend_Db_Table_Abstract::setDefaultAdapter($connection);
    }
    return $this->_connectionMock;
}

/**
 * @return PHPUnit_Extensions_Database_DataSet_IDataSet
 */
protected function getDataSet()
{
    return $this->createFlatXmlDataSet(
        dirname(__FILE__) . '/_files/bugsSeed.xml'
    );
}
}

My "fix" for the problem was to not impelemt PHPUnit_Extensions_Database_DB_IMetaDatain the library Zend_Test_PHPUnit_Db_Metadata_Generic. Now everything is working fine, but I'm wondering if there is a suitable way to solve this problem.

I am using ZF 11.11, phpUnit 3.6.10 and DbUnit 1.1.2.

+3
source share
2 answers

Zend 1.11 does not support PHPUnit 3.6, you need to lower the value of PHPUnit 3.5 or 3.4.

PHPUnit , http://dustyreagan.com/downgrade-phpunit-3-6-to-3-5-15/

. http://framework.zend.com/issues/browse/ZF-11781

+2

PHPUnit 3.4 3.5 ( http://framework.zend.com/issues/browse/ZF-11828).

PHPUnit. , PHPUnit/3.5 /opt:

sudo pear config-set auto_discover 1
sudo pear install --installroot /opt/phpunit35 pear.phpunit.de/PHPUnit-3.5.15
sudo ln -s /opt/phpunit35/usr/bin/phpunit /usr/local/bin/phpunit35

/opt/phpunit35/usr/bin/phpunit, . :

// Ubuntu / Debian
set_include_path(implode(PATH_SEPARATOR, array(
    dirname(__FILE__) . '/../share/php',
    get_include_path()
)));

// CentOS
set_include_path(implode(PATH_SEPARATOR, array(
    dirname(__FILE__) . '/../share/pear',
    get_include_path()
)));

PHPUnit/3.5 , phpunit35.

, ZF/1.11 - PHPUnit/3.4; 3.5, , , , .

, (, Jenkins, Makefiles IDE), phpunit35 phpunit .

: http://tech.vg.no/2011/11/29/running-multiple-versions-of-phpunit/

+2

All Articles