EphemeralTest.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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\Item;
  12. use Stash\Test\Stubs\PoolGetDriverStub;
  13. /**
  14. * @package Stash
  15. * @author Robert Hafner <tedivm@tedivm.com>
  16. */
  17. class EphemeralTest extends AbstractDriverTest
  18. {
  19. protected $driverClass = 'Stash\Driver\Ephemeral';
  20. public function testKeyCollisions1()
  21. {
  22. $driver = new $this->driverClass;
  23. $poolStub = new PoolGetDriverStub();
  24. $poolStub->setDriver($driver);
  25. $item1 = new Item();
  26. $item1->setPool($poolStub);
  27. $item1->setKey(array('##', '#'));
  28. $item1->set('X')->save();
  29. $item2 = new Item();
  30. $item2->setPool($poolStub);
  31. $item2->setKey(array('#', '##'));
  32. $item2->set('Y')->save();
  33. $this->assertEquals('X', $item1->get());
  34. }
  35. public function testKeyCollisions2()
  36. {
  37. $driver = new $this->driverClass;
  38. $poolStub = new PoolGetDriverStub();
  39. $poolStub->setDriver($driver);
  40. $item1 = new Item();
  41. $item1->setPool($poolStub);
  42. $item1->setKey(array('#'));
  43. $item1->set('X');
  44. $item2 = new Item();
  45. $item2->setPool($poolStub);
  46. $item2->setKey(array(':'));
  47. $item2->set('Y');
  48. $this->assertEquals('X', $item1->get());
  49. }
  50. }