This commit is contained in:
Khoubza Younes
2021-10-03 23:12:02 +01:00
parent 07d0700740
commit 3d31936102
2 changed files with 19 additions and 8 deletions
+2 -1
View File
@@ -13,7 +13,8 @@
], ],
"require": { "require": {
"php": ">=5.3", "php": ">=5.3",
"ext-json": "*" "ext-json": "*",
"symfony/symfony": "~2.0.0"
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {
+17 -7
View File
@@ -10,18 +10,19 @@ use Flasher\Symfony\Storage\Storage;
use Flasher\Tests\Prime\TestCase; use Flasher\Tests\Prime\TestCase;
use Symfony\Component\HttpFoundation\Session\Session; use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage; use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
use Symfony\Component\HttpFoundation\SessionStorage\ArraySessionStorage;
class StorageTest extends TestCase class StorageTest extends TestCase
{ {
public function testInitialState() public function testInitialState()
{ {
$storage = new Storage(new Session(new MockArraySessionStorage())); $storage = $this->getStorage();
$this->assertEquals(array(), $storage->all()); $this->assertEquals(array(), $storage->all());
} }
public function testAddEnvelope() public function testAddEnvelope()
{ {
$storage = new Storage(new Session(new MockArraySessionStorage())); $storage = $this->getStorage();
$envelope = new Envelope(new Notification()); $envelope = new Envelope(new Notification());
$storage->add($envelope); $storage->add($envelope);
@@ -30,7 +31,7 @@ class StorageTest extends TestCase
public function testAddMultipleEnvelopes() public function testAddMultipleEnvelopes()
{ {
$storage = new Storage(new Session(new MockArraySessionStorage())); $storage = $this->getStorage();
$envelopes = array( $envelopes = array(
new Envelope(new Notification()), new Envelope(new Notification()),
new Envelope(new Notification()), new Envelope(new Notification()),
@@ -42,7 +43,7 @@ class StorageTest extends TestCase
public function testUpdateEnvelopes() public function testUpdateEnvelopes()
{ {
$storage = new Storage(new Session(new MockArraySessionStorage())); $storage = $this->getStorage();
$envelopes = array( $envelopes = array(
new Envelope(new Notification(), array( new Envelope(new Notification(), array(
new UuidStamp(), new UuidStamp(),
@@ -67,7 +68,7 @@ class StorageTest extends TestCase
public function testRemoveEnvelopes() public function testRemoveEnvelopes()
{ {
$storage = new Storage(new Session(new MockArraySessionStorage())); $storage = $this->getStorage();
$envelopes = array( $envelopes = array(
new Envelope(new Notification(), array( new Envelope(new Notification(), array(
new UuidStamp(), new UuidStamp(),
@@ -86,7 +87,7 @@ class StorageTest extends TestCase
public function testRemoveMultipleEnvelopes() public function testRemoveMultipleEnvelopes()
{ {
$storage = new Storage(new Session(new MockArraySessionStorage())); $storage = $this->getStorage();
$envelopes = array( $envelopes = array(
new Envelope(new Notification(), array( new Envelope(new Notification(), array(
new UuidStamp(), new UuidStamp(),
@@ -105,7 +106,7 @@ class StorageTest extends TestCase
public function testClearAllEnvelopes() public function testClearAllEnvelopes()
{ {
$storage = new Storage(new Session(new MockArraySessionStorage())); $storage = $this->getStorage();
$envelopes = array( $envelopes = array(
new Envelope(new Notification(), array( new Envelope(new Notification(), array(
new UuidStamp(), new UuidStamp(),
@@ -121,4 +122,13 @@ class StorageTest extends TestCase
$storage->clear(); $storage->clear();
$this->assertEquals(array(), $storage->all()); $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);
}
} }