Browse Source

Edited test associated with that fix

Jonathan Boyer 12 years ago
parent
commit
7f7d725a21
2 changed files with 5 additions and 6 deletions
  1. 3 4
      src/ORM/Table.php
  2. 2 2
      tests/TestCase/ORM/TableTest.php

+ 3 - 4
src/ORM/Table.php

@@ -887,10 +887,9 @@ class Table implements EventListener {
  */
 	public function get($primaryKey, $options = []) {
 		$key = (array)$this->primaryKey();
-		if (!empty($this->_alias)) {
-			foreach($key as $index => $keyname){
-				$key[$index] = $this->_alias . '.' . $keyname;
-			}
+		$alias = $this->alias();
+		foreach ($key as $index => $keyname) {
+			$key[$index] = $alias . '.' . $keyname;
 		}
 		$conditions = array_combine($key, (array)$primaryKey);
 		$entity = $this->find('all', $options)->where($conditions)->first();

+ 2 - 2
tests/TestCase/ORM/TableTest.php

@@ -3045,7 +3045,7 @@ class TableTest extends \Cake\TestSuite\TestCase {
 			->will($this->returnValue($query));
 
 		$query->expects($this->once())->method('where')
-			->with(['bar' => 10])
+			->with([$table->alias() . '.bar' => 10])
 			->will($this->returnSelf());
 		$query->expects($this->once())->method('first')
 			->will($this->returnValue($entity));
@@ -3088,7 +3088,7 @@ class TableTest extends \Cake\TestSuite\TestCase {
 			->will($this->returnValue($query));
 
 		$query->expects($this->once())->method('where')
-			->with(['bar' => 10])
+			->with([$table->alias() . '.bar' => 10])
 			->will($this->returnSelf());
 		$query->expects($this->once())->method('first')
 			->will($this->returnValue(false));