<commit_before><commit_msg>Adding Memcached tests<commit_after><?php

namespace JawHare;

class CacheMemcachedTest extends \PHPUnit_Framework_TestCase
{
	protected $obj;

	protected function setUp()
	{
		global $ini;
		if (!class_exists('Memcached', false))
			$this->markTestSkipped('Memcached doesn\'t exist');

		if (empty($ini['cache']['Memcached']))
			$this->markTestSkipped('No Memcached configuration');

		$this->obj = Cache($ini['cache']['Memcached']);
	}

	public function testIO()
	{
		$ret = $this->obj->set('foo', 5, 100);
		$this->assertTrue($ret);

		$ret = $this->obj->get('foo');
		$this->assertEquals($ret, 5);

		$ret = $this->obj->add('foo', 3, 100);
		// Should fail since add doesn't replace existing values
		$this->assertFalse($ret);
		$this->assertEquals($this->obj->get('foo'), 5);

		$ret = $this->obj->replace('foo', 6, 100);
		$this->assertTrue($ret);
		$this->assertEquals($this->obj->get('foo'), 6);

		$ret = $this->obj->delete('foo');
		$this->assertTrue($ret);

		$ret = $this->obj->delete('foo');
		$this->assertFalse($ret);

		$ret = $this->obj->add('foo', 3, 100);
		// Should fail since add doesn't replace existing values
		$this->assertTrue($ret);
		$this->assertEquals($this->obj->get('foo'), 3);
	}
}

{'fraction_non_alphanumeric': 0.22106109324758844, 'fraction_numerical': 0.01607717041800643, 'mean_word_length': 4.900473933649289, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 36, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5921312', 'n_tokens_mistral': 476, 'n_tokens_neox': 422, 'n_words': 84}