Navigation Menu

Skip to content

Commit

Permalink
Test to prove #7589
Browse files Browse the repository at this point in the history
  • Loading branch information
dakota committed Oct 21, 2015
1 parent 2cba8e6 commit bebed23
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/TestCase/ORM/QueryTest.php
Expand Up @@ -18,6 +18,7 @@
use Cake\Database\Expression\OrderByExpression;
use Cake\Database\Expression\QueryExpression;
use Cake\Database\TypeMap;
use Cake\Database\ValueBinder;
use Cake\Datasource\ConnectionManager;
use Cake\ORM\Query;
use Cake\ORM\ResultSet;
Expand Down Expand Up @@ -1551,6 +1552,28 @@ public function testCountBeforeFind()
$this->assertSame(3, $result);
}

/**
* test count with a beforeFind.
*
* @return void
*/
public function testBeforeFindCalledOnce()
{
$callCount = 0;
$table = TableRegistry::get('Articles');
$table->eventManager()
->attach(function ($event, $query) use (&$callCount) {
$valueBinder = new ValueBinder();
$query->sql($valueBinder);
$callCount++;
}, 'Model.beforeFind');

$query = $table->find();
$valueBinder = new ValueBinder();
$query->sql($valueBinder);
$this->assertSame(1, $callCount);
}

/**
* Test that count() returns correct results with group by.
*
Expand Down

0 comments on commit bebed23

Please sign in to comment.