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

Commit

Permalink
Merge branch 'hotfix/5857' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
weierophinney committed Apr 14, 2014
3 parents f375652 + 4407fb8 + 0882e33 commit 63af384
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Db/AbstractDb.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ public function getExclude()
public function setExclude($exclude)
{
$this->exclude = $exclude;
$this->select = null;
return $this;
}

Expand All @@ -210,7 +211,8 @@ public function getField()
*/
public function setField($field)
{
$this->field = (string) $field;
$this->field = (string) $field;
$this->select = null;
return $this;
}

Expand All @@ -232,7 +234,8 @@ public function getTable()
*/
public function setTable($table)
{
$this->table = (string) $table;
$this->table = (string) $table;
$this->select = null;
return $this;
}

Expand All @@ -255,6 +258,7 @@ public function getSchema()
public function setSchema($schema)
{
$this->schema = $schema;
$this->select = null;
return $this;
}

Expand Down
35 changes: 35 additions & 0 deletions test/Db/RecordExistsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,4 +273,39 @@ public function testGetSelect()
$this->assertNull($parameters['where1']);
$this->assertEquals($parameters['where2'], 'bar');
}

/**
* @cover Zend\Validator\Db\RecordExists::getSelect
* @group ZF2-4521
*/
public function testGetSelectWithSameValidatorTwice()
{
$validator = new RecordExists(
array(
'table' => 'users',
'schema' => 'my'
),
'field1',
array(
'field' => 'foo',
'value' => 'bar'
),
$this->getMockHasResult()
);
$select = $validator->getSelect();
$this->assertInstanceOf('Zend\Db\Sql\Select', $select);
$this->assertEquals('SELECT "my"."users"."field1" AS "field1" FROM "my"."users" WHERE "field1" = \'\' AND "foo" != \'bar\'', $select->getSqlString(new TrustingSql92Platform()));

// same validator instance with changing properties
$validator->setTable('othertable');
$validator->setSchema('otherschema');
$validator->setField('fieldother');
$validator->setExclude(array(
'field' => 'fieldexclude',
'value' => 'fieldvalueexclude',
));
$select = $validator->getSelect();
$this->assertInstanceOf('Zend\Db\Sql\Select', $select);
$this->assertEquals('SELECT "otherschema"."othertable"."fieldother" AS "fieldother" FROM "otherschema"."othertable" WHERE "fieldother" = \'\' AND "fieldexclude" != \'fieldvalueexclude\'', $select->getSqlString(new TrustingSql92Platform()));
}
}

0 comments on commit 63af384

Please # to comment.