public function setUp() { if (!cachestore_apcu::are_requirements_met()) { $this->markTestSkipped('Could not test cachestore_apcu. Requirements are not met.'); } return parent::setUp(); }
/** * Test purging the apcu cache store. */ public function test_purge() { if (!cachestore_apcu::are_requirements_met()) { $this->markTestSkipped('Could not test cachestore_apcu. Requirements are not met.'); } $definition = cache_definition::load_adhoc(cache_store::MODE_APPLICATION, 'cachestore_apcu', 'phpunit_test'); $instance = cachestore_apcu::initialise_unit_test_instance($definition); // Test a simple purge return. $this->assertTrue($instance->purge()); // Test purge works. $this->assertTrue($instance->set('test', 'monster')); $this->assertSame('monster', $instance->get('test')); $this->assertTrue($instance->purge()); $this->assertFalse($instance->get('test')); // Test purge with custom data. $this->assertTrue($instance->set('test', 'monster')); $this->assertSame('monster', $instance->get('test')); $this->assertTrue(apcu_store('test', 'pirate', 180)); $this->assertSame('monster', $instance->get('test')); $this->assertTrue(apcu_exists('test')); $this->assertSame('pirate', apcu_fetch('test')); // Purge and check that our data is gone but the the custom data is still there. $this->assertTrue($instance->purge()); $this->assertFalse($instance->get('test')); $this->assertTrue(apcu_exists('test')); $this->assertSame('pirate', apcu_fetch('test')); }