Tests for nullable User#getName().
This commit is contained in:
parent
45c3a0d9c9
commit
aebc31a0fe
|
@ -19,7 +19,7 @@ class LoadUserData extends AbstractFixture implements OrderedFixtureInterface
|
|||
// 99996
|
||||
['login' => 'testuser4', 'name' => 'Test User 4'],
|
||||
//99995
|
||||
['login' => 'testuser5', 'name' => 'Test User 5'],
|
||||
['login' => 'testuser5', 'name' => null],
|
||||
];
|
||||
|
||||
public function load(ObjectManager $om)
|
||||
|
|
|
@ -32,7 +32,7 @@ class User
|
|||
private $login;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @var string|null
|
||||
*
|
||||
* @ORM\Column(name="name", type="string", length=255, nullable=true)
|
||||
*/
|
||||
|
@ -135,6 +135,9 @@ class User
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
|
|
|
@ -81,6 +81,7 @@ class MainControllerTest extends WebTestCase
|
|||
public function testAjaxUserAutoComplete()
|
||||
{
|
||||
$client = static::createClient();
|
||||
// We need to search all test user with 'testuser5' included which will test the code against null-string problem in User#getName()
|
||||
$client->request('GET', '/ajax/users/search/testuser');
|
||||
|
||||
$this->assertTrue($client->getResponse()->headers->contains('Content-Type', 'application/json'), 'Response has "Content-Type" = "application/json"');
|
||||
|
@ -99,7 +100,7 @@ class MainControllerTest extends WebTestCase
|
|||
|
||||
$this->assertNotNull($data, 'JSON data successfully decoded and not empty');
|
||||
$this->assertTrue(is_array($data), 'JSON data is array');
|
||||
$this->assertGreaterThan(0, count($data), 'Array has at least one element');
|
||||
$this->assertCount(5, $data, 'Array has 5 elements');
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue