mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 00:48:25 +00:00
Tweak/Add doc blocks.
This commit is contained in:
parent
e8683fdde5
commit
ecd270d04b
2 changed files with 33 additions and 2 deletions
|
@ -3453,7 +3453,8 @@ class Model extends CakeObject implements CakeEventListener {
|
|||
* - 3rd param: If 2nd argument is provided, a boolean flag for enabling/disabled
|
||||
* query caching.
|
||||
*
|
||||
* If the query cache param as 2nd or 3rd argument is not given then the model's default $cacheQueries value is used.
|
||||
* If the query cache param as 2nd or 3rd argument is not given then the model's
|
||||
* default `$cacheQueries` value is used.
|
||||
*
|
||||
* @param string $sql SQL statement
|
||||
* @return mixed Resultset array or boolean indicating success / failure depending on the query executed
|
||||
|
|
|
@ -8532,10 +8532,21 @@ class ModelReadTest extends BaseModelTest {
|
|||
$this->assertEquals($expected, $results, 'Model related with belongsTo afterFind callback fails');
|
||||
}
|
||||
|
||||
/**
|
||||
* Pull out the username from a result set.
|
||||
*
|
||||
* @param array $result The results.
|
||||
* @return string The username.
|
||||
*/
|
||||
public static function extractUserNameFromQueryResult(array $result) {
|
||||
return isset($result[0][0]) ? $result[0][0]['user'] : $result[0]['u']['user'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that query() doesn't override the 2nd argument with a default.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testQueryRespectsCacheQueriesAsSecondArgument() {
|
||||
$model = new User();
|
||||
$model->save(array('user' => 'Chuck'));
|
||||
|
@ -8552,12 +8563,17 @@ class ModelReadTest extends BaseModelTest {
|
|||
$this->assertSame('Chuck', $getUserNameFromDb(false));
|
||||
|
||||
$model->updateAll(array('User.user' => "'Sylvester'"), array('User.id' => $model->id));
|
||||
|
||||
$model->cacheQueries = false;
|
||||
$this->assertSame('Chuck', $getUserNameFromDb(true));
|
||||
$this->assertSame('Sylvester', $getUserNameFromDb(false));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that query() doesn't override the cache param in the 3nd argument
|
||||
* with a default.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testQueryRespectsCacheQueriesAsThirdArgument() {
|
||||
$model = new User();
|
||||
$model->save(array('user' => 'Chuck'));
|
||||
|
@ -8572,12 +8588,18 @@ class ModelReadTest extends BaseModelTest {
|
|||
$model->cacheQueries = true;
|
||||
$this->assertSame('Chuck', $getUserNameFromDb(true));
|
||||
$this->assertSame('Chuck', $getUserNameFromDb(false));
|
||||
|
||||
$model->updateAll(array('User.user' => "'Sylvester'"), array('User.id' => $model->id));
|
||||
$model->cacheQueries = false;
|
||||
$this->assertSame('Chuck', $getUserNameFromDb(true));
|
||||
$this->assertSame('Sylvester', $getUserNameFromDb(false));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that query() uses the cacheQueries property when there is one argument.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testQueryTakesModelCacheQueriesValueAsDefaultForOneArgument() {
|
||||
$model = new User();
|
||||
$model->save(array('user' => 'Chuck'));
|
||||
|
@ -8592,11 +8614,17 @@ class ModelReadTest extends BaseModelTest {
|
|||
$model->cacheQueries = true;
|
||||
$this->assertSame('Chuck', $getUserNameFromDb());
|
||||
$model->updateAll(array('User.user' => "'Sylvester'"), array('User.id' => $model->id));
|
||||
|
||||
$this->assertSame('Chuck', $getUserNameFromDb());
|
||||
$model->cacheQueries = false;
|
||||
$this->assertSame('Sylvester', $getUserNameFromDb());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that query() uses the cacheQueries property when there are two arguments.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testQueryTakesModelCacheQueriesValueAsDefaultForTwoArguments() {
|
||||
$model = new User();
|
||||
$model->save(array('user' => 'Chuck'));
|
||||
|
@ -8610,8 +8638,10 @@ class ModelReadTest extends BaseModelTest {
|
|||
|
||||
$model->cacheQueries = true;
|
||||
$this->assertSame('Chuck', $getUserNameFromDb());
|
||||
|
||||
$model->updateAll(array('User.user' => "'Sylvester'"), array('User.id' => $model->id));
|
||||
$this->assertSame('Chuck', $getUserNameFromDb());
|
||||
|
||||
$model->cacheQueries = false;
|
||||
$this->assertSame('Sylvester', $getUserNameFromDb());
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue