Laravel 5.2 PHPUnit LogicException:所选节点没有表单祖先

时间:2016-10-17 09:05:42

标签: laravel phpunit

嗨,我有这个观点。

@extends('layouts.app')
@section('title', 'Register')
@section('content')
<!--BEGIN CONTENT-->
  <div id="content">
    <div class="content">
      <div class="breadcrumbs">
        <a href="#">Home</a>
        <img src="images/marker_2.gif" alt=""/>
        <span>Register</span>
      </div>
      <div class="main_wrapper">
        <div class="sell_box sell_box_5">
          <h2><strong>Customer</strong> details</h2>
          <form name="register" method="post" action="{{ url('/register') }}" enctype="multipart/form-data">
            {{ csrf_field() }}

          <div class="input_wrapper">
            <label><span>* </span><strong>Nama lengkap: </strong></label>
            <input type="text" class="txb" value="" name="full_name"/>
          </div>

          <div class="input_wrapper">
            <label><span>* </span><strong>Alamat lengkap: </strong></label>
            <input type="text" class="txb" value="" name="address"/>
          </div>

          <div class="input_wrapper">
            <label><span>* </span><strong>Telepon: </strong></label>
            <input type="text" class="txb" value="" name="phone"/>
          </div>

          <div class="input_wrapper">
            <label><span>* </span><strong>Upload Identitas (KTP/SIM):</strong></label>
            <input type="file" class="txb" name="idcard"/>
          </div>

          <div class="input_wrapper">
            <label><span>* </span><strong>E-mail: </strong></label>
            <input type="text" class="txb" value="" name="email"/>
          </div>

          <div class="input_wrapper">
            <label><span>* </span><strong>Password:</strong></label>
            <input type="password" class="txb" value="" name="password"/>
          </div>

          <div class="input_wrapper last">
            <label><span>* </span><strong>Password Confirmation:</strong></label>
            <input type="password" class="txb" name="password_confirmation"/>
          </div>

          <div class="input_wrapper">
            <label><span>* </span><strong>Nama saudara tidak serumah: </strong></label>
            <input type="text" class="txb" value="" name="family_name"/>
          </div>

          <div class="input_wrapper">
            <label><span>* </span><strong>Alamat saudara tidak serumah: </strong></label>
            <input type="text" class="txb" value="" name="family_address"/>
          </div>

          <div class="input_wrapper">
            <label><span>* </span><strong>Telepon saudara tidak serumah: </strong></label>
            <input type="text" class="txb" value="" name="family_phone"/>
          </div>

          <div class="clear"></div>
        </div>
        <div class="sell_submit_wrapper">
          <!--
          <span class="custom_chb_wrapper fL">
            <span class="custom_chb">
              <input type="checkbox" name=""/>
            </span>
            <label>I agree to the Terms and Conditions</label>
          </span>
        -->
          <input type="submit" value="Submit" class="sell_submit"/>
          <div class="clear"></div>
        </div>
      </form>
      </div>
    </div>
  </div>
<!--EOF CONTENT-->
@endsection

以下测试方法,成功通过单元测试

public function testNewUserRegistration(){
$this->visit('/register')->see('Submit');
}

但是使用以下方法,我收到以下错误1) RegistrationTest::testNewUserRegistration LogicException: The selected node does not have a form ancestor.

public function testNewUserRegistration(){
$this->visit('/register')->press('Submit');
}

为什么这个测试失败了?它可以看到提交但不能按提交。

我读了一些文章,表明HTML有问题,但我不知道哪一个是错的,因为我觉得我的HTML代码没有错。

任何帮助表示感谢。

0 个答案:

没有答案