0

Please help me on this

Configuration read from /usr/share/nginx/www/laravel-cribb/phpunit.xml

PHP Fatal error:  Class User contains 3 abstract methods and must therefore be declared abstract or implement the remaining methods (Illuminate\Auth\UserInterface::getRememberToken, Illuminate\Auth\UserInterface::setRememberToken, Illuminate\Auth\UserInterface::getRememberTokenName) in /usr/share/nginx/www/laravel-cribb/app/models/User.php on line 93
PHP Stack trace:
PHP   1. {main}() /usr/bin/phpunit:0
PHP   2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:583
PHP   3. PHPUnit_TextUI_Command->run() phar:///usr/bin/phpunit/phpunit/TextUI/Command.php:132
PHP   4. PHPUnit_TextUI_TestRunner->doRun() phar:///usr/bin/phpunit/phpunit/TextUI/Command.php:179
PHP   5. PHPUnit_Framework_TestSuite->run() /usr/share/nginx/www/laravel-cribb/vendor/phpunit/phpunit/PHPUnit/TextUI/TestRunner.php:349
PHP   6. PHPUnit_Framework_TestSuite->run() /usr/share/nginx/www/laravel-cribb/vendor/phpunit/phpunit/PHPUnit/Framework/TestSuite.php:705
PHP   7. PHPUnit_Framework_TestSuite->runTest() /usr/share/nginx/www/laravel-cribb/vendor/phpunit/phpunit/PHPUnit/Framework/TestSuite.php:745
PHP   8. PHPUnit_Framework_TestCase->run() /usr/share/nginx/www/laravel-cribb/vendor/phpunit/phpunit/PHPUnit/Framework/TestSuite.php:775
PHP   9. PHPUnit_Framework_TestResult->run() /usr/share/nginx/www/laravel-cribb/vendor/phpunit/phpunit/PHPUnit/Framework/TestCase.php:783
PHP  10. PHPUnit_Framework_TestCase->runBare() /usr/share/nginx/www/laravel-cribb/vendor/phpunit/phpunit/PHPUnit/Framework/TestResult.php:648
PHP  11. UserRepositoryTest->setUp() /usr/share/nginx/www/laravel-cribb/vendor/phpunit/phpunit/PHPUnit/Framework/TestCase.php:835
PHP  12. Illuminate\Support\Facades\App::make() /usr/share/nginx/www/laravel-cribb/app/tests/unit/Repositories/UserRepositoryTest.php:12
PHP  13. Illuminate\Support\Facades\Facade::__callStatic() /usr/share/nginx/www/laravel-cribb/app/tests/unit/Repositories/UserRepositoryTest.php:12
PHP  14. Illuminate\Foundation\Application->make() /usr/share/nginx/www/laravel-cribb/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:208
PHP  15. Illuminate\Container\Container->make() /usr/share/nginx/www/laravel-cribb/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:463
PHP  16. Illuminate\Container\Container->build() /usr/share/nginx/www/laravel-cribb/vendor/laravel/framework/src/Illuminate/Container/Container.php:425
PHP  17. Cribbb\Repositories\RepositoryServiceProvider->Cribbb\Repositories\{closure}() /usr/share/nginx/www/laravel-cribb/vendor/laravel/framework/src/Illuminate/Container/Container.php:482
PHP  18. spl_autoload_call() /usr/share/nginx/www/laravel-cribb/vendor/laravel/framework/src/Illuminate/Container/Container.php:32
PHP  19. Composer\Autoload\ClassLoader->loadClass() /usr/share/nginx/www/laravel-cribb/vendor/laravel/framework/src/Illuminate/Container/Container.php:0
PHP  20. Composer\Autoload\includeFile() /usr/share/nginx/www/laravel-cribb/vendor/composer/ClassLoader.php:269
PHP  21. include() /usr/share/nginx/www/laravel-cribb/vendor/composer/ClassLoader.php:377
1
  • show your code to check where u wrong Commented Apr 17, 2014 at 10:24

2 Answers 2

2

You haven't showed your test, but you are trying use a Abstract Class and don't have all the abstract methods implemented. As the error states.

You are probably trying to mock the class that is throwing the error and just using getMock(). You need to use getMockForAbstractClass() instead. This will take care of implementing the methods for you.

$mock = $this->getMockForAbstractClass('User');

or using the MockBuilder

$mock = $this->getMockBuilder('User')
             ->getMockForAbstractClass();

http://phpunit.de/manual/current/en/test-doubles.html#test-doubles.mocking-traits-and-abstract-classes

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

Comments

0

The error message already point you in the right direction:

PHP Fatal error:  Class User contains 3 abstract methods and must therefore be declared abstract or implement the remaining methods (Illuminate\Auth\UserInterface::getRememberToken, Illuminate\Auth\UserInterface::setRememberToken, Illuminate\Auth\UserInterface::getRememberTokenName) in /usr/share/nginx/www/laravel-cribb/app/models/User.php on line 93

I assume your code looks like this:

class User {
   getRememberToken();
   setRememberToken($rememberToken);
   getRememberTokenName();
}

What you need to do depends now on what you want to do.

If User should be an abstract class:

abstract class User {
   getRememberToken();
   setRememberToken($rememberToken);
   getRememberTokenName();
}

If user should be a normal class, you need to implement the methods:

class User {
   getRememberToken() {
       return $this->rememberToken;
   }

   setRememberToken($rememberToken) {
      $this->rememberToken = $rememberToken;
   }

   getRememberTokenName() {
      return $this->rememberTokenName;
   }
}

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.