dongni9825 2012-02-28 19:16
浏览 135

Yii assertTextPresent无效

Here is my environment Yii 1.1.10, PHPUnit 3.6.0, Selenium Server 2.20.0, PHP 5.2.17

Every time i use command $this->assertTextPresent('Foo'); on my Yii application. PHPUnit seem not responding and didn't give feedback. If i removed that assert, PHPunit is working.

How come?


Example of no Responding.

I Tried to test phpunit with SiteTest.php (default test example from Yii)

here is the content of SIteTest.php

<?php

class SiteTest extends WebTestCase
{
public function testIndex()
{
    $this->open('');
    $this->assertTextPresent('Welcome');
}

public function testContact()
{
    $this->open('?r=site/contact');
    $this->assertTextPresent('Contact Us');
    $this->assertElementPresent('name=ContactForm[name]');

    $this->type('name=ContactForm[name]','tester');
    $this->type('name=ContactForm[email]','tester@example.com');
    $this->type('name=ContactForm[subject]','test subject');
    $this->click("//input[@value='Submit']");
    $this->waitForTextPresent('Body cannot be blank.');
}

public function testLoginLogout()
{
    $this->open('');
    // ensure the user is logged out
    if($this->isTextPresent('Logout'))
        $this->clickAndWait('link=Logout (demo)');

    // test login process, including validation
    $this->clickAndWait('link=Login');
    $this->assertElementPresent('name=LoginForm[username]');
    $this->type('name=LoginForm[username]','demo');
    $this->click("//input[@value='Login']");
    $this->waitForTextPresent('Password cannot be blank.');
    $this->type('name=LoginForm[password]','demo');
    $this->clickAndWait("//input[@value='Login']");
    $this->assertTextNotPresent('Password cannot be blank.');
    $this->assertTextPresent('Logout');

    // test logout process
    $this->assertTextNotPresent('Login');
    $this->clickAndWait('link=Logout (demo)');
    $this->assertTextPresent('Login');
}
}

And this is the result

seems like phpunit not responding anything. and here is the example if i create my own Test unit without assertion or any test so i will get error.

<?php

 Class MessageTest extends CTestCase {

 }

 ?>

and here the result.

  • 写回答

1条回答 默认 最新

  • dongshanfan1941 2014-06-20 03:44
    关注

    There may be a syntax error somewhere else, try adding

    ini_set('error_reporting', E_ALL); // or error_reporting(E_ALL);
    ini_set('display_errors', '1');
    ini_set('display_startup_errors', '1');
    

    to the end of your bootstrap.php

    评论

报告相同问题?

悬赏问题

  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 路易威登官网 里边的参数逆向
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程
  • ¥20 模型在y分布之外的数据上预测能力不好如何解决
  • ¥15 processing提取音乐节奏