I have a question,
I am using phpunit WebTestCase in symfony 3.4
but I can't select any data
and I get
1) Tests\BankBundle\Controller\BankControllerTest::testmoneyIn Failed asserting that null matches expected 1.
this is my ControllerTest
<?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
{
static::$kernel = static::createKernel();
static::$kernel->boot();
$this->em = static::$kernel->getContainer()
->get('doctrine')
->getManager();
}
public function testmoneyIn()
{
$client = static::createClient();
$client->request('POST', '/bank/moneyin', array('amount' => 50));
$bank = $this->em
->getRepository('BankBundle:entry')
->getId(1);
$this->assertEquals(1, $bank);
}
/**
* {@inheritDoc}
*/
protected function tearDown(): void
{
parent::tearDown();
$this->em->close();
}
}
$bank = 1. But$bankis null. Your test is failed