13.扩展

这里写图片描述


1.自定义配置
这里写图片描述
这里写图片描述
这里写图片描述

如果希望配置在什么情况下都生效,就配置在config.yml.
如果在config.yml中有,而config_dev.yml导入configy.yml后,
再配置会覆盖

这里写图片描述
这里写图片描述


2.关于 Service
这里写图片描述
这里写图片描述
这里写图片描述


3.编写测试用例
这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述
https://symfony.com/doc/current/testing.html

这里写图片描述
这里写图片描述

<?php

namespace Www\WebBundle\Tests\Service;

use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

class PrintATest extends WebTestCase
{
    private $printA;

    //用 service 调用
    public function setUp()
    {
        static::$kernel = static::createKernel();
        static::$kernel->boot();
        $this->printA = static::$kernel->getContainer()->get('www_web.printa');
    }

    public function testPrintA()
    {
        //$printA = new PrintA();
        $this->assertEquals(1,$this->printA->printA());
    }
}

function test:

<?php

namespace Www\WebBundle\Tests\Controller;

use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

class DefaultControllerTest extends WebTestCase
{
    public function testIndex()
    {
        $client = static::createClient();//创建一个客户端,模拟浏览器

        $crawler = $client->request('GET', '/hello/Fabien'); //发送请求

        $this->assertTrue($crawler->filter('html:contains("Hello Fabien")')->count() > 0);//如果含有 Hello Fabien ,这是正确的即页面可以打开
    }
}

4.第三方 Bundle
https://packagist.org/

http://knpbundles.com/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值