Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
odan committed Aug 24, 2019
1 parent 177eea6 commit 44b573f
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions tests/TestCase/UnitTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ protected function registerMock(string $class): void
$container = $this->getContainer();

if ($container instanceof Container) {
$definition = $container->extend($class);
$definition->setConcrete($this->createMockObject($class));
$container->add($class, $this->createMockObject($class));
}
}

Expand All @@ -59,21 +58,24 @@ protected function createMockObject(string $class): MockObject
$methods[] = $method->name;
}

return $this->getMockBuilder($class)->disableOriginalConstructor()->setMethods($methods)->getMock();
return $this->getMockBuilder($class)
->disableOriginalConstructor()
->setMethods($methods)
->getMock();
}

/**
* Create a mocked class method.
*
* @param array|callable $method The class and method
*
* @return InvocationMocker The mocked method
* @return InvocationMocker
*/
protected function mockMethod($method): InvocationMocker
{
/** @var MockObject $mock */
$mock = $this->getContainer()->get($method[0] ?? '');
$mock = $this->getContainer()->get((string)$method[0]);

return $mock->method($method[1] ?? '');
return $mock->method((string)$method[1]);
}
}

0 comments on commit 44b573f

Please sign in to comment.