APCuTest.php 930 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace Test\Memcache;
  8. /**
  9. * @group Memcache
  10. * @group APCu
  11. */
  12. class APCuTest extends Cache {
  13. protected function setUp(): void {
  14. parent::setUp();
  15. if (!\OC\Memcache\APCu::isAvailable()) {
  16. $this->markTestSkipped('The APCu extension is not available.');
  17. return;
  18. }
  19. $this->instance = new \OC\Memcache\APCu($this->getUniqueID());
  20. }
  21. public function testCasIntChanged(): void {
  22. $this->instance->set('foo', 1);
  23. $this->assertTrue($this->instance->cas('foo', 1, 2));
  24. $this->assertEquals(2, $this->instance->get('foo'));
  25. }
  26. public function testCasIntNotChanged(): void {
  27. $this->instance->set('foo', 1);
  28. $this->assertFalse($this->instance->cas('foo', 2, 3));
  29. $this->assertEquals(1, $this->instance->get('foo'));
  30. }
  31. }