Overview

Namespaces

  • Composer
    • Autoload
  • Guzzle
    • Common
      • Exception
    • Http
      • Curl
      • Exception
      • Message
        • Header
      • QueryAggregator
    • Parser
      • Cookie
      • Message
      • UriTemplate
      • Url
    • Plugin
      • Mock
    • Stream
  • Mockery
    • Adapter
      • Phpunit
    • CountValidator
    • Exception
    • Generator
      • StringManipulation
        • Pass
    • Loader
    • Matcher
  • None
  • Omnipay
    • Common
      • Exception
      • Message
    • Dummy
      • Message
    • Fatzebra
      • Message
  • PHP
  • Symfony
    • Component
      • EventDispatcher
        • Debug
        • DependencyInjection
        • Tests
          • Debug
          • DependencyInjection
      • HttpFoundation
        • File
          • Exception
          • MimeType
        • Session
          • Attribute
          • Flash
          • Storage
            • Handler
            • Proxy
        • Tests
          • File
            • MimeType
          • Session
            • Attribute
            • Flash
            • Storage
              • Handler
              • Proxy
      • Yaml
        • Exception
        • Tests

Classes

  • Symfony\Component\Yaml\Tests\A
  • Symfony\Component\Yaml\Tests\B
  • Symfony\Component\Yaml\Tests\DumperTest
  • Symfony\Component\Yaml\Tests\InlineTest
  • Symfony\Component\Yaml\Tests\ParseExceptionTest
  • Symfony\Component\Yaml\Tests\ParserTest
  • Symfony\Component\Yaml\Tests\YamlTest
  • Overview
  • Namespace
  • Function
  • Tree
  1: <?php
  2: 
  3: /*
  4:  * This file is part of the Symfony package.
  5:  *
  6:  * (c) Fabien Potencier <fabien@symfony.com>
  7:  *
  8:  * For the full copyright and license information, please view the LICENSE
  9:  * file that was distributed with this source code.
 10:  */
 11: 
 12: namespace Symfony\Component\HttpFoundation\Tests\Session\Flash;
 13: 
 14: use Symfony\Component\HttpFoundation\Session\Flash\FlashBag;
 15: 
 16: /**
 17:  * FlashBagTest.
 18:  *
 19:  * @author Drak <drak@zikula.org>
 20:  */
 21: class FlashBagTest extends \PHPUnit_Framework_TestCase
 22: {
 23:     /**
 24:      * @var \Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface
 25:      */
 26:     private $bag;
 27: 
 28:     /**
 29:      * @var array
 30:      */
 31:     protected $array = array();
 32: 
 33:     protected function setUp()
 34:     {
 35:         parent::setUp();
 36:         $this->bag = new FlashBag();
 37:         $this->array = array('notice' => array('A previous flash message'));
 38:         $this->bag->initialize($this->array);
 39:     }
 40: 
 41:     public function tearDown()
 42:     {
 43:         $this->bag = null;
 44:         parent::tearDown();
 45:     }
 46: 
 47:     public function testInitialize()
 48:     {
 49:         $bag = new FlashBag();
 50:         $bag->initialize($this->array);
 51:         $this->assertEquals($this->array, $bag->peekAll());
 52:         $array = array('should' => array('change'));
 53:         $bag->initialize($array);
 54:         $this->assertEquals($array, $bag->peekAll());
 55:     }
 56: 
 57:     public function testGetStorageKey()
 58:     {
 59:         $this->assertEquals('_sf2_flashes', $this->bag->getStorageKey());
 60:         $attributeBag = new FlashBag('test');
 61:         $this->assertEquals('test', $attributeBag->getStorageKey());
 62:     }
 63: 
 64:     public function testGetSetName()
 65:     {
 66:         $this->assertEquals('flashes', $this->bag->getName());
 67:         $this->bag->setName('foo');
 68:         $this->assertEquals('foo', $this->bag->getName());
 69:     }
 70: 
 71:     public function testPeek()
 72:     {
 73:         $this->assertEquals(array(), $this->bag->peek('non_existing'));
 74:         $this->assertEquals(array('default'), $this->bag->peek('not_existing', array('default')));
 75:         $this->assertEquals(array('A previous flash message'), $this->bag->peek('notice'));
 76:         $this->assertEquals(array('A previous flash message'), $this->bag->peek('notice'));
 77:     }
 78: 
 79:     public function testGet()
 80:     {
 81:         $this->assertEquals(array(), $this->bag->get('non_existing'));
 82:         $this->assertEquals(array('default'), $this->bag->get('not_existing', array('default')));
 83:         $this->assertEquals(array('A previous flash message'), $this->bag->get('notice'));
 84:         $this->assertEquals(array(), $this->bag->get('notice'));
 85:     }
 86: 
 87:     public function testAll()
 88:     {
 89:         $this->bag->set('notice', 'Foo');
 90:         $this->bag->set('error', 'Bar');
 91:         $this->assertEquals(array(
 92:             'notice' => array('Foo'),
 93:             'error' => array('Bar'), ), $this->bag->all()
 94:         );
 95: 
 96:         $this->assertEquals(array(), $this->bag->all());
 97:     }
 98: 
 99:     public function testSet()
100:     {
101:         $this->bag->set('notice', 'Foo');
102:         $this->bag->set('notice', 'Bar');
103:         $this->assertEquals(array('Bar'), $this->bag->peek('notice'));
104:     }
105: 
106:     public function testHas()
107:     {
108:         $this->assertFalse($this->bag->has('nothing'));
109:         $this->assertTrue($this->bag->has('notice'));
110:     }
111: 
112:     public function testKeys()
113:     {
114:         $this->assertEquals(array('notice'), $this->bag->keys());
115:     }
116: 
117:     public function testPeekAll()
118:     {
119:         $this->bag->set('notice', 'Foo');
120:         $this->bag->set('error', 'Bar');
121:         $this->assertEquals(array(
122:             'notice' => array('Foo'),
123:             'error' => array('Bar'),
124:             ), $this->bag->peekAll()
125:         );
126:         $this->assertTrue($this->bag->has('notice'));
127:         $this->assertTrue($this->bag->has('error'));
128:         $this->assertEquals(array(
129:             'notice' => array('Foo'),
130:             'error' => array('Bar'),
131:             ), $this->bag->peekAll()
132:         );
133:     }
134: 
135:     /**
136:      * @covers Symfony\Component\HttpFoundation\Session\Flash\FlashBag::getIterator
137:      */
138:     public function testGetIterator()
139:     {
140:         $flashes = array('hello' => 'world', 'beep' => 'boop', 'notice' => 'nope');
141:         foreach ($flashes as $key => $val) {
142:             $this->bag->set($key, $val);
143:         }
144: 
145:         $i = 0;
146:         foreach ($this->bag as $key => $val) {
147:             $this->assertEquals(array($flashes[$key]), $val);
148:             $i++;
149:         }
150: 
151:         $this->assertEquals(count($flashes), $i);
152:         $this->assertCount(0, $this->bag->all());
153:     }
154: }
155: 
Omnipay Fat Zebra / Paystream Gateway Module API Documentation API documentation generated by ApiGen