Wednesday, 15 July 2015

testing - How do I set method tearDown() in yii with phpunit? -


I wrote a class registration and test for it.

  $ this-> Open ('/'); If ($ this-> isTextPresent ('logout')) $ this- & gt; ClickAndWait ('link = logout'); $ This- & gt; ClickAndWait ('click = reg'); $ This- & gt; AssertElementPresent ('id = reg form of user'); $ This- & gt; Type ('name = user [login]', 'root111'); $ This- & gt; Click ("// input [@ value = 'submit']"); $ This- & gt; IsTextPresent ('can not be empty'.); $ This- & gt; Type ('name = user [pswd]', 'll111'); $ This- & gt; Click ("// input [@ value = 'submit']"); $ This- & gt; IsTextPresent ('can not be empty'.); $ This- & gt; Type ('name = user [email]', '1a1111@gmail.com'); $ This- & gt; Click ("// input [@ value = 'submit']"); $ This- & gt; WaitForTextPresent ('logout'); $ This- & gt; ClickAndWait ('click = logout'); $ This- & gt; WaitForTextPresent ('reg'); $ This- & gt; ClickAndWait ('click = reg');   

To set a new record and set Tyrund () in WebTestCase.php.

  // Delete test user records $ exe = Yii :: app) - & gt; Db- & gt; CreateCommand (); $ Exe- & gt; Delete ('{{User}}', 'id & gt ;: id', array (': id' => 5)); $ Exe- & gt; Executed ();   

Tests are performed according to the requirement, but the record is not removed. Why? How do I fix this bug? I try to use terDownAfterClass (), but the result is the same.

Try another way For example find the model based on properties (you can find them ) And delete it.

  User: Model () - & gt; DeletedAttributeAttributes (array ('email' = & gt; '1a1111@gmail.com ',));    

No comments:

Post a Comment