我正在运行phpunit测试,但是无法使用getRepository从数据库中获取$ amount。
我不知道如何解决。
我明白了
1)Tests \ BankBundle \ Controller \ BankControllerTest :: testMoneyIn 无法断言null匹配预期的50
<?php
namespace Tests\BankBundle\Controller;
use BankBundle\Entity\entry;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class BankControllerTest extends WebTestCase
{
/**
* @var \Doctrine\ORM\EntityManager
*/
private $em;
/**
* {@inheritDoc}
*/
public function setUp(): void
{
self::bootKernel();
$this->em = static::$kernel->getContainer()
->get('doctrine')
->getManager();
}
public function testMoneyIn()
{
$client = static::createClient();
$client->request('POST', '/bank/moneyin', array('amount' => 50));
$query = $this->em
->getRepository('BankBundle:entry')
->getAmount();
$this->assertEquals(50, $query);
}