From 442b43c44f6a4e46f1180d41fdc3313c718ad506 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sat, 4 Feb 2023 11:23:10 +0100 Subject: [PATCH] stop using assertObjectHasAttribute()/assertObjectHasNotAttribute() --- .../Doctrine/Tests/ManagerRegistryTest.php | 3 ++- .../HttpFoundation/Tests/RequestTest.php | 5 +---- .../HttpFoundation/Tests/ResponseTest.php | 21 +++---------------- .../Tests/StreamedResponseTest.php | 7 +------ 4 files changed, 7 insertions(+), 29 deletions(-) diff --git a/src/Symfony/Bridge/Doctrine/Tests/ManagerRegistryTest.php b/src/Symfony/Bridge/Doctrine/Tests/ManagerRegistryTest.php index dd7dabcc87db1..e524ebceff0b8 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/ManagerRegistryTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/ManagerRegistryTest.php @@ -44,7 +44,8 @@ public function testResetService() $registry->resetManager(); $this->assertSame($foo, $container->get('foo')); - $this->assertObjectNotHasAttribute('bar', $foo); + $this->assertInstanceOf(\stdClass::class, $foo); + $this->assertFalse(property_exists($foo, 'bar')); } /** diff --git a/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php b/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php index 058b5419a87f9..bf311044fa2d9 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php @@ -1668,10 +1668,7 @@ public function testGetSession() $request->setSession(new Session(new MockArraySessionStorage())); $this->assertTrue($request->hasSession()); - $session = $request->getSession(); - $this->assertObjectHasAttribute('storage', $session); - $this->assertObjectHasAttribute('flashName', $session); - $this->assertObjectHasAttribute('attributeName', $session); + $this->assertInstanceOf(Session::class, $request->getSession()); } public function testHasPreviousSession() diff --git a/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php index 580099903bb2b..48713e364c208 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php @@ -51,24 +51,14 @@ public function testSendHeaders() { $response = new Response(); $headers = $response->sendHeaders(); - $this->assertObjectHasAttribute('headers', $headers); - $this->assertObjectHasAttribute('content', $headers); - $this->assertObjectHasAttribute('version', $headers); - $this->assertObjectHasAttribute('statusCode', $headers); - $this->assertObjectHasAttribute('statusText', $headers); - $this->assertObjectHasAttribute('charset', $headers); + $this->assertSame($response, $headers); } public function testSend() { $response = new Response(); $responseSend = $response->send(); - $this->assertObjectHasAttribute('headers', $responseSend); - $this->assertObjectHasAttribute('content', $responseSend); - $this->assertObjectHasAttribute('version', $responseSend); - $this->assertObjectHasAttribute('statusCode', $responseSend); - $this->assertObjectHasAttribute('statusText', $responseSend); - $this->assertObjectHasAttribute('charset', $responseSend); + $this->assertSame($response, $responseSend); } public function testGetCharset() @@ -132,12 +122,7 @@ public function testSetNotModified() { $response = new Response('foo'); $modified = $response->setNotModified(); - $this->assertObjectHasAttribute('headers', $modified); - $this->assertObjectHasAttribute('content', $modified); - $this->assertObjectHasAttribute('version', $modified); - $this->assertObjectHasAttribute('statusCode', $modified); - $this->assertObjectHasAttribute('statusText', $modified); - $this->assertObjectHasAttribute('charset', $modified); + $this->assertSame($response, $modified); $this->assertEquals(304, $modified->getStatusCode()); ob_start(); diff --git a/src/Symfony/Component/HttpFoundation/Tests/StreamedResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/StreamedResponseTest.php index 4a58bca442d15..8f76371e08046 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/StreamedResponseTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/StreamedResponseTest.php @@ -127,12 +127,7 @@ public function testSetNotModified() { $response = new StreamedResponse(function () { echo 'foo'; }); $modified = $response->setNotModified(); - $this->assertObjectHasAttribute('headers', $modified); - $this->assertObjectHasAttribute('content', $modified); - $this->assertObjectHasAttribute('version', $modified); - $this->assertObjectHasAttribute('statusCode', $modified); - $this->assertObjectHasAttribute('statusText', $modified); - $this->assertObjectHasAttribute('charset', $modified); + $this->assertSame($response, $modified); $this->assertEquals(304, $modified->getStatusCode()); ob_start();