Skip to content

Commit 183b417

Browse files
committed
Fix DI extension tests and apply code style fixes
Tests for discovery locations did not account for the default plugin location being appended via `beforeNormalization`. Also fix trailing commas and remove unused imports flagged by ECS.
1 parent 709bdaf commit 183b417

File tree

3 files changed

+50
-34
lines changed

3 files changed

+50
-34
lines changed

tests/Unit/DependencyInjection/SyliusMcpServerConfigurationTest.php

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function it_has_default_server_name(): void
2727
$this->assertProcessedConfigurationEquals(
2828
[],
2929
['server' => ['name' => 'Sylius MCP Server']],
30-
'server.name'
30+
'server.name',
3131
);
3232
}
3333

@@ -37,7 +37,7 @@ public function it_allows_to_define_server_name(): void
3737
$this->assertProcessedConfigurationEquals(
3838
[['server' => ['name' => 'Custom MCP Server']]],
3939
['server' => ['name' => 'Custom MCP Server']],
40-
'server.name'
40+
'server.name',
4141
);
4242
}
4343

@@ -47,7 +47,7 @@ public function it_has_default_server_version(): void
4747
$this->assertProcessedConfigurationEquals(
4848
[],
4949
['server' => ['version' => '0.1.0']],
50-
'server.version'
50+
'server.version',
5151
);
5252
}
5353

@@ -57,7 +57,7 @@ public function it_allows_to_define_server_version(): void
5757
$this->assertProcessedConfigurationEquals(
5858
[['server' => ['version' => '1.0.0']]],
5959
['server' => ['version' => '1.0.0']],
60-
'server.version'
60+
'server.version',
6161
);
6262
}
6363

@@ -77,10 +77,10 @@ public function it_has_default_transport_configuration(): void
7777
'enabled' => false,
7878
'context' => [],
7979
],
80-
]
81-
]
80+
],
81+
],
8282
],
83-
'server.transport'
83+
'server.transport',
8484
);
8585
}
8686

@@ -99,8 +99,8 @@ public function it_allows_to_define_transport_configuration(): void
9999
'enabled' => true,
100100
'context' => ['verify_peer' => false],
101101
],
102-
]
103-
]
102+
],
103+
],
104104
]],
105105
[
106106
'server' => [
@@ -113,8 +113,8 @@ public function it_allows_to_define_transport_configuration(): void
113113
'enabled' => true,
114114
'context' => ['verify_peer' => false],
115115
],
116-
]
117-
]
116+
],
117+
],
118118
],
119119
'server.transport',
120120
);
@@ -130,10 +130,10 @@ public function it_has_default_session_configuration(): void
130130
'session' => [
131131
'driver' => 'cache',
132132
'ttl' => 3600,
133-
]
134-
]
133+
],
134+
],
135135
],
136-
'server.session'
136+
'server.session',
137137
);
138138
}
139139

@@ -146,16 +146,16 @@ public function it_allows_to_define_session_configuration(): void
146146
'session' => [
147147
'driver' => 'array',
148148
'ttl' => 7200,
149-
]
150-
]
149+
],
150+
],
151151
]],
152152
[
153153
'server' => [
154154
'session' => [
155155
'driver' => 'array',
156156
'ttl' => 7200,
157-
]
158-
]
157+
],
158+
],
159159
],
160160
'server.session',
161161
);
@@ -175,10 +175,10 @@ public function it_has_default_discovery_locations(): void
175175
'scan_dirs' => ['src/Tool'],
176176
],
177177
],
178-
]
179-
]
178+
],
179+
],
180180
],
181-
'server.discovery.locations'
181+
'server.discovery.locations',
182182
);
183183
}
184184

@@ -195,8 +195,8 @@ public function it_allows_to_define_discovery_locations(): void
195195
'scan_dirs' => ['src/Tool', 'src/Resource'],
196196
],
197197
],
198-
]
199-
]
198+
],
199+
],
200200
]],
201201
[
202202
'server' => [
@@ -206,9 +206,13 @@ public function it_allows_to_define_discovery_locations(): void
206206
'base_path' => 'test/path',
207207
'scan_dirs' => ['src/Tool', 'src/Resource'],
208208
],
209+
[
210+
'base_path' => '%sylius_mcp_server.plugin_root%',
211+
'scan_dirs' => ['src/Tool'],
212+
],
209213
],
210-
]
211-
]
214+
],
215+
],
212216
],
213217
'server.discovery.locations',
214218
);

tests/Unit/DependencyInjection/SyliusMcpServerExtensionTest.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,8 @@
1313

1414
namespace Tests\Sylius\McpServerPlugin\Unit\DependencyInjection;
1515

16-
use Doctrine\Bundle\MigrationsBundle\DependencyInjection\DoctrineMigrationsExtension;
1716
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractExtensionTestCase;
1817
use Sylius\McpServerPlugin\DependencyInjection\SyliusMcpServerExtension;
19-
use SyliusLabs\DoctrineMigrationsExtraBundle\DependencyInjection\SyliusLabsDoctrineMigrationsExtraExtension;
20-
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
2118

2219
final class SyliusMcpServerExtensionTest extends AbstractExtensionTestCase
2320
{
@@ -28,7 +25,7 @@ public function it_loads_plugin_root_parameter(): void
2825

2926
$this->assertContainerBuilderHasParameter(
3027
'sylius_mcp_server.plugin_root',
31-
dirname(__DIR__, 3)
28+
dirname(__DIR__, 3),
3229
);
3330
}
3431

@@ -43,7 +40,7 @@ public function it_loads_server_name_parameter(): void
4340

4441
$this->assertContainerBuilderHasParameter(
4542
'sylius_mcp_server.server.name',
46-
'Test MCP Server'
43+
'Test MCP Server',
4744
);
4845
}
4946

@@ -58,7 +55,7 @@ public function it_loads_server_version_parameter(): void
5855

5956
$this->assertContainerBuilderHasParameter(
6057
'sylius_mcp_server.server.version',
61-
'1.0.0'
58+
'1.0.0',
6259
);
6360
}
6461

@@ -151,7 +148,11 @@ public function it_loads_server_discovery_locations(): void
151148
'base_path' => 'test/path',
152149
'scan_dirs' => ['src/Tool', 'src/Resource'],
153150
],
154-
]
151+
[
152+
'base_path' => '%sylius_mcp_server.plugin_root%',
153+
'scan_dirs' => ['src/Tool'],
154+
],
155+
],
155156
);
156157
}
157158

tests/bootstrap.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
11
<?php
22

3+
/*
4+
* This file is part of the Sylius package.
5+
*
6+
* (c) Sylius Sp. z o.o.
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
declare(strict_types=1);
13+
314
use Symfony\Component\Dotenv\Dotenv;
415

5-
require dirname(__DIR__).'/vendor/autoload.php';
16+
require dirname(__DIR__) . '/vendor/autoload.php';
617

718
if (method_exists(Dotenv::class, 'bootEnv')) {
8-
(new Dotenv())->bootEnv(dirname(__DIR__).'/.env');
19+
(new Dotenv())->bootEnv(dirname(__DIR__) . '/.env');
920
}
1021

1122
if ($_SERVER['APP_DEBUG']) {

0 commit comments

Comments
 (0)