Installing PHPUnit via PEAR
I had the same problem, try: pear clear-cache
I had the same problem, try: pear clear-cache
UPDATE: As of 2013 November and Ubuntu 12.04 these 2 commands should suffice: sudo pear config-set auto_discover 1 sudo pear install pear.phpunit.de/PHPUnit The following is an older answer. It’s a known problem , although almost a year and a half had passed. Read about it here The code coverage must be installed in order for … Read more
PHPUnit supports test dependencies via the @depends annotation. Here is an example from the documentation where tests will be run in an order that satisfies dependencies, with each dependent test passing an argument to the next: class StackTest extends PHPUnit_Framework_TestCase { public function testEmpty() { $stack = array(); $this->assertEmpty($stack); return $stack; } /** * @depends … Read more
http://apigen.juzna.cz/doc/sebastianbergmann/phpunit/function-assertInstanceOf.html I think you are using this function wrong. Try: $this->assertInstanceOf(‘User’, $user);
It seems like you are missing the Xdebug extension. If you’re using homebrew you can install it like: brew install php70-xdebug After that, don’t forget to edit your php.ini file to enable the extension. php -i | grep xdebug After checking that xdebug is enabled you should be able to do code coverage
Inside controller inject Request object. So if you want to access request body inside controller method ‘foo’ do the following: use Illuminate\Http\Request; public function foo(Request $request){ $bodyContent = $request->getContent(); }
Usually you just don’t test or mock the private & protected methods directy. What you want to test is the public API of your class. Everything else is an implementation detail for your class and should not “break” your tests if you change it. That also helps you when you notice that you “can’t get … Read more
This is more an additional answer to the one already given: Looking through your code, the class GoogleAPIRequest has a hard-encoded dependency of class Request. This prevents you from testing it independently from the request class, so you can’t mock the request. You need to make the request injectable, so you can change it to … Read more
You can get PHP_CodeSniffer to ignore specific files or lines in a file using comments: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#ignoring-files-and-folders In this case, the error will be generated on your second class definition, so you’d have to write you second definition like this: // @codingStandardsIgnoreStart class MyClassTest extends \PHPUnit_Framework_TestCase { // @codingStandardsIgnoreEnd // … } But you might also … Read more
Here’s the code as if PHPUnit 3.7.13 $ phpunit –configuration config.xml –testsuite Library $ phpunit –configuration config.xml –testsuite XXX_Form If you want to run a group of the test suites then you can do this <testsuites> <testsuite name=”Library”> <directory>library</directory> </testsuite> <testsuite name=”XXX_Form”> <file>library/XXX/FormTest.php</file> <directory>library/XXX/Form</directory> </testsuite> <testsuite name=”Both”> <directory>library</directory> <file>library/XXX/FormTest.php</file> <directory>library/XXX/Form</directory> </testsuite> </testsuites> Then $ phpunit … Read more