Não estou conseguindo organizar os teste, da erro.
<?php
namespace Alura\Leilao\Tests\Service;
use Alura\Leilao\Model\Lance;
use Alura\Leilao\Model\Leilao;
use Alura\Leilao\Model\Usuario;
use Alura\Leilao\Service\Avaliador;
use PHPUnit\Framework\TestCase;
class AvaliadorTest extends TestCase
{
/**
* @dataProvider leilaoEmOrdemAleatoria
* @dataProvider leilaoEmOrdemCrescente
* @dataProvider leilaoEmOrdemDecrescente
* */
public function testAvaliadorDeveEncontrarOMaiorValorDeLances(Leilao $leilao)
{
$leiloeiro = new Avaliador();
$leiloeiro->avalia($leilao);
$maiorValor = $leiloeiro->getMaioValor();
self::assertEquals(2500,$maiorValor);
}
/**
* @dataProvider leilaoEmOrdemAleatoria
* @dataProvider leilaoEmOrdemCrescente
* @dataProvider leilaoEmOrdemDecrescente
* */
public function testAvaliadorDeveEncontrarOMenorValorDeLances(Leilao $leilao)
{
$leiloeiro = new Avaliador();
$leiloeiro->avalia($leilao);
$menorValor = $leiloeiro->getMenorValor();
self::assertEquals(1700,$menorValor);
}
/**
* @dataProvider leilaoEmOrdemAleatoria
* @dataProvider leilaoEmOrdemCrescente
* @dataProvider leilaoEmOrdemDecrescente
*/
public function testeAvaliadorDeveBuscar3MaioresValores(Leilao $leilao)
{
$leiloeiro = new Avaliador;
$leiloeiro->avalia($leilao);
$maiores = $leiloeiro->getMaioresLances();
static::assertCount(3,$maiores);
static :: assertEquals(2500,$maiores[0]->getValor());
static :: assertEquals(2000,$maiores[1]->getValor());
static :: assertEquals(1700,$maiores[2]->getValor());
}
public function leilaoEmOrdemCrescente()
{
$leilao = new Leilao('Fiat 147 0KM');
$maria = new Usuario('Maria');
$joao = new Usuario('Joao');
$ana = new Usuario('Ana');
$leilao->recebeLance(new Lance($ana,1700));
$leilao->recebeLance(new Lance($joao,2000));
$leilao->recebeLance(new Lance($maria,2500));
return [ [$leilao] ]; }
public function leilaoEmOrdemDecrescente()
{
$leilao = new Leilao('Fiat 147 0KM');
$maria = new Usuario('Maria');
$joao = new Usuario('Joao');
$ana = new Usuario('Ana');
$leilao->recebeLance(new Lance($maria,2500));
$leilao->recebeLance(new Lance($joao,2000));
$leilao->recebeLance(new Lance($ana,1700));
return [
[$leilao]
];
}
public function leilaoEmOrdemAleatoria()
{
$leilao = new Leilao('Fiat 147 0KM');
$maria = new Usuario('Maria');
$joao = new Usuario('Joao');
$ana = new Usuario('Ana');
$leilao->recebeLance(new Lance($joao,2000));
$leilao->recebeLance(new Lance($maria,2500));
$leilao->recebeLance(new Lance($ana,1700));
return [ [$leilao] ] ; } }
PHPUnit 10.0.0 by Sebastian Bergmann and contributors.
Runtime: PHP 8.2.11
D........ 9 / 9 (100%)
Time: 00:00.108, Memory: 6.00 MB
There were 3 PHPUnit deprecations:
1) Alura\Leilao\Tests\Service\AvaliadorTest::testAvaliadorDeveEncontrarOMaiorValorDeLances
* Data Provider method Alura\Leilao\Tests\Service\AvaliadorTest::leilaoEmOrdemAleatoria() is not static
* Data Provider method Alura\Leilao\Tests\Service\AvaliadorTest::leilaoEmOrdemCrescente() is not static
* Data Provider method Alura\Leilao\Tests\Service\AvaliadorTest::leilaoEmOrdemDecrescente() is not static
F:\Pedro\Github\php\Semana8-1\tests\Service\AvaliadorTest.php:18
2) Alura\Leilao\Tests\Service\AvaliadorTest::testAvaliadorDeveEncontrarOMenorValorDeLances
* Data Provider method Alura\Leilao\Tests\Service\AvaliadorTest::leilaoEmOrdemAleatoria() is not static
* Data Provider method Alura\Leilao\Tests\Service\AvaliadorTest::leilaoEmOrdemCrescente() is not static
* Data Provider method Alura\Leilao\Tests\Service\AvaliadorTest::leilaoEmOrdemDecrescente() is not static
F:\Pedro\Github\php\Semana8-1\tests\Service\AvaliadorTest.php:53
3) Alura\Leilao\Tests\Service\AvaliadorTest::testeAvaliadorDeveBuscar3MaioresValores
* Data Provider method Alura\Leilao\Tests\Service\AvaliadorTest::leilaoEmOrdemAleatoria() is not static
* Data Provider method Alura\Leilao\Tests\Service\AvaliadorTest::leilaoEmOrdemCrescente() is not static
* Data Provider method Alura\Leilao\Tests\Service\AvaliadorTest::leilaoEmOrdemDecrescente() is not static
F:\Pedro\Github\php\Semana8-1\tests\Service\AvaliadorTest.php:101
OK, but some tests have issues!
Tests: 9, Assertions: 18, Deprecations: 3.