Skip to content

Commit dd814bf

Browse files
minor #32923 [PhpUnitBridge] Remove calls to deprecated function assertAttributeX (jderusse)
This PR was merged into the 3.4 branch. Discussion ---------- [PhpUnitBridge] Remove calls to deprecated function assertAttributeX | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #32844 | License | MIT | Doc PR | NA This PR remove unecessary call to assertAttribute and replace assertAttributeX by Reflection when no alternative is available. Commits ------- d098c11 Remove calls to deprecated function assertAttributeX
2 parents 5d60221 + d098c11 commit dd814bf

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

src/Symfony/Component/EventDispatcher/Tests/GenericEventTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,14 @@ public function testGetArguments()
6161
public function testSetArguments()
6262
{
6363
$result = $this->event->setArguments(['foo' => 'bar']);
64-
$this->assertAttributeSame(['foo' => 'bar'], 'arguments', $this->event);
64+
$this->assertSame(['foo' => 'bar'], $this->event->getArguments());
6565
$this->assertSame($this->event, $result);
6666
}
6767

6868
public function testSetArgument()
6969
{
7070
$result = $this->event->setArgument('foo2', 'bar2');
71-
$this->assertAttributeSame(['name' => 'Event', 'foo2' => 'bar2'], 'arguments', $this->event);
71+
$this->assertSame(['name' => 'Event', 'foo2' => 'bar2'], $this->event->getArguments());
7272
$this->assertEquals($this->event, $result);
7373
}
7474

@@ -97,13 +97,13 @@ public function testOffsetGet()
9797
public function testOffsetSet()
9898
{
9999
$this->event['foo2'] = 'bar2';
100-
$this->assertAttributeSame(['name' => 'Event', 'foo2' => 'bar2'], 'arguments', $this->event);
100+
$this->assertSame(['name' => 'Event', 'foo2' => 'bar2'], $this->event->getArguments());
101101
}
102102

103103
public function testOffsetUnset()
104104
{
105105
unset($this->event['name']);
106-
$this->assertAttributeSame([], 'arguments', $this->event);
106+
$this->assertSame([], $this->event->getArguments());
107107
}
108108

109109
public function testOffsetIsset()

src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -324,15 +324,15 @@ public function testGetConnectionConnectsIfNeeded()
324324
public function testUrlDsn($url, $expectedDsn, $expectedUser = null, $expectedPassword = null)
325325
{
326326
$storage = new PdoSessionHandler($url);
327-
328-
$this->assertAttributeEquals($expectedDsn, 'dsn', $storage);
329-
330-
if (null !== $expectedUser) {
331-
$this->assertAttributeEquals($expectedUser, 'username', $storage);
332-
}
333-
334-
if (null !== $expectedPassword) {
335-
$this->assertAttributeEquals($expectedPassword, 'password', $storage);
327+
$reflection = new \ReflectionClass(PdoSessionHandler::class);
328+
329+
foreach (['dsn' => $expectedDsn, 'username' => $expectedUser, 'password' => $expectedPassword] as $property => $expectedValue) {
330+
if (!isset($expectedValue)) {
331+
continue;
332+
}
333+
$property = $reflection->getProperty($property);
334+
$property->setAccessible(true);
335+
$this->assertSame($expectedValue, $property->getValue($storage));
336336
}
337337
}
338338

0 commit comments

Comments
 (0)