Are you executing all the steps exactly like in your ".travis.yml"?
Also, this looks like the mock could not be instantiated correctly. Autoloading problem? Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/ On 28 January 2013 19:06, jmleroux <jmleroux....@gmail.com> wrote: > Hi, > > I'm trying to test some Db components with PHPUnit and i've got some > trouble > with Travis-CI about type hinting. > > Here is the error message : > > 1) ZfcRbacTest\Provider\AdjacencyList\Role\DbTest::testNoRoles > Argument 1 passed to ZfcRbac\Provider\AdjacencyList\Role\Db::__construct() > must be an instance of Zend\Db\Adapter\AdapterInterface, instance of > Mock_Adapter_c7632875 given, called in > > /home/travis/build/ZF-Commons/ZfcRbac/tests/ZfcRbacTest/Provider/AdjacencyList/Role/DbTest.php > > > But i got no error when i run phpunit on my machine. > > My configuration : > php 5.4 > phpunit 3.7.13 > > error_reporting = E_ALL > > > The error is triggered in the setUp method of my test : > > > <?php > > namespace ZfcRbacTest\Provider\AdjacencyList\Role; > > use ZfcRbac\Service\Rbac as RbacService; > use ZfcRbac\Provider\AdjacencyList\Role\Db; > > use ZfcRbacTest\Bootstrap; > use ZfcRbacTest\RbacServiceTestCase; > > class DbTest extends RbacServiceTestCase > { > // mock adapter > protected $_mockAdapter; > > /** > * @var Db > */ > protected $_db; > > public function setUp() > { > $rbacService = new RbacService(); > self::setRbacService($rbacService); > > Bootstrap::getServiceManager()->setAllowOverride(true); > Bootstrap::getServiceManager()->setService('ZfcRbac\Service\Rbac', > $rbacService); > > // mock the adapter, driver, and parts > $mockConnection = > $this->getMock('Zend\Db\Adapter\Driver\ConnectionInterface'); > $this->_mockDriver = > $this->getMock('Zend\Db\Adapter\Driver\DriverInterface'); > > > $this->_mockDriver->expects($this->any())->method('getConnection')->will($this->returnValue($mockConnection)); > $this->_mockAdapter = $this->getMock('Zend\Db\Adapter\Adapter', > null, array($this->_mockDriver)); > > // set up Db > $this->_db = new Db($this->_mockAdapter, array()); > } > > /** > * Test exception when no role can be loaded > * @return boolean > */ > public function testNoRoles() > { > // here goes my test > } > } > > and the Db class : > > class Db extends AbstractProvider > { > /** @var AdapterInterface */ > protected $_adapter; > > /** > * @var array > */ > protected $roles; > > /** > * @var CommonOptions > */ > protected $_options; > > /** > * @param Connection $connection > * @param array $options > */ > public function __construct(AdapterInterface $adapter, array $options) > { > $this->_adapter = $adapter; > $this->_options = new DbOptions($options); > } > > } > > > I don't understand the difference between my platform and Travis. > > Any idea ? > > Thanks, > > JM Leroux > > PS : the whole story can be read here : > https://github.com/ZF-Commons/ZfcRbac/pull/37 > > > > -- > View this message in context: > http://zend-framework-community.634137.n4.nabble.com/ZF2-PHPUnit-mocks-Zend-Db-Adapter-and-Travis-CI-type-hinting-tp4658864.html > Sent from the Zend Framework mailing list archive at Nabble.com. > > -- > List: fw-general@lists.zend.com > Info: http://framework.zend.com/archives > Unsubscribe: fw-general-unsubscr...@lists.zend.com > > >