25 lines
650 B
PHP
25 lines
650 B
PHP
|
<?php
|
||
|
|
||
|
declare(strict_types=1);
|
||
|
|
||
|
namespace App\Tests;
|
||
|
|
||
|
use PHPUnit\Framework\TestCase;
|
||
|
use PHPUnit\Framework\Attributes\CoversClass;
|
||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||
|
use CodingTests\Prime;
|
||
|
|
||
|
#[CoversClass(Prime::class)]
|
||
|
final class PrimeTest extends \PHPUnit\Framework\TestCase
|
||
|
{
|
||
|
public function testisPrime(): void
|
||
|
{
|
||
|
$primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97];
|
||
|
for($test=-100;$test<=100;$test++)
|
||
|
{
|
||
|
$ret = Prime::isPrime($test);
|
||
|
$this->assertEquals(in_array($test, $primes), $ret, "Testing $test");
|
||
|
|
||
|
}
|
||
|
}
|
||
|
}
|