Files
predis/tests/Predis/Profile/FactoryTest.php
T
Daniele Alessandri b6389e4a03 Switch to "3.0" as the default server profile.
Redis 3.0 does not really change much in terms of commands (most of
the ones implemented in the "unstable" branch have been backported to
the "2.8" branch after all) aside from a few cluster-related ones, so
we can bump the default version without worries.
2014-07-28 20:36:12 +02:00

96 lines
2.6 KiB
PHP

<?php
/*
* This file is part of the Predis package.
*
* (c) Daniele Alessandri <suppakilla@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Predis\Profile;
use PredisTestCase;
/**
*
*/
class FactoryTest extends PredisTestCase
{
const DEFAULT_PROFILE_VERSION = '3.0';
const DEVELOPMENT_PROFILE_VERSION = '3.0';
/**
* @group disconnected
*/
public function testGetVersion()
{
$profile = Factory::get('2.0');
$this->assertInstanceOf('Predis\Profile\ProfileInterface', $profile);
$this->assertEquals('2.0', $profile->getVersion());
}
/**
* @group disconnected
*/
public function testGetDefault()
{
$profile1 = Factory::get(self::DEFAULT_PROFILE_VERSION);
$profile2 = Factory::get('default');
$profile3 = Factory::getDefault();
$this->assertInstanceOf('Predis\Profile\ProfileInterface', $profile1);
$this->assertInstanceOf('Predis\Profile\ProfileInterface', $profile2);
$this->assertInstanceOf('Predis\Profile\ProfileInterface', $profile3);
$this->assertEquals($profile1->getVersion(), $profile2->getVersion());
$this->assertEquals($profile2->getVersion(), $profile3->getVersion());
}
/**
* @group disconnected
*/
public function testGetDevelopment()
{
$profile1 = Factory::get('dev');
$profile2 = Factory::getDevelopment();
$this->assertInstanceOf('Predis\Profile\ProfileInterface', $profile1);
$this->assertInstanceOf('Predis\Profile\ProfileInterface', $profile2);
$this->assertEquals(self::DEVELOPMENT_PROFILE_VERSION, $profile2->getVersion());
}
/**
* @group disconnected
* @expectedException \Predis\ClientException
* @expectedExceptionMessage Unknown server profile: '1.0'.
*/
public function testGetUndefinedProfile()
{
Factory::get('1.0');
}
/**
* @group disconnected
*/
public function testDefineProfile()
{
$profileClass = get_class($this->getMock('Predis\Profile\ProfileInterface'));
Factory::define('mock', $profileClass);
$this->assertInstanceOf($profileClass, Factory::get('mock'));
}
/**
* @group disconnected
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage The class 'stdClass' is not a valid profile class.
*/
public function testDefineInvalidProfile()
{
Factory::define('bogus', 'stdClass');
}
}