0

I have a 2 files in my controller and here is the folder list

-controller (folder)
 - AbstractTestCase.php
 - PatientControllerTest.php

In my AbstractWebtestCase.php

namespace AdminBundle\Tests\Controller;

use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

abstract class AbstractTestCase extends WebTestCase{}

In my PatientControllerTest.php

use AdminBundle\Tests\Controller\AbstractTestCase;

class PatientControllerTest extends AbstractTestCase {}

I inherit the AbstractTestCase in SpecializationControllerTest when the time I run phpunit I get this error

PHP Fatal error:  Class 'AdminBundle\Tests\Controller\AbstractTestCase' not found in /Users/helloworld/Projects/sample/src/AdminBundle/Tests/Contoller/PatientControllerTest.php on line 11

Why is it I can't inherit it? but when I separate it to other it works.

5
  • The autoloader will be looking for AbstractTestCase.php but your file is named AbstractWebtestCase.php Commented Nov 23, 2017 at 3:03
  • Also, assuming PatientControllerTest is in the same namespace as AbstractTestCase, you don't need a use statement to import the symbol Commented Nov 23, 2017 at 3:05
  • @Phil still the same output when I rename AbstractTestCase. even I did add use statement Commented Nov 23, 2017 at 4:25
  • Have you tried composer dump-autoload -o Commented Nov 23, 2017 at 4:30
  • Have you configured an auto-loader? You typically include the composer autoload.php in your PHPUnit bootstrap file Commented Nov 23, 2017 at 4:31

1 Answer 1

1

in you error message there is '.../Tests/Contoller/PatientControllerTest.php', 'Contoller' is missing a 'r'. Is the namespace of this file ok ?

Please be more precise too, ex is your folder 'controller' or maybe 'Controller' and post the whole code instead of parts.

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.