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\EventDispatcher\Tests;
 13: 
 14: use Symfony\Component\EventDispatcher\GenericEvent;
 15: 
 16: /**
 17:  * Test class for Event.
 18:  */
 19: class GenericEventTest extends \PHPUnit_Framework_TestCase
 20: {
 21:     /**
 22:      * @var GenericEvent
 23:      */
 24:     private $event;
 25: 
 26:     private $subject;
 27: 
 28:     /**
 29:      * Prepares the environment before running a test.
 30:      */
 31:     protected function setUp()
 32:     {
 33:         parent::setUp();
 34: 
 35:         $this->subject = new \stdClass();
 36:         $this->event = new GenericEvent($this->subject, array('name' => 'Event'));
 37:     }
 38: 
 39:     /**
 40:      * Cleans up the environment after running a test.
 41:      */
 42:     protected function tearDown()
 43:     {
 44:         $this->subject = null;
 45:         $this->event = null;
 46: 
 47:         parent::tearDown();
 48:     }
 49: 
 50:     public function testConstruct()
 51:     {
 52:         $this->assertEquals($this->event, new GenericEvent($this->subject, array('name' => 'Event')));
 53:     }
 54: 
 55:     /**
 56:      * Tests Event->getArgs().
 57:      */
 58:     public function testGetArguments()
 59:     {
 60:         // test getting all
 61:         $this->assertSame(array('name' => 'Event'), $this->event->getArguments());
 62:     }
 63: 
 64:     public function testSetArguments()
 65:     {
 66:         $result = $this->event->setArguments(array('foo' => 'bar'));
 67:         $this->assertAttributeSame(array('foo' => 'bar'), 'arguments', $this->event);
 68:         $this->assertSame($this->event, $result);
 69:     }
 70: 
 71:     public function testSetArgument()
 72:     {
 73:         $result = $this->event->setArgument('foo2', 'bar2');
 74:         $this->assertAttributeSame(array('name' => 'Event', 'foo2' => 'bar2'), 'arguments', $this->event);
 75:         $this->assertEquals($this->event, $result);
 76:     }
 77: 
 78:     public function testGetArgument()
 79:     {
 80:         // test getting key
 81:         $this->assertEquals('Event', $this->event->getArgument('name'));
 82:     }
 83: 
 84:     /**
 85:      * @expectedException \InvalidArgumentException
 86:      */
 87:     public function testGetArgException()
 88:     {
 89:         $this->event->getArgument('nameNotExist');
 90:     }
 91: 
 92:     public function testOffsetGet()
 93:     {
 94:         // test getting key
 95:         $this->assertEquals('Event', $this->event['name']);
 96: 
 97:         // test getting invalid arg
 98:         $this->setExpectedException('InvalidArgumentException');
 99:         $this->assertFalse($this->event['nameNotExist']);
100:     }
101: 
102:     public function testOffsetSet()
103:     {
104:         $this->event['foo2'] = 'bar2';
105:         $this->assertAttributeSame(array('name' => 'Event', 'foo2' => 'bar2'), 'arguments', $this->event);
106:     }
107: 
108:     public function testOffsetUnset()
109:     {
110:         unset($this->event['name']);
111:         $this->assertAttributeSame(array(), 'arguments', $this->event);
112:     }
113: 
114:     public function testOffsetIsset()
115:     {
116:         $this->assertTrue(isset($this->event['name']));
117:         $this->assertFalse(isset($this->event['nameNotExist']));
118:     }
119: 
120:     public function testHasArgument()
121:     {
122:         $this->assertTrue($this->event->hasArgument('name'));
123:         $this->assertFalse($this->event->hasArgument('nameNotExist'));
124:     }
125: 
126:     public function testGetSubject()
127:     {
128:         $this->assertSame($this->subject, $this->event->getSubject());
129:     }
130: 
131:     public function testHasIterator()
132:     {
133:         $data = array();
134:         foreach ($this->event as $key => $value) {
135:             $data[$key] = $value;
136:         }
137:         $this->assertEquals(array('name' => 'Event'), $data);
138:     }
139: }
140: 
Omnipay Fat Zebra / Paystream Gateway Module API Documentation API documentation generated by ApiGen