Skip to content

Commit

Permalink
chore(Deps): update phpunit (#40)
Browse files Browse the repository at this point in the history
* chore(Deps): update phpunit

* chore(Deps): drop php 5 support
  • Loading branch information
cdaguerre authored and Pitoune committed Mar 20, 2018
1 parent 959c028 commit 13fed49
Show file tree
Hide file tree
Showing 16 changed files with 87 additions and 74 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ language: php
sudo: false

php:
- 5.6
- 7.0
- 7.1
- 7.2
Expand Down
6 changes: 3 additions & 3 deletions Features/Context/ProductContextTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Behat\Gherkin\Node\TableNode;
use Doctrine\ORM\EntityManagerInterface;
use PHPUnit_Framework_Assert;
use PHPUnit\Framework\Assert;
use Worldia\Bundle\ProductTestBundle\Entity\Product;

trait ProductContextTrait
Expand Down Expand Up @@ -63,8 +63,8 @@ public function createProductTranslations(Product $product, TableNode $table)
public function assertProductTranslations(Product $product, TableNode $table)
{
foreach ($table->getHash() as $data) {
PHPUnit_Framework_Assert::assertSame($data['title'], $product->getTranslation($data['locale'])->getTitle());
PHPUnit_Framework_Assert::assertSame($data['description'], $product->getTranslation($data['locale'])->getDescription());
Assert::assertSame($data['title'], $product->getTranslation($data['locale'])->getTitle());
Assert::assertSame($data['description'], $product->getTranslation($data['locale'])->getDescription());
}
}
}
30 changes: 15 additions & 15 deletions Features/Context/TranslationContextTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Behat\Gherkin\Node\TableNode;
use Doctrine\ORM\EntityManagerInterface;
use PHPUnit_Framework_Assert;
use PHPUnit\Framework\Assert;;
use Symfony\Component\HttpKernel\KernelInterface;
use Worldia\Bundle\TextmasterBundle\Entity\JobInterface;
use Worldia\Bundle\TextmasterBundle\EntityManager\JobManagerInterface;
Expand Down Expand Up @@ -75,11 +75,11 @@ public function assertJobs(TableNode $table)
foreach ($table->getHash() as $data) {
$job = $this->findJob($data['id']);

PHPUnit_Framework_Assert::assertSame($data['status'], $job->getStatus());
PHPUnit_Framework_Assert::assertSame($data['locale'], $job->getLocale());
PHPUnit_Framework_Assert::assertSame((int) $data['translatable'], $job->getTranslatable()->getId());
PHPUnit_Framework_Assert::assertSame($data['project'], $job->getProjectId());
PHPUnit_Framework_Assert::assertSame($data['document'], $job->getDocumentId());
Assert::assertSame($data['status'], $job->getStatus());
Assert::assertSame($data['locale'], $job->getLocale());
Assert::assertSame((int) $data['translatable'], $job->getTranslatable()->getId());
Assert::assertSame($data['project'], $job->getProjectId());
Assert::assertSame($data['document'], $job->getDocumentId());
}
}

Expand All @@ -105,13 +105,13 @@ public function createTranslationProject(TableNode $table)
);

if (null !== $project) {
PHPUnit_Framework_Assert::assertSame($data['name'], $project->getName());
PHPUnit_Framework_Assert::assertSame(isset($data['activity']) ? $data['activity'] : null, $project->getActivity());
PHPUnit_Framework_Assert::assertSame($data['languageFrom'], $project->getLanguageFrom());
PHPUnit_Framework_Assert::assertSame(isset($data['languageTo']) ? $data['languageTo'] : null, $project->getLanguageTo());
PHPUnit_Framework_Assert::assertSame($data['category'], $project->getCategory());
PHPUnit_Framework_Assert::assertSame($data['briefing'], $project->getBriefing());
PHPUnit_Framework_Assert::assertSame(json_decode($data['options'], true), $project->getOptions());
Assert::assertSame($data['name'], $project->getName());
Assert::assertSame(isset($data['activity']) ? $data['activity'] : null, $project->getActivity());
Assert::assertSame($data['languageFrom'], $project->getLanguageFrom());
Assert::assertSame(isset($data['languageTo']) ? $data['languageTo'] : null, $project->getLanguageTo());
Assert::assertSame($data['category'], $project->getCategory());
Assert::assertSame($data['briefing'], $project->getBriefing());
Assert::assertSame(json_decode($data['options'], true), $project->getOptions());
}
}
}
Expand All @@ -121,7 +121,7 @@ public function createTranslationProject(TableNode $table)
*/
public function assertJobStatus(JobInterface $job, $status)
{
PHPUnit_Framework_Assert::assertSame($status, $job->getStatus());
Assert::assertSame($status, $job->getStatus());
}

