|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Zend Framework (http://framework.zend.com/) |
| 4 | + * |
| 5 | + * @link http://github.com/zendframework/zf2 for the canonical source repository |
| 6 | + * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) |
| 7 | + * @license http://framework.zend.com/license/new-bsd New BSD License |
| 8 | + */ |
| 9 | + |
| 10 | +namespace ZendTest\Db\RowGateway; |
| 11 | + |
| 12 | +use ReflectionObject; |
| 13 | +use PHPUnit_Framework_TestCase; |
| 14 | +use Zend\Db\RowGateway\RowGateway; |
| 15 | + |
| 16 | +class RowGatewayTest extends PHPUnit_Framework_TestCase |
| 17 | +{ |
| 18 | + protected $mockAdapter; |
| 19 | + protected $rowGateway; |
| 20 | + |
| 21 | + public function setup() |
| 22 | + { |
| 23 | + // mock the adapter, driver, and parts |
| 24 | + $mockResult = $this->getMock('Zend\Db\Adapter\Driver\ResultInterface'); |
| 25 | + $mockResult->expects($this->any())->method('getAffectedRows')->will($this->returnValue(1)); |
| 26 | + $this->mockResult = $mockResult; |
| 27 | + |
| 28 | + $mockStatement = $this->getMock('Zend\Db\Adapter\Driver\StatementInterface'); |
| 29 | + $mockStatement->expects($this->any())->method('execute')->will($this->returnValue($mockResult)); |
| 30 | + |
| 31 | + $mockConnection = $this->getMock('Zend\Db\Adapter\Driver\ConnectionInterface'); |
| 32 | + |
| 33 | + $mockDriver = $this->getMock('Zend\Db\Adapter\Driver\DriverInterface'); |
| 34 | + $mockDriver->expects($this->any())->method('createStatement')->will($this->returnValue($mockStatement)); |
| 35 | + $mockDriver->expects($this->any())->method('getConnection')->will($this->returnValue($mockConnection)); |
| 36 | + |
| 37 | + // setup mock adapter |
| 38 | + $this->mockAdapter = $this->getMock('Zend\Db\Adapter\Adapter', null, array($mockDriver)); |
| 39 | + } |
| 40 | + |
| 41 | + public function testEmptyPrimaryKey() |
| 42 | + { |
| 43 | + $this->setExpectedException('Zend\Db\RowGateway\Exception\RuntimeException', 'This row object does not have a primary key column set.'); |
| 44 | + $this->rowGateway = new RowGateway('', 'foo', $this->mockAdapter); |
| 45 | + } |
| 46 | +} |
0 commit comments