MemcachedTest.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. /*
  3. * This file is part of the Stash package.
  4. *
  5. * (c) Robert Hafner <tedivm@tedivm.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Stash\Test\Driver;
  11. use \Stash\Driver\Memcache;
  12. /**
  13. * @package Stash
  14. * @author Robert Hafner <tedivm@tedivm.com>
  15. */
  16. class MemcachedTest extends MemcacheTest
  17. {
  18. protected $extension = 'memcached';
  19. protected function getOptions()
  20. {
  21. $options = parent::getOptions();
  22. $memcachedOptions = array('hash' => 'default',
  23. 'distribution' => 'modula',
  24. 'serializer' => 'php',
  25. 'buffer_writes' => false,
  26. 'connect_timeout' => 500,
  27. 'prefix_key' => 'cheese'
  28. );
  29. return array_merge($options, $memcachedOptions);
  30. }
  31. /**
  32. * @expectedException Stash\Exception\RuntimeException
  33. */
  34. public function testSetHashException()
  35. {
  36. $options = array();
  37. $options['servers'][] = array('127.0.0.1', '11211', '50');
  38. $options['servers'][] = array('127.0.0.1', '11211');
  39. $options['hash'] = 'InvalidOption';
  40. $driver = new Memcache($options);
  41. }
  42. /**
  43. * @expectedException Stash\Exception\RuntimeException
  44. */
  45. public function testSetDistributionException()
  46. {
  47. $options = array();
  48. $options['servers'][] = array('127.0.0.1', '11211', '50');
  49. $options['servers'][] = array('127.0.0.1', '11211');
  50. $options['distribution'] = 'InvalidOption';
  51. $driver = new Memcache($options);
  52. }
  53. /**
  54. * @expectedException Stash\Exception\RuntimeException
  55. */
  56. public function testSetSerializerException()
  57. {
  58. $options = array();
  59. $options['servers'][] = array('127.0.0.1', '11211', '50');
  60. $options['servers'][] = array('127.0.0.1', '11211');
  61. $options['serializer'] = 'InvalidOption';
  62. $driver = new Memcache($options);
  63. }
  64. /**
  65. * @expectedException Stash\Exception\RuntimeException
  66. */
  67. public function testSetNumberedValueException()
  68. {
  69. $options = array();
  70. $options['servers'][] = array('127.0.0.1', '11211', '50');
  71. $options['servers'][] = array('127.0.0.1', '11211');
  72. $options['connect_timeout'] = 'InvalidOption';
  73. $driver = new Memcache($options);
  74. }
  75. /**
  76. * @expectedException Stash\Exception\RuntimeException
  77. */
  78. public function testSetBooleanValueException()
  79. {
  80. $options = array();
  81. $options['servers'][] = array('127.0.0.1', '11211', '50');
  82. $options['servers'][] = array('127.0.0.1', '11211');
  83. $options['cache_lookups'] = 'InvalidOption';
  84. $driver = new Memcache($options);
  85. }
  86. }