KeepInCacheTest.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace YdbPlatform\Ydb\Test;
  3. use PHPUnit\Framework\TestCase;
  4. use YdbPlatform\Ydb\Session;
  5. class KeepInCacheTest extends TestCase
  6. {
  7. protected $sampleParams = ["x", 1];
  8. public function testIsNeedSetKeepQueryInCache()
  9. {
  10. $tests = [
  11. ["flag" => null, "params" => null, "result" => false],
  12. ["flag" => null, "params" => [], "result" => false],
  13. ["flag" => null, "params" => $this->sampleParams, "result" => true],
  14. ["flag" => false, "params" => null, "result" => false],
  15. ["flag" => false, "params" => [], "result" => false],
  16. ["flag" => false, "params" => $this->sampleParams, "result" => false],
  17. ["flag" => true, "params" => null, "result" => true],
  18. ["flag" => true, "params" => [], "result" => true],
  19. ["flag" => true, "params" => $this->sampleParams, "result" => true],
  20. ];
  21. foreach ($tests as $i => $test){
  22. self::assertEquals($test["result"], YdbQuery::isNeedSetKeepQueryInCache($test["flag"], $test["params"]));
  23. }
  24. }
  25. }
  26. class YdbQuery extends \YdbPlatform\Ydb\YdbQuery{
  27. public static function isNeedSetKeepQueryInCache(?bool $userFlag, ?array $queryDeclaredParams): bool
  28. {
  29. return parent::isNeedSetKeepQueryInCache($userFlag, $queryDeclaredParams);
  30. }
  31. }