From 3d31936102eee5eeb5297d32531b095d0f6439fc Mon Sep 17 00:00:00 2001 From: Khoubza Younes Date: Sun, 3 Oct 2021 23:12:02 +0100 Subject: [PATCH] Wip --- composer.json | 3 ++- tests/Symfony/Storage/StorageTest.php | 24 +++++++++++++++++------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index 6f23f55a..fefa73bc 100755 --- a/composer.json +++ b/composer.json @@ -13,7 +13,8 @@ ], "require": { "php": ">=5.3", - "ext-json": "*" + "ext-json": "*", + "symfony/symfony": "~2.0.0" }, "autoload": { "psr-4": { diff --git a/tests/Symfony/Storage/StorageTest.php b/tests/Symfony/Storage/StorageTest.php index b3d32ddf..a382a968 100644 --- a/tests/Symfony/Storage/StorageTest.php +++ b/tests/Symfony/Storage/StorageTest.php @@ -10,18 +10,19 @@ use Flasher\Symfony\Storage\Storage; use Flasher\Tests\Prime\TestCase; use Symfony\Component\HttpFoundation\Session\Session; use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage; +use Symfony\Component\HttpFoundation\SessionStorage\ArraySessionStorage; class StorageTest extends TestCase { public function testInitialState() { - $storage = new Storage(new Session(new MockArraySessionStorage())); + $storage = $this->getStorage(); $this->assertEquals(array(), $storage->all()); } public function testAddEnvelope() { - $storage = new Storage(new Session(new MockArraySessionStorage())); + $storage = $this->getStorage(); $envelope = new Envelope(new Notification()); $storage->add($envelope); @@ -30,7 +31,7 @@ class StorageTest extends TestCase public function testAddMultipleEnvelopes() { - $storage = new Storage(new Session(new MockArraySessionStorage())); + $storage = $this->getStorage(); $envelopes = array( new Envelope(new Notification()), new Envelope(new Notification()), @@ -42,7 +43,7 @@ class StorageTest extends TestCase public function testUpdateEnvelopes() { - $storage = new Storage(new Session(new MockArraySessionStorage())); + $storage = $this->getStorage(); $envelopes = array( new Envelope(new Notification(), array( new UuidStamp(), @@ -67,7 +68,7 @@ class StorageTest extends TestCase public function testRemoveEnvelopes() { - $storage = new Storage(new Session(new MockArraySessionStorage())); + $storage = $this->getStorage(); $envelopes = array( new Envelope(new Notification(), array( new UuidStamp(), @@ -86,7 +87,7 @@ class StorageTest extends TestCase public function testRemoveMultipleEnvelopes() { - $storage = new Storage(new Session(new MockArraySessionStorage())); + $storage = $this->getStorage(); $envelopes = array( new Envelope(new Notification(), array( new UuidStamp(), @@ -105,7 +106,7 @@ class StorageTest extends TestCase public function testClearAllEnvelopes() { - $storage = new Storage(new Session(new MockArraySessionStorage())); + $storage = $this->getStorage(); $envelopes = array( new Envelope(new Notification(), array( new UuidStamp(), @@ -121,4 +122,13 @@ class StorageTest extends TestCase $storage->clear(); $this->assertEquals(array(), $storage->all()); } + + private function getStorage() + { + $session = class_exists('Symfony\Component\HttpFoundation\Session\Session') + ? new Session(new MockArraySessionStorage()) + : new Symfony\Component\HttpFoundation\Session(new ArraySessionStorage()); + + return new Storage($session); + } }