mirror of
https://github.com/predis/predis.git
synced 2026-08-25 18:49:44 +00:00
b253bdc41e
We now have a base test case class for Predis (namely PredisTestCase) grouping various commonly used utility methods shared by all of the tests in the suite, greatly improving reusability.
97 lines
2.6 KiB
PHP
97 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;
|
|
use Predis\Command\Processor\ProcessorChain;
|
|
|
|
/**
|
|
*
|
|
*/
|
|
class FactoryTest extends PredisTestCase
|
|
{
|
|
const DEFAULT_PROFILE_VERSION = '2.8';
|
|
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 Cannot register 'stdClass' as it is not a valid profile class
|
|
*/
|
|
public function testDefineInvalidProfile()
|
|
{
|
|
Factory::define('bogus', 'stdClass');
|
|
}
|
|
}
|