MemoryStorageTest.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. /**
  3. * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
  4. * Copyright (c) Cake Software Foundation, Inc. (https://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. (https://cakefoundation.org)
  11. * @link https://cakephp.org CakePHP(tm) Project
  12. * @since 3.2.12
  13. * @license https://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. class MemoryStorageTest extends TestCase
  22. {
  23. /**
  24. * Setup
  25. *
  26. * @return void
  27. */
  28. public function setUp()
  29. {
  30. parent::setUp();
  31. $this->storage = new MemoryStorage;
  32. $this->user = ['username' => 'giantGummyLizard'];
  33. }
  34. /**
  35. * Test write.
  36. *
  37. * @return void
  38. */
  39. public function testWrite()
  40. {
  41. $this->storage->write($this->user);
  42. $this->assertSame($this->user, $this->storage->read());
  43. }
  44. /**
  45. * Test read.
  46. *
  47. * @return void
  48. */
  49. public function testRead()
  50. {
  51. $this->assertNull($this->storage->read());
  52. }
  53. /**
  54. * Test delete.
  55. *
  56. * @return void
  57. */
  58. public function testDelete()
  59. {
  60. $this->storage->write($this->user);
  61. $this->storage->delete();
  62. $this->assertNull($this->storage->read());
  63. }
  64. /**
  65. * Test redirectUrl.
  66. *
  67. * @return void
  68. */
  69. public function testRedirectUrl()
  70. {
  71. $this->assertNull($this->storage->redirectUrl());
  72. $this->storage->redirectUrl('/posts/the-gummy-lizards');
  73. $this->assertSame('/posts/the-gummy-lizards', $this->storage->redirectUrl());
  74. $this->assertNull($this->storage->redirectUrl(false));
  75. $this->assertNull($this->storage->redirectUrl());
  76. }
  77. }