Posts

Showing posts with the label phpunit

Laravel: How to enable stacktrace error on PhpUnit

Laravel: How to enable stacktrace error on PhpUnit I have a fresh installation of laravel 5.4 I've tried to modify the default test just to see a failing test. tests/ExampleTest.php class ExampleTest extends TestCase { /** * A basic test example. * * @return void */ public function testBasicTest() { $response = $this->get('/ooops'); $response->assertStatus(200); } } I was expecting to see more detailed error like no route has been found or defined etc, but instead just this error saying no route has been found or defined Time: 1.13 seconds, Memory: 8.00MB There was 1 failure: 1) TestsFeatureExampleTest::testBasicTest Expected status code 200 but received 404. Failed asserting that false is true. /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestResponse.php:51 /var/www/tests/Feature/ExampleTest.php:21 Its really hard to do TDD without meaningful error (yeah I know 404 in this case is enough, bu...

wordpress-develop unit testing couldn't fetch mysqli

wordpress-develop unit testing couldn't fetch mysqli I've seen a lot of mysqli errors on stack overflow, but none seem to relate to wordpress-develop I set up the test folder, bootstrap.php. if ( function_exists( 'xdebug_disable' ) ) { xdebug_disable(); } if ( false !== getenv( 'WP_DEVELOP_DIR' ) ) { require getenv( 'WP_DEVELOP_DIR' ) . 'testsphpunitincludesbootstrap.php'; } if ( false !== getenv( 'WP_PLUGIN_DIR' ) ) { define( 'WP_PLUGIN_DIR', getenv( 'WP_PLUGIN_DIR' ) ); } phpunit.xml <phpunit bootstrap="tests/bootstrap.php"> <testsuites> <testsuite> <directory prefix="test-" suffix=".php">./tests/</directory> </testsuite> </testsuites> </phpunit> config define( 'DB_NAME', 'bitnami_wordpress_testing' ); define( 'DB_USER', 'root' ); define( 'DB_PASSWORD', '' ); de...

How do I run PHPUnit in Laravel from my Windows Command prompt

How do I run PHPUnit in Laravel from my Windows Command prompt I have a Laravel app installed in my directory f:lara_app. I use PHP artisan serve to run the app. I have Laravel version 5.4.36 (via Composer Install) I am not trying my hand in using the PHP Unit to do testing. Inside f:/lara_app/tests/Unit/ExampleTest.php, I have the following codes: namespace TestsUnit; use TestsTestCase; use IlluminateFoundationTestingDatabaseMigrations; use IlluminateFoundationTestingDatabaseTransactions; class ExampleTest extends TestCase { /** * A basic test example. * * @return void */ public function testBasicTest() { $this->assertTrue(true); } public function myFirstTest() { $value = 'Hello World'; $this->assertTrue( 'Hello' === $value, 'Value should be Hello World'); } } I now try to run the test from my command prompt: f:lara_app> .vendor/phpunit/phpuni/phpunit But I'm getting the m...