From: William Desportes <williamdes@wdes.fr>
Date: Sun, 9 Jun 2024 12:56:17 +0200
Subject: Remove phpunit mocks

Closes: #1070599

Origin: vendor
Forwarded: https://github.com/slimphp/Slim-Psr7/pull/311
---
 tests/ResponseTest.php |  7 +------
 tests/TestObject.php   | 23 +++++++++++++++++++++++
 tests/UriTest.php      | 15 +++------------
 3 files changed, 27 insertions(+), 18 deletions(-)
 create mode 100644 tests/TestObject.php

diff --git a/tests/ResponseTest.php b/tests/ResponseTest.php
index 7bd3206..a1fb045 100644
--- a/tests/ResponseTest.php
+++ b/tests/ResponseTest.php
@@ -141,13 +141,8 @@ class ResponseTest extends TestCase
 
     public function testWithStatusValidReasonPhraseObject()
     {
-        $mock = $this->getMockBuilder(stdClass::class)->addMethods(['__toString'])->getMock();
-        $mock->expects($this->once())
-            ->method('__toString')
-            ->will($this->returnValue('Slim OK'));
-
         $response = new Response();
-        $response = $response->withStatus(200, $mock);
+        $response = $response->withStatus(200, new TestObject('Slim OK'));
         $this->assertEquals('Slim OK', $response->getReasonPhrase());
     }
 
diff --git a/tests/TestObject.php b/tests/TestObject.php
new file mode 100644
index 0000000..631b4ca
--- /dev/null
+++ b/tests/TestObject.php
@@ -0,0 +1,23 @@
+<?php
+
+/**
+ * Slim Framework (https://slimframework.com)
+ *
+ * @license https://github.com/slimphp/Slim-Psr7/blob/master/LICENSE.md (MIT License)
+ */
+
+declare(strict_types=1);
+
+namespace Slim\Tests\Psr7;
+
+final class TestObject implements \Stringable
+{
+    public function __construct(private string $value)
+    {
+    }
+
+    public function __toString(): string
+    {
+        return $this->value;
+    }
+}
diff --git a/tests/UriTest.php b/tests/UriTest.php
index 92077ec..a307720 100644
--- a/tests/UriTest.php
+++ b/tests/UriTest.php
@@ -133,10 +133,7 @@ class UriTest extends TestCase
 
     public function testWithHostValidObject()
     {
-        $mock = $this->getMockBuilder(stdClass::class)->addMethods(['__toString'])->getMock();
-        $mock->expects($this->once())
-            ->method('__toString')
-            ->will($this->returnValue('host.test'));
+        $mock = new TestObject('host.test');
 
         $uri = $this->uriFactory()->withHost($mock);
         $this->assertEquals('host.test', $uri->getHost());
@@ -298,10 +295,7 @@ class UriTest extends TestCase
 
     public function testWithQueryValidObject()
     {
-        $mock = $this->getMockBuilder(stdClass::class)->addMethods(['__toString'])->getMock();
-        $mock->expects($this->once())
-            ->method('__toString')
-            ->will($this->returnValue('xyz=123'));
+        $mock = new TestObject('xyz=123');
 
         $uri = $this->uriFactory()->withQuery($mock);
         $this->assertEquals('xyz=123', $uri->getQuery());
@@ -350,10 +344,7 @@ class UriTest extends TestCase
 
     public function testWithFragmentValidObject()
     {
-        $mock = $this->getMockBuilder(stdClass::class)->addMethods(['__toString'])->getMock();
-        $mock->expects($this->once())
-            ->method('__toString')
-            ->will($this->returnValue('other-fragment'));
+        $mock = new TestObject('other-fragment');
 
         $uri = $this->uriFactory()->withFragment($mock);
         $this->assertEquals('other-fragment', $uri->getFragment());
