मैं निम्नलिखित त्रुटि प्राप्त हो रही:symfony2 क्रॉलर से फ़ॉर्म का चयन करने का प्रयास करने में त्रुटि?
There was 1 error:
1) Caremonk\MainSiteBundle\Tests\Controller\SecurityControllerFunctionalTest::testIndex
InvalidArgumentException: The current node list is empty.
लेकिन जब मैं स्थानीय होस्ट/लॉगिन करने के लिए नेविगेट, मेरे प्रपत्र सही सामग्री के साथ भरता है। लाइन जो कहती है ...
$form = $crawler->selectButton('login')->form();
त्रुटि उत्पन्न कर रहा है। मेरे परीक्षण में क्या गलत है?
कार्यात्मक परीक्षण:
<?php
namespace Caremonk\MainSiteBundle\Tests\Controller;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class SecurityControllerFunctionalTest extends WebTestCase
{
public function testIndex()
{
$client = static::createClient();
$crawler = $client->request('GET', '/login');
$form = $crawler->selectButton('login')->form();
$form['username'] = 'testActive';
$form['password'] = 'passwordActive';
}
}
टहनी दृश्य:
{# src/Acme/SecurityBundle/Resources/views/Security/login.html.twig #}
{% if error %}
<div>{{ error.message }}</div>
{% endif %}
<form action="{{ path('caremonk_mainsite_login_check') }}" method="post">
<label for="username">Username:</label>
<input type="text" id="username" name="_username" value="{{ last_username }}" />
<label for="password">Password:</label>
<input type="password" id="password" name="_password" />
{#
If you want to control the URL the user is redirected to on success (more details below)
<input type="hidden" name="_target_path" value="/account" />
#}
<button type="submit">login</button>
</form>
मापदंडों भी अंडरस्कोर prepended, उदा की आवश्यकता होती है प्रस्तुत '' _username''' – Tjorriemorrie