-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathAdapterFactoryTest.php
More file actions
59 lines (46 loc) · 2.18 KB
/
AdapterFactoryTest.php
File metadata and controls
59 lines (46 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
namespace Lexik\Bundle\CurrencyBundle\Tests\Unit\Adapter;
use Lexik\Bundle\CurrencyBundle\Adapter\AdapterFactory;
use Lexik\Bundle\CurrencyBundle\Tests\Unit\BaseUnitTestCase;
class AdapterFactoryTest extends BaseUnitTestCase
{
const CURRENCY_ENTITY = 'Lexik\Bundle\CurrencyBundle\Entity\Currency';
protected $doctrine;
public function setUp()
{
$this->doctrine = $this->getMockDoctrine();
$em = $this->getEntityManager();
$this->createSchema($em);
}
public function testCreateEcbAdapter()
{
$factory = new AdapterFactory($this->doctrine, 'EUR', array('EUR', 'USD'), self::CURRENCY_ENTITY);
$adapter = $factory->createEcbAdapter();
$this->assertInstanceOf('Lexik\Bundle\CurrencyBundle\Adapter\EcbCurrencyAdapter', $adapter);
$this->assertEquals('EUR', $adapter->getDefaultCurrency());
$this->assertEquals(array('EUR', 'USD'), $adapter->getManagedCurrencies());
$this->assertEquals(0, count($adapter));
}
public function testCreateAlphaAdapter()
{
$factory = new AdapterFactory($this->doctrine, 'EUR', array('EUR', 'USD'), self::CURRENCY_ENTITY);
$adapter = $factory->createAlphaAdapter();
$this->assertInstanceOf('Lexik\Bundle\CurrencyBundle\Adapter\AlphaCurrencyAdapter', $adapter);
$this->assertEquals('EUR', $adapter->getDefaultCurrency());
$this->assertEquals(array('EUR', 'USD'), $adapter->getManagedCurrencies());
$this->assertEquals(0, count($adapter));
}
public function testCreateDoctrineAdapter()
{
$em = $this->getEntityManager();
$this->loadFixtures($em);
$factory = new AdapterFactory($this->doctrine, 'USD', array('EUR'), self::CURRENCY_ENTITY);
$adapter = $factory->createDoctrineAdapter();
$this->assertInstanceOf('Lexik\Bundle\CurrencyBundle\Adapter\DoctrineCurrencyAdapter', $adapter);
$this->assertEquals('USD', $adapter->getDefaultCurrency());
$this->assertEquals(array('EUR'), $adapter->getManagedCurrencies());
$this->assertEquals(0, count($adapter));
$adapter['USD']; // force initialization
$this->assertEquals(2, count($adapter));
}
}