Skip to content

Commit

Permalink
Modify EntityManager to EntityManagerInterface
Browse files Browse the repository at this point in the history
  • Loading branch information
nanasess committed Jan 11, 2018
1 parent 93b4497 commit 6c60ed5
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 42 deletions.
4 changes: 2 additions & 2 deletions tests/Eccube/Tests/EccubeTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Eccube\Tests;

use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Eccube\Entity\Customer;
use Eccube\Tests\Fixture\Generator;
use Faker\Factory as Faker;
Expand Down Expand Up @@ -38,7 +38,7 @@ abstract class EccubeTestCase extends WebTestCase
protected $container;

/**
* @var EntityManager
* @var EntityManagerInterface
*/
protected $entityManager;

Expand Down
6 changes: 3 additions & 3 deletions tests/Eccube/Tests/Fixture/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Eccube\Tests\Fixture;

use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Eccube\Entity\Customer;
use Eccube\Entity\CustomerAddress;
use Eccube\Entity\Delivery;
Expand Down Expand Up @@ -52,7 +52,7 @@ class Generator
protected $locale;

/**
* @var EntityManager
* @var EntityManagerInterface
*/
protected $entityManager;

Expand Down Expand Up @@ -117,7 +117,7 @@ class Generator
protected $session;

public function __construct(
EntityManager $entityManager,
EntityManagerInterface $entityManager,
PasswordEncoder $passwordEncoder,
MemberRepository $memberRepository,
CategoryRepository $categoryRepository,
Expand Down
8 changes: 1 addition & 7 deletions tests/Eccube/Tests/Service/CartServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

namespace Eccube\Tests\Service;

use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Eccube\Entity\CartItem;
use Eccube\Service\Cart\CartItemComparator;
use Eccube\Service\CartService;
Expand All @@ -46,15 +46,9 @@ class CartServiceTest extends AbstractServiceTestCase

protected $SaleType2;

/**
* @var EntityManager
*/
protected $entityManager;

public function setUp()
{
parent::setUp();
$this->entityManager = $this->container->get('doctrine')->getManager();
$this->SaleType1 = $this->entityManager->find(\Eccube\Entity\Master\SaleType::class, 1);
$this->SaleType2 = $this->entityManager->find(\Eccube\Entity\Master\SaleType::class, 2);
$this->Product = $this->createProduct();
Expand Down
7 changes: 0 additions & 7 deletions tests/Eccube/Tests/Service/CsvExportServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Eccube\Tests\Service;

use Doctrine\ORM\EntityManager;
use Eccube\Service\CsvExportService;
use Eccube\Entity\Master\CsvType;
use Eccube\Repository\CsvRepository;
Expand All @@ -14,11 +13,6 @@ class CsvExportServiceTest extends AbstractServiceTestCase

protected $url;

/**
* @var EntityManager
*/
protected $entityManager;

/**
* @var CsvExportService
*/
Expand All @@ -41,7 +35,6 @@ public function setUp()
$root = vfsStream::setup('rootDir');
$this->url = vfsStream::url('rootDir/test.csv');

$this->entityManager = $this->container->get('doctrine')->getManager();
$this->csvExportService = $this->container->get(CsvExportService::class);
$this->csvRepository = $this->container->get(CsvRepository::class);
$this->orderRepository = $this->container->get(OrderRepository::class);
Expand Down
6 changes: 0 additions & 6 deletions tests/Eccube/Tests/Service/MailServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Eccube\Tests\Service;

use Doctrine\ORM\EntityManager;
use Eccube\Entity\BaseInfo;
use Eccube\Entity\Customer;
use Eccube\Service\MailService;
Expand All @@ -12,11 +11,6 @@
*/
class MailServiceTest extends AbstractServiceTestCase
{
/**
* @var EntityManager
*/
protected $entityManager;

/**
* @var Customer
*/
Expand Down
1 change: 0 additions & 1 deletion tests/Eccube/Tests/Service/TaxRuleServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Eccube\Tests\Service;

use Doctrine\ORM\EntityManager;
use Eccube\Repository\BaseInfoRepository;
use Eccube\Repository\TaxRuleRepository;
use Eccube\Service\TaxRuleService;
Expand Down
24 changes: 8 additions & 16 deletions tests/Eccube/Tests/Util/EntityUtilTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Eccube\Tests\Util;

use Doctrine\ORM\EntityManager;
use Eccube\Entity\AbstractEntity;
use Eccube\Entity\Product;
use Eccube\Entity\ProductClass;
Expand All @@ -21,23 +20,16 @@ class EntityUtilTest extends EccubeTestCase
private $memberId;
private $productClassId;

/**
* @var EntityManager
*/
private $em;

public function setUp()
{
parent::setUp();
$client = self::createClient();
$this->em = $client->getContainer()->get('doctrine')->getManager();
// eccube_install.sh で追加される Member
$Member = $this->em->find(\Eccube\Entity\Member::class, 1);
$Member = $this->entityManager->find(\Eccube\Entity\Member::class, 1);

$Product = new Product();
$ProductClass = new ProductClass();
$ProductStatus = $this->em->find(\Eccube\Entity\Master\ProductStatus::class, \Eccube\Entity\Master\ProductStatus::DISPLAY_HIDE);
$SaleType = $this->em->find(\Eccube\Entity\Master\SaleType::class, 1);
$ProductStatus = $this->entityManager->find(\Eccube\Entity\Master\ProductStatus::class, \Eccube\Entity\Master\ProductStatus::DISPLAY_HIDE);
$SaleType = $this->entityManager->find(\Eccube\Entity\Master\SaleType::class, 1);
$Product
->setName('test')
->setCreator($Member)
Expand All @@ -55,10 +47,10 @@ public function setUp()
$ProductClass->setProductStock($ProductStock);
$ProductStock->setProductClass($ProductClass);

$this->em->persist($Product);
$this->em->persist($ProductClass);
$this->em->persist($ProductStock);
$this->em->flush();
$this->entityManager->persist($Product);
$this->entityManager->persist($ProductClass);
$this->entityManager->persist($ProductStock);
$this->entityManager->flush();

$this->Product = $Product;
$this->ProductClass = $ProductClass;
Expand All @@ -67,7 +59,7 @@ public function setUp()
public function testIsEmptyWithFalse()
{
// setUp() で追加したサンプル商品
$Product = $this->em->find(Product::class, $this->Product->getId());
$Product = $this->entityManager->find(Product::class, $this->Product->getId());
// eccube_install.sh で追加される Member
$Member = $Product->getCreator();
/*
Expand Down

0 comments on commit 6c60ed5

Please sign in to comment.