PHP 用户登录Symfony 1.4功能测试

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP 用户登录Symfony 1.4功能测试相关的知识,希望对你有一定的参考价值。

// First, place this in your functional bootstrap file
// (optional, but helps keep things organized)

sfConfig::set('FUNC_ADMIN_USER', 'admin');
sfConfig::set('FUNC_ADMIN_PASS', 'admin');

// In the functional test, this line logs in a user using vars from the bootstrap file
// It first logs in a user, then checks that the user has access to the page we are testing

$browser->

  // go to login page
  get('/appointments')->

  // make sure we did not get access
  with('response')->begin()->
    isStatusCode(401)->
  end()->

  // log in
  with('form')->begin()->
    click('sign in', array(
      'signin' => array(
        'username' => sfConfig::get('FUNC_ADMIN_USER'),
        'password' => sfConfig::get('FUNC_ADMIN_PASS'))))->
  end()->
  
  // try again to access the appointment page (should have been block the first time
  get('/appointments')->

  // make sure we have access now
  with('response')->begin()->
    isStatusCode(200)->
  end()
;

以上是关于PHP 用户登录Symfony 1.4功能测试的主要内容,如果未能解决你的问题,请参考以下文章

使用 Symfony 1.4 的自动加载器加载命名空间类?

更新到 php 7 后如何修复 symfony 1.4 错误“Empty response header name, aborting request”

如何使用 Symfony 2 在单元测试中获取当前登录的用户?

Symfony 2 还是 Symfony 1.4? [关闭]

免费办公室转换为pdf在带有IIS 8的symfony 1.4中不起作用

带有 PHP 应用程序和用户会话的 NodeJS