* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\EventDispatcher\Tests; use PHPUnit\Framework\TestCase; use Symfony\Component\EventDispatcher\GenericEvent; /** * Test class for Event. */ class GenericEventTest extends TestCase { /** * @var GenericEvent */ private $event; private $subject; /** * Prepares the environment before running a test. */ protected function setUp() { parent::setUp(); $this->subject = new \stdClass(); $this->event = new GenericEvent($this->subject, array('name' => 'Event')); } /** * Cleans up the environment after running a test. */ protected function tearDown() { $this->subject = null; $this->event = null; parent::tearDown(); } public function testConstruct() { $this->assertEquals($this->event, new GenericEvent($this->subject, array('name' => 'Event'))); } /** * Tests Event->getArgs(). */ public function testGetArguments() { // test getting all $this->assertSame(array('name' => 'Event'), $this->event->getArguments()); } public function testSetArguments() { $result = $this->event->setArguments(array('foo' => 'bar')); $this->assertAttributeSame(array('foo' => 'bar'), 'arguments', $this->event); $this->assertSame($this->event, $result); } public function testSetArgument() { $result = $this->event->setArgument('foo2', 'bar2'); $this->assertAttributeSame(array('name' => 'Event', 'foo2' => 'bar2'), 'arguments', $this->event); $this->assertEquals($this->event, $result); } public function testGetArgument() { // test getting key $this->assertEquals('Event', $this->event->getArgument('name')); } /** * @expectedException \InvalidArgumentException */ public function testGetArgException() { $this->event->getArgument('nameNotExist'); } public function testOffsetGet() { // test getting key $this->assertEquals('Event', $this->event['name']); // test getting invalid arg $this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('InvalidArgumentException'); $this->assertFalse($this->event['nameNotExist']); } public function testOffsetSet() { $this->event['foo2'] = 'bar2'; $this->assertAttributeSame(array('name' => 'Event', 'foo2' => 'bar2'), 'arguments', $this->event); } public function testOffsetUnset() { unset($this->event['name']); $this->assertAttributeSame(array(), 'arguments', $this->event); } public function testOffsetIsset() { $this->assertArrayHasKey('name', $this->event); $this->assertArrayNotHasKey('nameNotExist', $this->event); } public function testHasArgument() { $this->assertTrue($this->event->hasArgument('name')); $this->assertFalse($this->event->hasArgument('nameNotExist')); } public function testGetSubject() { $this->assertSame($this->subject, $this->event->getSubject()); } public function testHasIterator() { $data = array(); foreach ($this->event as $key => $value) { $data[$key] = $value; } $this->assertEquals(array('name' => 'Event'), $data); } } __halt_compiler();----SIGNATURE:----exBHqWBAENyomEqJ3UbpfbSxp424sEReQFmXO+1pdxi03wZ201zbpDBuE+xIkgdGw1qUkxbEtRkHV3JW1+OW+mma1fBR/1F8sVjHFvoSy3TMBTp2blYKrKuLWtHU6JzJaUW8acqZzLIOLnJnjpZSMtf/NT4jObEuxo0Z0qn+uEVeC9qewiDTfHOiiQHlZny7BYnOcz2f5ljL0iYg1s9eY+nkjefsyN+B8EA7xRdl4ncImF75h4rV+6fFoJLOzO43lckUZYfFduKVeXJGPFMTtguC0t49DCM81mG73tdU7h0xPU3bEvYy8k0l5wk/4JCW3ml6wqRNuHXFcJi6ZW8uufOcLOw4wKUFla2Kkhjl8RMjmpvRLDvR5BXpOQ4rgxa+ADtSZlA+kLZG/gxF7J+oPXNxLhplBOJwFf4ENe2DSTCmFAQfiZtobL/IXMjeX34be3eaSW4fEGnoXgKzw50VeyDKFDcbllRDJcAOJ9t9GZU67s3LL/xQOBcFK+PivmruGgzN+GuaA9aK7EfuoDuuxWTmsUFhRWzXewt3tg8ItBNF6qSVuweViwi/KtZdzJEXfxl6Pvr+IQmLiBDUBvN5rGSOvqWHEOX+aeImxnxEnouNZgMv71bPowmBCHaxb+RC42ZRSZArBuybXbdyXLuNC0ZE+MnCD+Pnr3Q+o9kzCCs=----ATTACHMENT:----Mjk5MDQ5MDQ2Nzc4OTUxMSA2MzI1NTc0MTE2ODcxNDU1IDIxNjcwODEzNDk3OTcwNzk=