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/