diff options
author | Mirosław Sztorc <msztorc@users.noreply.github.com> | 2021-01-06 03:06:04 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-06 03:06:04 +0300 |
commit | a4b0fac121b19a3e44104b89af50d33979095b6c (patch) | |
tree | 4c7d2aadd59038bd830d369bac3c015878726419 /tests/MathTest.php | |
parent | 5ed72fda6f80e862162999a0442f6ea97c91af56 (diff) |
Cache-control improvements (#81)
* cache-control improvements
* Update src/NXP/MathExecutor.php
yeah, you're right.
Co-authored-by: Alexander Kiryukhin <a.kiryukhin@mail.ru>
* Update MathExecutor.php
braces qfix
* Update MathExecutor.php
Co-authored-by: Alexander Kiryukhin <a.kiryukhin@mail.ru>
Diffstat (limited to 'tests/MathTest.php')
-rw-r--r-- | tests/MathTest.php | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/MathTest.php b/tests/MathTest.php index 1e5da5a..a5061ad 100644 --- a/tests/MathTest.php +++ b/tests/MathTest.php @@ -589,4 +589,28 @@ class MathTest extends TestCase ]; } + public function testCache() + { + $calculator = new MathExecutor(); + $this->assertEquals(256, $calculator->execute('2 ^ 8')); // second arg $cache is true by default + + $this->assertIsArray($calculator->getCache()); + $this->assertEquals(1, count($calculator->getCache())); + + $this->assertEquals(512, $calculator->execute('2 ^ 9', true)); + $this->assertEquals(2, count($calculator->getCache())); + + $this->assertEquals(1024, $calculator->execute('2 ^ 10', false)); + $this->assertEquals(2, count($calculator->getCache())); + + $calculator->clearCache(); + $this->assertIsArray($calculator->getCache()); + $this->assertEquals(0, count($calculator->getCache())); + + $this->assertEquals(2048, $calculator->execute('2 ^ 11', false)); + $this->assertEquals(0, count($calculator->getCache())); + + + } + }
\ No newline at end of file |