Revize ddf4122e
Přidáno uživatelem Jakub Vašta před téměř 5 roky(ů)
website/src/Calculator.php | ||
---|---|---|
1 |
<?php |
|
2 |
namespace App; |
|
3 |
|
|
4 |
class Calculator |
|
5 |
{ |
|
6 |
public function add($a, $b) |
|
7 |
{ |
|
8 |
return $a + $b; |
|
9 |
} |
|
10 |
} |
website/tests/CalculatorTest.php | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
namespace App\tests; |
|
4 |
|
|
5 |
use App\Calculator; |
|
6 |
use PHPUnit\Framework\TestCase; |
|
7 |
|
|
8 |
class CalculatorTest extends TestCase |
|
9 |
{ |
|
10 |
public function testAdd() |
|
11 |
{ |
|
12 |
$calculator = new Calculator(); |
|
13 |
$result = $calculator->add(30, 12); |
|
14 |
|
|
15 |
// assert that your calculator added the numbers correctly! |
|
16 |
$this->assertEquals(42, $result); |
|
17 |
} |
|
18 |
} |
Také k dispozici: Unified diff
Testing gitlab ci/cd pipeline setup with symfony unit testing examples