Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Jan 8, 2020. It is now read-only.

Commit b6e3458

Browse files
committed
Merge branch 'hotfix/6335' into develop
Forward port #6335
2 parents 2dde132 + 1f1f189 commit b6e3458

2 files changed

Lines changed: 48 additions & 1 deletion

File tree

library/Zend/Db/RowGateway/RowGateway.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ class RowGateway extends AbstractRowGateway
2525
*/
2626
public function __construct($primaryKeyColumn, $table, $adapterOrSql = null)
2727
{
28+
2829
// setup primary key
29-
$this->primaryKeyColumn = (array) $primaryKeyColumn;
30+
$this->primaryKeyColumn = empty($primaryKeyColumn) ? null : (array) $primaryKeyColumn;
3031

3132
// set table
3233
$this->table = $table;
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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

Comments
 (0)