diff --git a/tests/Prime/Factory/NotificationFactoryTest.php b/tests/Prime/Factory/NotificationFactoryTest.php index 6d169821..c5f5ba69 100644 --- a/tests/Prime/Factory/NotificationFactoryTest.php +++ b/tests/Prime/Factory/NotificationFactoryTest.php @@ -8,7 +8,7 @@ namespace Flasher\Tests\Prime\Factory; use Flasher\Prime\Factory\NotificationFactory; -use PHPUnit\Framework\TestCase; +use Flasher\Tests\Prime\TestCase; class NotificationFactoryTest extends TestCase { diff --git a/tests/Prime/Storage/StorageManagerTest.php b/tests/Prime/Storage/StorageManagerTest.php new file mode 100644 index 00000000..3b955b9f --- /dev/null +++ b/tests/Prime/Storage/StorageManagerTest.php @@ -0,0 +1,138 @@ + + */ + +namespace Flasher\Tests\Prime\Storage; + +use Flasher\Prime\Notification\Envelope; +use Flasher\Prime\Notification\Notification; +use Flasher\Prime\Stamp\DelayStamp; +use Flasher\Prime\Stamp\HopsStamp; +use Flasher\Prime\Stamp\UuidStamp; +use Flasher\Prime\Storage\StorageManager; +use Flasher\Tests\Prime\TestCase; + +class StorageManagerTest extends TestCase +{ + /** + * @return void + */ + public function testGetAllStoredEnvelopes() + { + $envelopes = array( + new Envelope(new Notification(), new UuidStamp('1111')), + new Envelope(new Notification(), new UuidStamp('2222')), + new Envelope(new Notification(), new UuidStamp('3333')), + new Envelope(new Notification(), new UuidStamp('4444')), + ); + + $storage = $this->getMockBuilder('Flasher\Prime\Storage\StorageInterface')->getMock(); + $storage->expects($this->once())->method('all')->willReturn($envelopes); + + $storageManager = new StorageManager($storage); + + $this->assertEquals($envelopes, $storageManager->all()); + } + + /** + * @return void + */ + public function testGetFilteredEnvelopes() + { + $envelopes = array( + new Envelope(new Notification(), new UuidStamp('1111')), + new Envelope(new Notification(), new UuidStamp('2222'), new HopsStamp(1), new DelayStamp(0)), + new Envelope(new Notification(), new UuidStamp('3333')), + new Envelope(new Notification(), new UuidStamp('4444')), + ); + + $storage = $this->getMockBuilder('Flasher\Prime\Storage\StorageInterface')->getMock(); + $storage->expects($this->once())->method('all')->willReturn($envelopes); + + $storageManager = new StorageManager($storage); + + $this->assertEquals(array($envelopes[1]), $storageManager->filter()); + } + + /** + * @return void + */ + public function testAddEnvelopes() + { + $envelopes = array( + new Envelope(new Notification()), + new Envelope(new Notification()), + new Envelope(new Notification()), + new Envelope(new Notification()), + ); + + $storageManager = new StorageManager(); + $storageManager->add($envelopes); + + $this->assertEquals($envelopes, $storageManager->all()); + } + + /** + * @return void + */ + public function testUpdateEnvelopes() + { + $envelopes = array( + new Envelope(new Notification()), + new Envelope(new Notification()), + new Envelope(new Notification()), + new Envelope(new Notification()), + ); + + $storageManager = new StorageManager(); + $storageManager->update($envelopes); + + $this->assertEquals($envelopes, $storageManager->all()); + } + + /** + * @return void + */ + public function testRemoveEnvelopes() + { + $envelopes = array( + new Envelope(new Notification(), new UuidStamp('1111')), + new Envelope(new Notification(), new UuidStamp('2222')), + new Envelope(new Notification(), new UuidStamp('3333')), + new Envelope(new Notification(), new UuidStamp('4444')), + ); + + $storageManager = new StorageManager(); + $storageManager->add($envelopes); + + $storageManager->remove(array( + new Envelope(new Notification(), new UuidStamp('2222')), + new Envelope(new Notification(), new UuidStamp('3333')), + )); + + $this->assertEquals(array($envelopes[0], $envelopes[3]), $storageManager->all()); + } + + /** + * @return void + */ + public function testClearEnvelopes() + { + $envelopes = array( + new Envelope(new Notification()), + new Envelope(new Notification()), + new Envelope(new Notification()), + new Envelope(new Notification()), + ); + + $storageManager = new StorageManager(); + $storageManager->add($envelopes); + + $storageManager->clear(); + + $this->assertEquals(array(), $storageManager->all()); + } +} diff --git a/tests/Prime/Translation/EchoTranslatorTest.php b/tests/Prime/Translation/EchoTranslatorTest.php new file mode 100644 index 00000000..71625c89 --- /dev/null +++ b/tests/Prime/Translation/EchoTranslatorTest.php @@ -0,0 +1,25 @@ + + */ + +namespace Flasher\Tests\Prime\Translation; + +use Flasher\Prime\Translation\EchoTranslator; +use Flasher\Tests\Prime\TestCase; + +class EchoTranslatorTest extends TestCase +{ + /** + * @return void + */ + public function testEchoTranslator() + { + $translator = new EchoTranslator(); + + $this->assertEquals('en', $translator->getLocale()); + $this->assertEquals('PHPFlasher', $translator->translate('PHPFlasher')); + } +} diff --git a/tests/Prime/Translation/LanguageTest.php b/tests/Prime/Translation/LanguageTest.php new file mode 100644 index 00000000..ab904e9d --- /dev/null +++ b/tests/Prime/Translation/LanguageTest.php @@ -0,0 +1,42 @@ + + */ + +namespace Flasher\Tests\Prime\Translation; + +use Flasher\Prime\Translation\Language; +use Flasher\Tests\Prime\TestCase; + +class LanguageTest extends TestCase +{ + /** + * @return void + */ + public function testLanguageDirection() + { + $this->assertEquals(Language::RTL, Language::direction('ar')); + $this->assertEquals(Language::LTR, Language::direction('fr')); + $this->assertEquals(Language::LTR, Language::direction('unknown')); + } + + /** + * @return void + */ + public function testIsRTL() + { + $this->assertTrue(Language::isRTL('ar_AE')); + $this->assertFalse(Language::isRTL('en_US')); + } + + /** + * @return void + */ + public function testIsLTR() + { + $this->assertTrue(Language::isLTR('en_US')); + $this->assertFalse(Language::isLTR('ar_AE')); + } +}