Skip to content

Commit

Permalink
compatibility with PHPUnit >= 5.4
Browse files Browse the repository at this point in the history
  • Loading branch information
xabbuh committed Oct 22, 2016
1 parent 93cf818 commit fa1f6f7
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 52 deletions.
13 changes: 4 additions & 9 deletions Tests/Config/Resource/TranslationManagerResourceTest.php
Expand Up @@ -59,14 +59,9 @@ public function testToString()

private function createDatabaseLoader()
{
$this->databaseLoader = $this->getMock(
'\Asm\TranslationLoaderBundle\Translation\DatabaseLoader',
array(
'isFresh'
),
array(),
'',
false
);
$this->databaseLoader = $this->getMockBuilder('\Asm\TranslationLoaderBundle\Translation\DatabaseLoader')
->disableOriginalConstructor()
->setMethods(array('isFresh'))
->getMock();
}
}
23 changes: 10 additions & 13 deletions Tests/DependencyInjection/Compiler/AddResourcePassTest.php
Expand Up @@ -95,10 +95,9 @@ public function testMultipleLocalesWithMultipleDomains()

public function testWithoutTranslator()
{
$container = $this->getMock(
'\Symfony\Component\DependencyInjection\ContainerBuilder',
array('getParameter', 'findDefinition')
);
$container = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerBuilder')
->setMethods(array('getParameter', 'findDefinition'))
->getMock();
$container
->expects($this->once())
->method('findDefinition')
Expand All @@ -115,10 +114,9 @@ public function testWithoutTranslator()

public function testWithoutTranslatorAndWithoutLocales()
{
$container = $this->getMock(
'\Symfony\Component\DependencyInjection\ContainerBuilder',
array('getParameter', 'findDefinition')
);
$container = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerBuilder')
->setMethods(array('getParameter', 'findDefinition'))
->getMock();
$container
->expects($this->once())
->method('findDefinition')
Expand All @@ -137,11 +135,10 @@ public function testWithoutTranslatorAndWithoutLocales()
*/
private function createContainer()
{
$container = $this->getMock(
'\Symfony\Component\DependencyInjection\ContainerBuilder',
array('getParameter', 'findDefinition')
);
$this->translator = $this->getMock('\Symfony\Component\DependencyInjection\Definition');
$container = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerBuilder')
->setMethods(array('getParameter', 'findDefinition'))
->getMock();
$this->translator = $this->getMockBuilder('\Symfony\Component\DependencyInjection\Definition')->getMock();
$container
->expects($this->any())
->method('findDefinition')
Expand Down
14 changes: 5 additions & 9 deletions Tests/Doctrine/TranslationHistoryManagerTest.php
Expand Up @@ -89,19 +89,15 @@ public function testUpdateTranslationHistoryAndClear()

private function createRepository()
{
$this->repository = $this->getMock(
'Doctrine\ORM\EntityRepository',
array(),
array(),
'',
false
);
$this->repository = $this->getMockBuilder('Doctrine\ORM\EntityRepository')
->disableOriginalConstructor()
->getMock();
}

private function createObjectManager()
{
$this->createRepository();
$this->objectManager = $this->getMock('Doctrine\Common\Persistence\ObjectManager');
$this->objectManager = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager')->getMock();
$this->objectManager
->expects($this->any())
->method('getRepository')
Expand All @@ -113,6 +109,6 @@ private function createObjectManager()
*/
private function createTranslationHistory()
{
return $this->getMock('Asm\TranslationLoaderBundle\Entity\TranslationHistory');
return $this->getMockBuilder('Asm\TranslationLoaderBundle\Entity\TranslationHistory')->getMock();
}
}
14 changes: 5 additions & 9 deletions Tests/Doctrine/TranslationManagerTest.php
Expand Up @@ -172,19 +172,15 @@ protected function createNonFreshTranslation()

private function createRepository()
{
$this->repository = $this->getMock(
'Doctrine\ORM\EntityRepository',
array(),
array(),
'',
false
);
$this->repository = $this->getMockBuilder('Doctrine\ORM\EntityRepository')
->disableOriginalConstructor()
->getMock();
}

private function createObjectManager()
{
$this->createRepository();
$this->objectManager = $this->getMock('Doctrine\Common\Persistence\ObjectManager');
$this->objectManager = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager')->getMock();
$this->objectManager
->expects($this->any())
->method('getRepository')
Expand All @@ -196,6 +192,6 @@ private function createObjectManager()
*/
private function createTranslation()
{
return $this->getMock('Asm\TranslationLoaderBundle\Entity\Translation');
return $this->getMockBuilder('Asm\TranslationLoaderBundle\Entity\Translation')->getMock();
}
}
8 changes: 4 additions & 4 deletions Tests/EventListener/TranslationHistorySubscriberTest.php
Expand Up @@ -110,7 +110,7 @@ public function updateHistoryProvider()
*/
private function createTranslationHistoryManager()
{
$manager = $this->getMock('Asm\TranslationLoaderBundle\Model\TranslationHistoryManagerInterface');
$manager = $this->getMockBuilder('Asm\TranslationLoaderBundle\Model\TranslationHistoryManagerInterface')->getMock();
$manager
->expects($this->any())
->method('createTranslationHistory')
Expand All @@ -132,7 +132,7 @@ private function createAnonymousSecurityContext()
*/
private function createAuthenticatedSecurityContext()
{
$token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$token
->expects($this->any())
->method('getUsername')
Expand Down Expand Up @@ -160,9 +160,9 @@ private function createRandomDummyTranslation()
private function mockTokenStorage()
{
if (interface_exists('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')) {
return $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
} else {
return $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface');
return $this->getMockBuilder('Symfony\Component\Security\Core\SecurityContextInterface')->getMock();
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/Model/TranslationManagerTest.php
Expand Up @@ -32,7 +32,7 @@ abstract class TranslationManagerTest extends \PHPUnit_Framework_TestCase

protected function setUp()
{
$this->eventDispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
$this->eventDispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
$this->translationManager = $this->createTranslationManager();
}

Expand Down
10 changes: 3 additions & 7 deletions Tests/Translation/DatabaseLoaderTest.php
Expand Up @@ -107,13 +107,9 @@ public function testGetResource()

private function createTranslationManager()
{
$this->translationManager = $this->getMock(
'Asm\TranslationLoaderBundle\Model\TranslationManager',
array(),
array(),
'',
false
);
$this->translationManager = $this->getMockBuilder('Asm\TranslationLoaderBundle\Model\TranslationManager')
->disableOriginalConstructor()
->getMock();
$this->translationManager
->expects($this->once())
->method('findTranslationsByLocaleAndDomain')
Expand Down

0 comments on commit fa1f6f7

Please sign in to comment.