Answer the question
In order to leave comments, you need to log in
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);
}
}
<?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);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question