【发布时间】:2021-06-16 11:10:19
【问题描述】:
https://github.com/liip/LiipTestFixturesBundle/tree/2.x 包存在问题(请注意,我是该包的维护者之一,问题不在于在项目中使用该包)
Tests were broken 在主 2.x 分支上出现以下错误:
Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException:服务“nelmio_alice.property_accessor.std”依赖于不存在的服务“property_accessor”。您的意思是:“nelmio_alice.property_accessor.std”?
这是在vendor/nelmio/alice/src/Bridge/Symfony/Resources/config/property_access.xml 中声明该服务的方式:
<service id="nelmio_alice.property_accessor.std"
class="Nelmio\Alice\PropertyAccess\StdPropertyAccessor">
<argument type="service" id="property_accessor" />
</service>
应该调用此代码,因为NelmioAliceBundle 加载到AppKernel 中。
所以我们将added 这个composer.json 禁止symfony/property-access 5.3 并修复了错误:
"symfony/property-access": "^4.4 || ^5.0 , <5.3",
但是,如果我们删除该解决方法,它会再次中断。而且我不明白是什么导致了这个问题。
禁止symfony/framework-bundle 5.3 也解决了这个问题:https://github.com/liip/LiipTestFixturesBundle/pull/127/commits/a534419e61ef90ca2685d697b89b2ce225712cdc
当我们使用symfony/framework-bundle 5.3 或symfony/property-access 5.3 时,是什么导致property_accessor 缺失?
如何重现错误
git clone git@github.com:liip/LiipTestFixturesBundle.git
cd LiipTestFixturesBundle
git checkout remove-required-symfony/property-access
composer install
vendor/bin/phpunit --testdox tests/Test/ConfigEventsTest.php
【问题讨论】:
-
对于它的价值,我可以在 Sf 5.3 上依赖
PropertyAccessorInterface罚款。 -
另外,按照问题中的步骤,测试通过了。 cln.sh/J7kQJ6
-
@yivi 我更新了问题,谢谢。我从那个分支打开了一个 PR,测试被破坏了:github.com/liip/LiipTestFixturesBundle/pull/130
-
再次,我按照信中的说明进行操作,我没有收到任何错误。
-
您在更新到 5.3 的方式上存在问题。有了新的 5.3(没有额外的捆绑包),property_accessor 服务就可以使用了。
标签: symfony symfony5 nelmio-alice liiptestfixturesbundle