Unit testing with PHPUnit: Writing your first test (3/10)

preview_player
Показать описание

Official site

Twitter
Рекомендации по теме
Комментарии
Автор

it is "class SampleTest extends \PHPUnit\Framework\TestCase" now

bewellegoist
Автор

PHP Fatal error: Class 'PHPUnit_Framework_TestCase' not found
For those arriving here after updating phpunit to version 6 released on 2017-02-03 (e.g. with composer), you may be getting this error because phpunit code is now namespaced (check changelog). You will need to refactor \PHPUnit_Framework_TestCase to \PHPUnit\Framework\TestCase

beefsupreme
Автор

use PHPUnit\Framework\TestCase;

class SampleTest extends TestCase
{
public function test_true_asserts_to_true()
{

}
}

skell_jams
Автор

"PHPUnit's units of code are now namespaced. For instance, PHPUnit_Framework_TestCase is now PHPUnit\Framework\TestCase." This was written in the announcement of PHPUnit 6.

Which means you have to write it like below:
<?php
use \PHPUnit\Framework\TestCase as TestCase;

class SampleTest extends TestCase
{
public function testTrueAssertsToTrue()
{
$this->assertTrue(true);
}
}

swastikrocker
Автор

Thank you for another great series!! For future viewers, you will need to extend \PHPUnit\Frameword\TestCase instead since version 6.

blueorca
Автор

Thank you! you helped me enormously to start testing 😁😁

arturonicolasjuarez
Автор

Did you ever get around to making that course on acceptance testing that you mentioned around 0:30?

brandonking
Автор

to fix "'PHPUnit_Framework_TestCase" error use "extends PHPUnit\Framework\TestCase" in your file

GAPk
Автор

I am getting Fatal error: Class 'PHPUnit_Framework_TestCase' not found in on line 5

saninshakya
Автор

How to make a test case that is not correct? Like if an element should be unique but the validation isn't set for its uniqueness then how should we do that?

sufyanbinshafqat
Автор

this is the new way of declaring the test class with extends
<?php
use PHPUnit\Framework\TestCase;

class SampleTest extends TestCase
{

}

ZrMst
Автор

Can we test angular 8 + node js webiste by using phpunit?

viraljadav
Автор

It's not working. Every time it gives the message "No tests executed". How can I solve the problem?

shahrinana
Автор

V6+ extends \PHPUnit\Framework\TestCase

wittm
Автор

If you get this error:
"Fatal error: Class 'PHPUnit_Framework_TestCase' not found in..."
this is the reason:
"PHPUnit's units of code are now namespaced. For instance, PHPUnit_Framework_TestCase is now PHPUnit\Framework\TestCase"

kevinobrien