Explorar o código

Silence internal deprecation notices (#3818)

We are only interested in deprecation notices from external libraries
(which can happen when tests are not really unit tests).
Grégoire Paris %!s(int64=9) %!d(string=hai) anos
pai
achega
b9196af4a7
Modificáronse 1 ficheiros con 23 adicións e 1 borrados
  1. 23 1
      Tests/Twig/Extension/SonataAdminExtensionTest.php

+ 23 - 1
Tests/Twig/Extension/SonataAdminExtensionTest.php

@@ -1764,16 +1764,35 @@ EOT
                 if ($value == 'associated_property') {
                     return $default;
                 }
+            }));
+
+        $element = new FooToString();
+        $this->assertSame('salut', $this->twigExtension->renderRelationElement($element, $this->fieldDescription));
+    }
 
+    /**
+     * @group legacy
+     */
+    public function testDeprecatedRelationElementToString()
+    {
+        $this->fieldDescription->expects($this->exactly(2))
+            ->method('getOption')
+            ->will($this->returnCallback(function ($value, $default = null) {
                 if ($value == 'associated_tostring') {
                     return '__toString';
                 }
             }));
 
         $element = new FooToString();
-        $this->assertSame('salut', $this->twigExtension->renderRelationElement($element, $this->fieldDescription));
+        $this->assertSame(
+            'salut',
+            $this->twigExtension->renderRelationElement($element, $this->fieldDescription)
+        );
     }
 
+    /**
+     * @group legacy
+     */
     public function testRenderRelationElementCustomToString()
     {
         $this->fieldDescription->expects($this->exactly(2))
@@ -1796,6 +1815,9 @@ EOT
         $this->assertSame('fooBar', $this->twigExtension->renderRelationElement($element, $this->fieldDescription));
     }
 
+    /**
+     * @group legacy
+     */
     public function testRenderRelationElementMethodNotExist()
     {
         $this->fieldDescription->expects($this->exactly(2))