Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
1 | <?php |
||
23 | class TranslatableAdminExtensionTest extends WebTestCase |
||
24 | { |
||
25 | /** |
||
26 | * @var AdminInterface |
||
27 | */ |
||
28 | protected $admin; |
||
29 | |||
30 | /** |
||
31 | * @var TranslatableEntity |
||
32 | */ |
||
33 | protected $object; |
||
34 | |||
35 | /** |
||
36 | * @var TranslatableAdminExtension |
||
37 | */ |
||
38 | protected $extension; |
||
39 | |||
40 | protected function setUp() |
||
41 | { |
||
42 | $translatableChecker = new TranslatableChecker(); |
||
43 | $translatableChecker->setSupportedInterfaces(array( |
||
44 | 'Sonata\TranslationBundle\Model\TranslatableInterface', |
||
45 | )); |
||
46 | $this->extension = new TranslatableAdminExtension($translatableChecker); |
||
47 | |||
48 | $request = $this->prophesize('Symfony\Component\HttpFoundation\Request'); |
||
49 | $request->get('tl')->willReturn('es'); |
||
50 | |||
51 | $this->admin = $this->prophesize('Sonata\AdminBundle\Admin\AdminInterface'); |
||
52 | $this->admin->getRequest()->willReturn($request->reveal()); |
||
53 | |||
54 | $this->object = new TranslatableEntity(); |
||
55 | } |
||
56 | |||
57 | public function testSetLocaleForTranslatableObject() |
||
63 | |||
64 | public function testAlertObjectForTranslatableObject() |
||
70 | |||
71 | View Code Duplication | public function testPreUpdate() |
|
78 | |||
79 | View Code Duplication | public function testPrePersist() |
|
86 | } |
||
87 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.