2014-11-22 4 views
0

Я хочу протестировать один из моих классов, но похоже, что Phpunit не работает.

Это испытание ниже:Laravel: тесты PHPUnit не запускаются

<?php 

use NERO\Datagrids\Datagrid; 

class DatagridTest extends TestCase 
{ 

    public function __construct() 
    { 
     $this->datagrid = new Datagrid; 
    } 

    public function testStopMethod() 
    { 
     $response = $this->datagrid->stop(); 
     $this->assertEquals($response, 'Stop'); 
    } 

} 

И сам класс:

<?php 

namespace NERO\Datagrids; 

class Datagrid { 

    public function stop() 
    { 
     return 'Stop'; 
    } 

} 

Я не событие получить любой réponse из командной строки. Я делаю следующее, и ничего не происходит.

intelis:laravel me$ clear 
intelis:laravel me$ vendor/bin/phpunit 
intelis:laravel me$ 

Благодарим за помощь!

ответ

1

Пожалуйста, не используйте __construct, вместо:

<?php 

use NERO\Datagrids\Datagrid; 

class DatagridTest extends TestCase 
{ 
    protected $datagrid; 

    public function setUp() 
    { 
     $this->datagrid = new Datagrid; 
    } 

    public function testStopMethod() 
    { 
     $response = $this->datagrid->stop(); 
     $this->assertEquals($response, 'Stop'); 
    } 

} 
Смежные вопросы