0

drupalの7モジュールでいくつかのテストを行いたいです。だから私はdrupalのSimpleTestApiに従い、いくつかのテストを実装しました

たとえば、ログインプロセスをテストしています。

   public function  testLogin() {
    $user = $this->drupalCreateUser(array());
    $this->drupalLogin($user);
   }

ログインしようとすると、常に次の例外が発生します。

Undefined property: MyModuleTest::$public_files_directory drupal_web_test_case.php  1692 DrupalWebTestCase->curlInitialize()

その後、例外ログインは失敗します。

詳細なメッセージは次のとおりです。

User created with name zPUkpgzN and pass 6NXRDGWy5k Pass
GET http://www.example.com/user returned 200 (1 byte). Pass
Valid HTML found on "http://www.example.com/user" Pass
Failed to set field name to zPUkpgzN Pass
Failed to set field pass to 6NXRDGWy5k Fail
Found the Log in button Fail
Found the requested form fields at user Fail
User zPUkpgzN successfully logged in.   Fail

私はこの投稿http://drupal.org/node/1789942を見つけました、そして私はいくつかの提案に従いました、しかし私が成功した唯一のことはこれでした:

User created with name zPUkpgzN and pass 6NXRDGWy5k Pass
GET http://www.example.com/user returned 200 (1 byte). Pass
Valid HTML found on "http://www.example.com/user" Pass
Failed to set field name to zPUkpgzN Pass
Failed to set field pass to 6NXRDGWy5k Pass
Found the Log in button Fail
Found the requested form fields at user Pass
User zPUkpgzN successfully logged in.   Fail

助言がありますか?

ありがとう。

タンデム。

4

2 に答える 2

0

少し前に修正しました。例外は残りますが、テストは成功しました。

I followed this approach:

  public function  testLogin() {
    $user = $this->drupalCreateUser(array());
    $user->roles[] = 'authenticated user'; //Defining user role
    user_save( $user ); //Save user in testing database

    $this->drupalLogin($user);//success!!!!
  }
于 2013-01-04T08:57:37.333 に答える