UnitTestCase::getObjectCreator()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
/**
4
 * Created by PhpStorm.
5
 * User: benedikt
6
 * Date: 1/30/18
7
 * Time: 7:06 PM
8
 */
9
10
namespace Tfboe\FmLib\Tests\Helpers;
11
12
use Tfboe\FmLib\Service\ObjectCreatorServiceInterface;
13
14
/**
15
 * Class UnitTestCase
16
 * @package Tfboe\FmLib\Tests\Helpers
17
 */
18
class UnitTestCase extends \Tfboe\FmLib\TestHelpers\UnitTestCase
19
{
20
//<editor-fold desc="Protected Methods">
21
  /**
22
   * Creates an object creator which creates objects from the Tfboe\FmLib\Tests\Entity namespace
23
   * @return ObjectCreatorServiceInterface
24
   */
25
  protected function getObjectCreator(): ObjectCreatorServiceInterface
26
  {
27
    $objectCreatorService = $this->createMock(ObjectCreatorServiceInterface::class);
28
    $objectCreatorService->method('createObjectFromInterface')->willReturnCallback(function ($if, $args) {
0 ignored issues
show
Bug introduced by
The method method() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject>.

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.

Loading history...
29
      $class = str_replace("\\Entity\\", "\\Tests\\Entity\\", $if);
30
      $class = str_replace("Interface", "", $class);
31
      return new $class(...$args);
32
    });
33
    /** @var ObjectCreatorServiceInterface $objectCreatorService */
34
    return $objectCreatorService;
35
  }
36
//</editor-fold desc="Protected Methods">
37
}