MemoryStorageTest.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. /**
  3. * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  4. * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  5. *
  6. * Licensed under The MIT License
  7. * For full copyright and license information, please see the LICENSE.txt
  8. * Redistributions of files must retain the above copyright notice.
  9. *
  10. * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  11. * @link http://cakephp.org CakePHP(tm) Project
  12. * @since 3.2.12
  13. * @license http://www.opensource.org/licenses/mit-license.php MIT License
  14. */
  15. namespace Cake\Test\TestCase\Auth\Storage;
  16. use Cake\Auth\Storage\MemoryStorage;
  17. use Cake\TestSuite\TestCase;
  18. /**
  19. * Test case for MemoryStorage
  20. *
  21. */
  22. class MemoryStorageTest extends TestCase
  23. {
  24. /**
  25. * Setup
  26. *
  27. * @return void
  28. */
  29. public function setUp()
  30. {
  31. parent::setUp();
  32. $this->storage = new MemoryStorage;
  33. $this->user = ['username' => 'giantGummyLizard'];
  34. }
  35. /**
  36. * Test write.
  37. *
  38. * @return void
  39. */
  40. public function testWrite()
  41. {
  42. $this->storage->write($this->user);
  43. $this->assertSame($this->user, $this->storage->read());
  44. }
  45. /**
  46. * Test read.
  47. *
  48. * @return void
  49. */
  50. public function testRead()
  51. {
  52. $this->assertNull($this->storage->read());
  53. }
  54. /**
  55. * Test delete.
  56. *
  57. * @return void
  58. */
  59. public function testDelete()
  60. {
  61. $this->storage->write($this->user);
  62. $this->storage->delete();
  63. $this->assertNull($this->storage->read());
  64. }
  65. /**
  66. * Test redirectUrl.
  67. *
  68. * @return void
  69. */
  70. public function testRedirectUrl()
  71. {
  72. $this->assertNull($this->storage->redirectUrl());
  73. $this->storage->redirectUrl('/posts/the-gummy-lizards');
  74. $this->assertSame('/posts/the-gummy-lizards', $this->storage->redirectUrl());
  75. $this->assertNull($this->storage->redirectUrl(false));
  76. $this->assertNull($this->storage->redirectUrl());
  77. }
  78. }