Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/event-dispatcher/Tests/GenericEventTest.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | 1fec387a4317 |
children |
comparison
equal
deleted
inserted
replaced
16:c2387f117808 | 17:129ea1e6d783 |
---|---|
29 /** | 29 /** |
30 * Prepares the environment before running a test. | 30 * Prepares the environment before running a test. |
31 */ | 31 */ |
32 protected function setUp() | 32 protected function setUp() |
33 { | 33 { |
34 parent::setUp(); | |
35 | |
36 $this->subject = new \stdClass(); | 34 $this->subject = new \stdClass(); |
37 $this->event = new GenericEvent($this->subject, array('name' => 'Event')); | 35 $this->event = new GenericEvent($this->subject, ['name' => 'Event']); |
38 } | 36 } |
39 | 37 |
40 /** | 38 /** |
41 * Cleans up the environment after running a test. | 39 * Cleans up the environment after running a test. |
42 */ | 40 */ |
43 protected function tearDown() | 41 protected function tearDown() |
44 { | 42 { |
45 $this->subject = null; | 43 $this->subject = null; |
46 $this->event = null; | 44 $this->event = null; |
47 | |
48 parent::tearDown(); | |
49 } | 45 } |
50 | 46 |
51 public function testConstruct() | 47 public function testConstruct() |
52 { | 48 { |
53 $this->assertEquals($this->event, new GenericEvent($this->subject, array('name' => 'Event'))); | 49 $this->assertEquals($this->event, new GenericEvent($this->subject, ['name' => 'Event'])); |
54 } | 50 } |
55 | 51 |
56 /** | 52 /** |
57 * Tests Event->getArgs(). | 53 * Tests Event->getArgs(). |
58 */ | 54 */ |
59 public function testGetArguments() | 55 public function testGetArguments() |
60 { | 56 { |
61 // test getting all | 57 // test getting all |
62 $this->assertSame(array('name' => 'Event'), $this->event->getArguments()); | 58 $this->assertSame(['name' => 'Event'], $this->event->getArguments()); |
63 } | 59 } |
64 | 60 |
65 public function testSetArguments() | 61 public function testSetArguments() |
66 { | 62 { |
67 $result = $this->event->setArguments(array('foo' => 'bar')); | 63 $result = $this->event->setArguments(['foo' => 'bar']); |
68 $this->assertAttributeSame(array('foo' => 'bar'), 'arguments', $this->event); | 64 $this->assertAttributeSame(['foo' => 'bar'], 'arguments', $this->event); |
69 $this->assertSame($this->event, $result); | 65 $this->assertSame($this->event, $result); |
70 } | 66 } |
71 | 67 |
72 public function testSetArgument() | 68 public function testSetArgument() |
73 { | 69 { |
74 $result = $this->event->setArgument('foo2', 'bar2'); | 70 $result = $this->event->setArgument('foo2', 'bar2'); |
75 $this->assertAttributeSame(array('name' => 'Event', 'foo2' => 'bar2'), 'arguments', $this->event); | 71 $this->assertAttributeSame(['name' => 'Event', 'foo2' => 'bar2'], 'arguments', $this->event); |
76 $this->assertEquals($this->event, $result); | 72 $this->assertEquals($this->event, $result); |
77 } | 73 } |
78 | 74 |
79 public function testGetArgument() | 75 public function testGetArgument() |
80 { | 76 { |
101 } | 97 } |
102 | 98 |
103 public function testOffsetSet() | 99 public function testOffsetSet() |
104 { | 100 { |
105 $this->event['foo2'] = 'bar2'; | 101 $this->event['foo2'] = 'bar2'; |
106 $this->assertAttributeSame(array('name' => 'Event', 'foo2' => 'bar2'), 'arguments', $this->event); | 102 $this->assertAttributeSame(['name' => 'Event', 'foo2' => 'bar2'], 'arguments', $this->event); |
107 } | 103 } |
108 | 104 |
109 public function testOffsetUnset() | 105 public function testOffsetUnset() |
110 { | 106 { |
111 unset($this->event['name']); | 107 unset($this->event['name']); |
112 $this->assertAttributeSame(array(), 'arguments', $this->event); | 108 $this->assertAttributeSame([], 'arguments', $this->event); |
113 } | 109 } |
114 | 110 |
115 public function testOffsetIsset() | 111 public function testOffsetIsset() |
116 { | 112 { |
117 $this->assertArrayHasKey('name', $this->event); | 113 $this->assertArrayHasKey('name', $this->event); |
129 $this->assertSame($this->subject, $this->event->getSubject()); | 125 $this->assertSame($this->subject, $this->event->getSubject()); |
130 } | 126 } |
131 | 127 |
132 public function testHasIterator() | 128 public function testHasIterator() |
133 { | 129 { |
134 $data = array(); | 130 $data = []; |
135 foreach ($this->event as $key => $value) { | 131 foreach ($this->event as $key => $value) { |
136 $data[$key] = $value; | 132 $data[$key] = $value; |
137 } | 133 } |
138 $this->assertEquals(array('name' => 'Event'), $data); | 134 $this->assertEquals(['name' => 'Event'], $data); |
139 } | 135 } |
140 } | 136 } |