B
B
BogMW2015-12-14 14:15:21
PHPUnit
BogMW, 2015-12-14 14:15:21

Phpunit throws an error when dealing with external classes?

Installed PHPStorm and phpunit.
When you run any primitive test, where there is no access to another file, everything is fine, the test passes:

class firstTest extends PHPUnit_Framework_TestCase
{
    public function testFirst(){
        $this->assertTrue(1 === 1);
    }
}

, but when I also run a simple test, but which tests another class, for example, a calculator
<?php
class Calculator
{

    public function add($a, $b)
    {
        return $a + $b;
    }

}

<?php
require '../Calculator.php';

class CalculatorTests extends PHPUnit_Framework_TestCase
{
    private $calculator;

    protected function setUp()
    {
        $this->calculator = new Calculator();
    }

    protected function tearDown()
    {
        $this->calculator = NULL;
    }

    public function testAdd()
    {
        $result = $this->calculator->add(1, 2);
        $this->assertEquals(3, $result);
    }

}

gives an error Process finished with exit code 255.
As I understand it, for some reason it does not pull up external classes, why?
Help a newbie, thanks in advance.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question