Micro-PHP /
plugin-doctrine
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | /* |
||
| 6 | * This file is part of the Micro framework package. |
||
| 7 | * |
||
| 8 | * (c) Stanislau Komar <[email protected]> |
||
| 9 | * |
||
| 10 | * For the full copyright and license information, please view the LICENSE |
||
| 11 | * file that was distributed with this source code. |
||
| 12 | */ |
||
| 13 | |||
| 14 | namespace Micro\Plugin\Doctrine\Test\Unit; |
||
| 15 | |||
| 16 | use Micro\Framework\Kernel\Configuration\ApplicationConfigurationInterface; |
||
| 17 | use Micro\Plugin\Doctrine\Configuration\EntityManagerConfigurationInterface; |
||
| 18 | use Micro\Plugin\Doctrine\DoctrinePluginConfiguration; |
||
| 19 | use Micro\Plugin\Doctrine\DoctrinePluginConfigurationInterface; |
||
| 20 | use PHPUnit\Framework\TestCase; |
||
| 21 | |||
| 22 | class DoctrinePluginConfigurationTest extends TestCase |
||
| 23 | { |
||
| 24 | private DoctrinePluginConfigurationInterface $pluginConfiguration; |
||
| 25 | |||
| 26 | private ApplicationConfigurationInterface $applicationConfiguration; |
||
| 27 | |||
| 28 | protected function setUp(): void |
||
| 29 | { |
||
| 30 | $this->applicationConfiguration = $this->createMock(ApplicationConfigurationInterface::class); |
||
| 31 | |||
| 32 | $this->pluginConfiguration = new DoctrinePluginConfiguration($this->applicationConfiguration); |
||
| 33 | } |
||
| 34 | |||
| 35 | public function testGetManagerConfiguration() |
||
| 36 | { |
||
| 37 | $this->applicationConfiguration |
||
| 38 | ->expects($this->once()) |
||
|
0 ignored issues
–
show
|
|||
| 39 | ->method('get') |
||
| 40 | ->with('ORM_TEST_DRIVER') |
||
| 41 | ->willReturn('pdo_mysql') |
||
| 42 | ; |
||
| 43 | |||
| 44 | $emCfg = $this->pluginConfiguration->getManagerConfiguration('test'); |
||
| 45 | $this->assertInstanceOf(EntityManagerConfigurationInterface::class, $emCfg); |
||
| 46 | $this->assertEquals('pdo_mysql', $emCfg->getDriverName()); |
||
| 47 | } |
||
| 48 | |||
| 49 | /** |
||
| 50 | * @dataProvider dataProviderIsDevMode |
||
| 51 | */ |
||
| 52 | public function testIsDevMode(bool $isDev) |
||
| 53 | { |
||
| 54 | $this->applicationConfiguration |
||
| 55 | ->expects($this->once()) |
||
| 56 | ->method('get') |
||
| 57 | ->with('APP_ENV') |
||
| 58 | ->willReturn($isDev ? 'dev-test' : 'prod'); |
||
| 59 | |||
| 60 | $this->assertEquals($isDev, $this->pluginConfiguration->isDevMode()); |
||
| 61 | } |
||
| 62 | |||
| 63 | public function dataProviderIsDevMode() |
||
| 64 | { |
||
| 65 | return [ |
||
| 66 | [true], |
||
| 67 | [false], |
||
| 68 | ]; |
||
| 69 | } |
||
| 70 | |||
| 71 | public function testGetConnectionList() |
||
| 72 | { |
||
| 73 | $listString = 'default, test'; |
||
| 74 | $list = ['default', 'test']; // Because with space after comma. |
||
| 75 | $this->applicationConfiguration |
||
| 76 | ->expects($this->once()) |
||
| 77 | ->method('get') |
||
| 78 | ->with('ORM_CONNECTION_LIST') |
||
| 79 | ->willReturn($listString); |
||
| 80 | |||
| 81 | $this->assertEquals($list, $this->pluginConfiguration->getConnectionList()); |
||
| 82 | } |
||
| 83 | } |
||
| 84 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.