/ / ईमेल का कार्यात्मक परीक्षण विफल हो जाता है यदि परीक्षण कार्रवाई पुनर्निर्देशित होती है - php, सिम्फनी, कार्यात्मक-परीक्षण, स्विफ्टमेलर

ईमेल की कार्यात्मक परीक्षा विफल हो जाती है यदि परीक्षण कार्रवाई पुनर्निर्देशित होती है - php, सिम्फनी, कार्यात्मक-परीक्षण, स्विफ्टमेलर

नियंत्रक क्रिया के कारण ई-मेल भेजा जाता हैऔर फिर पुनर्निर्देश करता है। रीडायरेक्ट के कारण इस क्रिया का कार्यात्मक परीक्षण विफल हो जाता है। यदि टेम्प्लेट पास होने वाले टेम्प्लेट को रेंडर करने के लिए नियंत्रक को फिर से लिखा जाता है [यह आम तौर पर सच प्रतीत होता है; स्थिति को [सिम्फनी के प्रलेखन] [1]] में कोड का उपयोग करके दोहराया जा सकता है।

संपादित करें: परीक्षण विफलता

"" usr / bin / php "" / usr / bin / phpunit "" --colors ""--Log-JUnit" "-tmp/nb-phpunit-log.xml" "- bootstrap" "-होम / जॉर्ज / वॉलंटियर / ऐप / बॉटस्ट्रैप। एफपीसी.चे" " "-होम / ग्राम / स्वयंसेवक / टैप / एफ्यूपनीट। xml.dist" "% BtestActivateOrganizationb%" "/Home/george/netbeans-8.0.1/php/phpunit/NetBeansSuite.php" "--Run = / घर / जॉर्ज / स्वयंसेवक / src / Truckee / MatchingBundle / टेस्ट / नियंत्रक / AdminControllerTest.php" सेबस्टियन बर्गमैन द्वारा PHPUnit 3.7.28।

कॉन्फ़िगरेशन को /home/george/volunteer/app/phpunit.xml.dist से पढ़ा जाता है

एफ

समय: 1.36 सेकंड, मेमोरी: 40.75Mb

1 विफलता थी:

1) TruckeeMatchingBundleTestsControllerAdminControllerTest :: testActivateOrganization यह अनुमान लगाने में विफल रहा कि 0 मैचों की उम्मीद थी

/home/george/volunteer/src/Truckee/MatchingBundle/Tests/Controller/AdminControllerTest.php:64

विफलताएं! टेस्ट: 1, दावे: 1, विफलताएं: 1।

किया हुआ।

नियंत्रक

public function activateOrgAction($id)
{
$em = $this->getDoctrine()->getManager();
$organization = $em->getRepository("TruckeeMatchingBundle:Organization")->find($id);
$temp = $organization->getTemp();
if (true === $temp) {
$organization->setTemp(false);
$organization->setActive(true);
$orgName = $organization->getOrgName();
$em->persist($organization);
$em->flush();
$to = $em->getRepository("TruckeeMatchingBundle:Staff")->getActivePersons($id);
$mailer = $this->container->get("admin.mailer");
$mailer->activateOrgMail($organization, $to);
$flash = $this->get("braincrafted_bootstrap.flash");
$flash->success("$orgName has been activated");
}

return $this->redirect($this->generateUrl("admin_home"));
}

संपादित 3: अधिक पूर्ण परीक्षण स्थिरता

class AdminControllerTest extends WebTestCase
{

private $client;

public function setUp()
{
$classes = array(
"TruckeeMatchingBundleDataFixturesSampleDataLoadFocusSkillData",
"TruckeeMatchingBundleDataFixturesSampleDataLoadAdminUser",
"TruckeeMatchingBundleDataFixturesSampleDataLoadStaffUserGlenshire",
"TruckeeMatchingBundleDataFixturesSampleDataLoadStaffUserMelanzane",
"TruckeeMatchingBundleDataFixturesSampleDataLoadTemplateData",
"TruckeeMatchingBundleDataFixturesSampleDataLoadOpportunity",
"TruckeeMatchingBundleDataFixturesSampleDataLoadVolunteer",
);
$this->loadFixtures($classes);
$this->client = $this->createClient();
$this->client->followRedirects();
}

public function login($user)
{
$crawler = $this->client->request("GET", "/login");
$form = $crawler->selectButton("Login")->form();
$form["_username"] = $user;
$form["_password"] = "123Abcd";
$crawler = $this->client->submit($form);

return $crawler;
}
public function testActivateOrganization()
{
$crawler = $this->login("admin");
$link = $crawler->selectLink("Accept organization")->link();
$crawler = $this->client->click($link);

$mailCollector = $this->client->getProfile()->getCollector("swiftmailer");
$this->assertEquals(1, $mailCollector->getMessageCount());
}
...
}

उत्तर:

उत्तर № 1 के लिए 1

इसे अपनी इकाई परीक्षा में जोड़ें:

 $this->client->followRedirects(false);

देखें टेस्टिंग पर सिम्फनी डॉक्स। पुनर्निर्देशन का स्वचालित रूप से पालन नहीं किया जाता है, लेकिन आप उन्हें ऐसा करने के लिए सेट कर रहे हैं। यदि आप ईमेल का परीक्षण करने के बाद अगले रीडायरेक्ट का पालन करना चाहते हैं, तो आप कॉल कर सकते हैं

$crawler = $client->followRedirect();

यदि आप सभी रीडायरेक्ट का पालन करने के लिए वापस बदलना चाहते हैं, तो कॉल करें:

$client->followRedirects();