/**
Expand All @@ -131,7 +131,7 @@ public function assertTranslatablesWithJob($number, $class, $locale)
{
$count = count($this->getJobManager()->getTranslatablesWithJobAndLocale($class, $locale));

PHPUnit_Framework_Assert::assertSame((int) $number, $count);
Assert::assertSame((int) $number, $count);
}

/**
Expand Down
10 changes: 5 additions & 5 deletions Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<argument type="service" id="worldia.textmaster.api.client" />
</service>

<service id="worldia.textmaster.api.handler" class="%worldia.textmaster.api.handler.class%">
<service id="worldia.textmaster.api.handler" class="%worldia.textmaster.api.handler.class%" public="true">
<argument type="service" id="event_dispatcher" />
<argument type="service" id="worldia.textmaster.api.client" />
</service>
Expand All @@ -57,20 +57,20 @@
<tag name="textmaster_translator_factory" />
</service>

<service id="worldia.textmaster.manager.job" class="%worldia.textmaster.manager.job.class%">
<service id="worldia.textmaster.manager.job" class="%worldia.textmaster.manager.job.class%" public="true">
<argument type="service" id="doctrine.orm.entity_manager" />
<argument type="service" id="worldia.textmaster.api.manager" />
<argument type="service" id="worldia.textmaster.repository.job" />
</service>

<service id="worldia.textmaster.manager.translation" class="%worldia.textmaster.manager.translation.class%">
<service id="worldia.textmaster.manager.translation" class="%worldia.textmaster.manager.translation.class%" public="true">
<argument type="service" id="worldia.textmaster.api.manager" />
<argument type="service" id="worldia.textmaster.api.translator" />
<argument type="service" id="router" />
<argument>%worldia.textmaster.copywriting_word_count%</argument>
</service>

<service id="worldia.textmaster.generator.translation" class="%worldia.textmaster.generator.translation.class%">
<service id="worldia.textmaster.generator.translation" class="%worldia.textmaster.generator.translation.class%" public="true">
<argument type="service" id="worldia.textmaster.manager.translation" />
</service>

Expand All @@ -89,7 +89,7 @@
<tag name="doctrine.event_subscriber" connection="default" priority="50" />
</service>

<service id="worldia.textmaster.repository.job" class="%worldia.textmaster.repository.job.class%">
<service id="worldia.textmaster.repository.job" class="%worldia.textmaster.repository.job.class%" public="true">
<factory service="doctrine" method="getRepository"/>
<argument>%worldia.textmaster.job.class%</argument>
</service>
Expand Down
6 changes: 5 additions & 1 deletion Tests/Fixtures/Project/app/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,12 @@ public function getLogDir()

private function guessTempDirectoryFor($dirname)
{
return is_writable(__DIR__.'/../../../../build/tmp') ?
$dir = is_writable(__DIR__.'/../../../../build/tmp') ?
__DIR__.'/build/tmp/'.$dirname
: sys_get_temp_dir().'/'.$this->mainBundle.'/'.$dirname;

// var_dump($dir);
// die;
return $dir;
}
}
3 changes: 2 additions & 1 deletion Tests/Fixtures/Project/app/config/config_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ framework:
secret: test
test: ~
router:
resource: %kernel.root_dir%/config/routing.yml
resource: '%kernel.root_dir%/config/routing.yml'
session:
storage_id: session.storage.mock_file
form: true
Expand All @@ -29,6 +29,7 @@ services:
worldia.textmaster.project.api:
class: Worldia\Bundle\ProductTestBundle\Service\ProjectApi
arguments: ['@worldia.textmaster.api.client', '@worldia.textmaster.document.api']
public: true

worldia.textmaster.project_author.api:
class: Worldia\Bundle\ProductTestBundle\Service\Project\AuthorApi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

interface TranslatableInterface
{
public function getId();

/**
* Translation method.
*
Expand Down
3 changes: 2 additions & 1 deletion Tests/Units/DependencyInjection/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
namespace Worldia\Bundle\TextmasterBundle\Tests\Units\DependencyInjection;

use Matthias\SymfonyConfigTest\PhpUnit\ConfigurationTestCaseTrait;
use PHPUnit\Framework\TestCase;
use Worldia\Bundle\TextmasterBundle\DependencyInjection\Configuration;

class ConfigurationTest extends \PHPUnit_Framework_TestCase
class ConfigurationTest extends TestCase
{
use ConfigurationTestCaseTrait;

Expand Down
7 changes: 4 additions & 3 deletions Tests/Units/EntityManager/JobManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

namespace Worldia\Bundle\TextmasterBundle\Tests\Units\EntityManager;

use PHPUnit\Framework\TestCase;
use Worldia\Bundle\TextmasterBundle\Entity\Job;
use Worldia\Bundle\TextmasterBundle\Entity\JobInterface;
use Worldia\Bundle\TextmasterBundle\EntityManager\JobManager;

class JobManagerTest extends \PHPUnit_Framework_TestCase
class JobManagerTest extends TestCase
{
protected $entityManagerMock;
protected $textmasterManagerMock;
Expand All @@ -16,7 +17,7 @@ class JobManagerTest extends \PHPUnit_Framework_TestCase

public function setUp()
{
$this->entityManagerMock = $this->getMock('Doctrine\ORM\EntityManagerInterface');
$this->entityManagerMock = $this->createMock('Doctrine\ORM\EntityManagerInterface');

$this->textmasterManagerMock = $this
->getMockBuilder('Textmaster\Manager')
Expand All @@ -28,7 +29,7 @@ public function setUp()
->disableOriginalConstructor()
->getMock();

$this->translatableMock = $this->getMock('TranslatableInterface', array('getId'));
$this->translatableMock = $this->createMock('Worldia\Bundle\ProductTestBundle\Entity\TranslatableInterface', array('getId'));
$this->translatableMock->expects($this->once())
->method('getId')
->willReturn(1);
Expand Down
21 changes: 11 additions & 10 deletions Tests/Units/EventListener/DocumentListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

namespace Worldia\Bundle\TextmasterBundle\Tests\Units\EventListener;

use PHPUnit\Framework\TestCase;
use Textmaster\Events;
use Textmaster\Model\Project;
use Worldia\Bundle\TextmasterBundle\EventListener\DocumentListener;

class DocumentListenerTest extends \PHPUnit_Framework_TestCase
class DocumentListenerTest extends TestCase
{
/**
* @var DocumentListener
Expand All @@ -20,11 +21,11 @@ class DocumentListenerTest extends \PHPUnit_Framework_TestCase

public function setUp()
{
$this->jobManagerMock = $this->getMock('Worldia\Bundle\TextmasterBundle\EntityManager\JobManagerInterface');
$this->translatorMock = $this->getMock('Textmaster\Translator\TranslatorInterface');
$this->jobManagerMock = $this->createMock('Worldia\Bundle\TextmasterBundle\EntityManager\JobManagerInterface');
$this->translatorMock = $this->createMock('Textmaster\Translator\TranslatorInterface');

$this->eventMock = $this->getMock('Symfony\Component\EventDispatcher\GenericEvent');
$this->documentMock = $this->getMock('Textmaster\Model\DocumentInterface');
$this->eventMock = $this->createMock('Symfony\Component\EventDispatcher\GenericEvent');
$this->documentMock = $this->createMock('Textmaster\Model\DocumentInterface');

$this->listener = new DocumentListener($this->jobManagerMock, $this->translatorMock);
}
Expand All @@ -49,8 +50,8 @@ public function shouldGetSubscribedEvents()
*/
public function shouldCreateJobWhenDocumentInCreation()
{
$objectMock = $this->getMock('ObjectInterface');
$projectMock = $this->getMock('Textmaster\Model\ProjectInterface');
$objectMock = $this->createMock('Worldia\Bundle\ProductTestBundle\Entity\Product');
$projectMock = $this->createMock('Textmaster\Model\ProjectInterface');

$this->eventMock->expects($this->once())
->method('getSubject')
Expand Down Expand Up @@ -83,7 +84,7 @@ public function shouldCreateJobWhenDocumentInCreation()
public function shouldFinishJobWhenDocumentInReview()
{
$eventMock = $this->getMockBuilder('Textmaster\Event\CallbackEvent')->disableOriginalConstructor()->getMock();
$jobMock = $this->getMock('Worldia\Bundle\TextmasterBundle\Entity\JobInterface');
$jobMock = $this->createMock('Worldia\Bundle\TextmasterBundle\Entity\JobInterface');

$eventMock->expects($this->once())
->method('getSubject')
Expand All @@ -104,7 +105,7 @@ public function shouldFinishJobWhenDocumentInReview()
*/
public function shouldValidateJobWhenDocumentCompleted()
{
$jobMock = $this->getMock('Worldia\Bundle\TextmasterBundle\Entity\JobInterface');
$jobMock = $this->createMock('Worldia\Bundle\TextmasterBundle\Entity\JobInterface');

$this->eventMock->expects($this->once())
->method('getSubject')
Expand All @@ -125,7 +126,7 @@ public function shouldValidateJobWhenDocumentCompleted()
*/
public function shouldStartJobWhenDocumentIncomplete()
{
$jobMock = $this->getMock('Worldia\Bundle\TextmasterBundle\Entity\JobInterface');
$jobMock = $this->createMock('Worldia\Bundle\TextmasterBundle\Entity\JobInterface');

$this->eventMock->expects($this->once())
->method('getSubject')
Expand Down
11 changes: 6 additions & 5 deletions Tests/Units/EventListener/JobListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
namespace Worldia\Bundle\TextmasterBundle\Tests\Units\EventListener;

use Doctrine\ORM\Events;
use PHPUnit\Framework\TestCase;
use Worldia\Bundle\TextmasterBundle\EventListener\JobListener;

class JobListenerTest extends \PHPUnit_Framework_TestCase
class JobListenerTest extends TestCase
{
/**
* @var JobListener
Expand Down Expand Up @@ -42,10 +43,10 @@ public function shouldGetSubscribedEvents()
*/
public function shouldSetTranslatableOnPostLoad()
{
$jobMock = $this->getMock('Worldia\Bundle\TextmasterBundle\Entity\JobInterface');
$translatableMock = $this->getMock('TranslatableInterface');
$objectManagerMock = $this->getMock('Doctrine\Common\Persistence\ObjectManager');
$objectRepositoryMock = $this->getMock('Doctrine\Common\Persistence\ObjectRepository');
$jobMock = $this->createMock('Worldia\Bundle\TextmasterBundle\Entity\JobInterface');
$translatableMock = $this->createMock('Worldia\Bundle\ProductTestBundle\Entity\TranslatableInterface');
$objectManagerMock = $this->createMock('Doctrine\Common\Persistence\ObjectManager');
$objectRepositoryMock = $this->createMock('Doctrine\Common\Persistence\ObjectRepository');

$this->eventMock->expects($this->once())
->method('getEntity')
Expand Down
9 changes: 5 additions & 4 deletions Tests/Units/EventListener/ProjectListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

namespace Worldia\Bundle\TextmasterBundle\Tests\Units\EventListener;

use PHPUnit\Framework\TestCase;
use Textmaster\Events;
use Worldia\Bundle\TextmasterBundle\EventListener\ProjectListener;

class ProjectListenerTest extends \PHPUnit_Framework_TestCase
class ProjectListenerTest extends TestCase
{
/**
* @var ProjectListener
Expand All @@ -16,7 +17,7 @@ class ProjectListenerTest extends \PHPUnit_Framework_TestCase

public function setUp()
{
$this->jobManagerMock = $this->getMock('Worldia\Bundle\TextmasterBundle\EntityManager\JobManagerInterface');
$this->jobManagerMock = $this->createMock('Worldia\Bundle\TextmasterBundle\EntityManager\JobManagerInterface');
$this->listener = new ProjectListener($this->jobManagerMock);
}

Expand All @@ -39,7 +40,7 @@ public function shouldGetSubscribedEvents()
public function shouldStartJobsWhenProjectInProgress()
{
$eventMock = $this->getMockBuilder('Textmaster\Event\CallbackEvent')->disableOriginalConstructor()->getMock();
$projectMock = $this->getMock('Textmaster\Model\ProjectInterface');
$projectMock = $this->createMock('Textmaster\Model\ProjectInterface');

$eventMock->expects($this->once())
->method('getSubject')
Expand All @@ -57,7 +58,7 @@ public function shouldStartJobsWhenProjectInProgress()
public function shouldLaunchProjectWhenProjectMemoryCompleted()
{
$eventMock = $this->getMockBuilder('Textmaster\Event\CallbackEvent')->disableOriginalConstructor()->getMock();
$projectMock = $this->getMock('Textmaster\Model\ProjectInterface');
$projectMock = $this->createMock('Textmaster\Model\ProjectInterface');

$eventMock->expects($this->once())
->method('getSubject')
Expand Down
Loading

0 comments on commit 13fed49

Please sign in to comment.