小编sti*_*ink的帖子

Symfony2中的Flash消息似乎不适用于我的twig-template

我想在我们的页面上添加对flash消息的支持.我按照此处的文档实现了这一点.

我将以下snipplet添加到我的基本布局中.(我也尝试将其添加到特定的操作模板中).

{% if app.session.hasFlash('notice') %} 
    <div id="flashmessage" class="flash-notice"> 
       {{ app.session.flash('notice') }} 
   </div> 
{% endif %} 
Run Code Online (Sandbox Code Playgroud)

添加以下错误后抛出

Twig_Error_Runtime:第66行"MyBundle :: layout.html.twig"中不存在""的"hasFlash"项

还有什么我需要做的吗?

templates symfony twig flash-message

10
推荐指数
3
解决办法
3万
查看次数

如何有效地拆分大型 phpunit 测试套件?

我使用 phpunit 的 testsuites 功能来组织我的测试。我这样做是为了以后能够并行运行测试。

对于不同的目录,这相对简单。因此,例如,我可以通过捆绑来拆分测试套件。

<testsuite name="bundle-one">
    <directory>tests/BundleOne</directory>
</testsuite>

<testsuite name="bundle-two">
    <directory>tests/BundleTwo</directory>
</testsuite>

<testsuite name="bundle-three">
    <directory>tests/BundleThree</directory>
</testsuite>
Run Code Online (Sandbox Code Playgroud)

但是现在我有一个包含数十个子文件夹的目录(服务)。我可以手动为这个文件夹制作几个测试套件。但在我看来,这将是一个薄弱的解决方案。因为如果我提到测试套件中的每个子文件夹并且文件夹被重命名或删除,测试套件可能很容易损坏。

我的想法是使用某种正则表达式来选择一系列子文件夹以包含在一个测试套件中,并为另一个测试套件选择另一范围的文件夹。

<testsuite name="services-AM">
    <directory>tests/services/{A-M}</directory>
</testsuite>

<testsuite name="services-NZ">
    <directory>tests/services/{A-M}</directory>
</testsuite>
Run Code Online (Sandbox Code Playgroud)

我找不到任何关于我的想法的文档。有人可能对此有想法吗?:-)

phpunit test-suite

3
推荐指数
1
解决办法
937
查看次数

标签 统计

flash-message ×1

phpunit ×1

symfony ×1

templates ×1

test-suite ×1

twig ×1