2013-07-24 15:50:15 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
/**
|
2024-05-10 09:09:14 -04:00
|
|
|
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
2013-07-24 15:50:15 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
namespace Test\Memcache;
|
|
|
|
|
|
2025-06-12 12:31:58 -04:00
|
|
|
use OC\Memcache\APCu;
|
|
|
|
|
|
2023-01-20 09:49:15 -05:00
|
|
|
/**
|
|
|
|
|
* @group Memcache
|
|
|
|
|
* @group APCu
|
|
|
|
|
*/
|
2016-05-20 09:38:20 -04:00
|
|
|
class APCuTest extends Cache {
|
2019-11-21 10:40:38 -05:00
|
|
|
protected function setUp(): void {
|
2014-11-10 17:30:38 -05:00
|
|
|
parent::setUp();
|
|
|
|
|
|
2025-06-12 12:31:58 -04:00
|
|
|
if (!APCu::isAvailable()) {
|
2013-07-24 15:50:15 -04:00
|
|
|
$this->markTestSkipped('The APCu extension is not available.');
|
|
|
|
|
return;
|
|
|
|
|
}
|
2025-06-12 12:31:58 -04:00
|
|
|
$this->instance = new APCu($this->getUniqueID());
|
2013-07-24 15:50:15 -04:00
|
|
|
}
|
2016-12-21 15:06:29 -05:00
|
|
|
|
2024-09-15 16:32:31 -04:00
|
|
|
public function testCasIntChanged(): void {
|
2016-12-21 15:06:29 -05:00
|
|
|
$this->instance->set('foo', 1);
|
|
|
|
|
$this->assertTrue($this->instance->cas('foo', 1, 2));
|
|
|
|
|
$this->assertEquals(2, $this->instance->get('foo'));
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-15 16:32:31 -04:00
|
|
|
public function testCasIntNotChanged(): void {
|
2016-12-21 15:06:29 -05:00
|
|
|
$this->instance->set('foo', 1);
|
|
|
|
|
$this->assertFalse($this->instance->cas('foo', 2, 3));
|
|
|
|
|
$this->assertEquals(1, $this->instance->get('foo'));
|
|
|
|
|
}
|
2013-07-24 15:50:15 -04:00
|
|
|
}
|