0

I want to test one of my classes, but it looks like the Phpunit is not working.

This is the test below:

<?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');
    }

}

And the class itself:

<?php

namespace NERO\Datagrids;

class Datagrid {

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

}

I don't event get any reponse from the command line. I do the following and nothing happens..

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

Thanks for your help!

1 Answer 1

1

Please not use __construct, instead:

<?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');
    }

}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.