GuessTest.php 939 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Form\Tests\Guess;
  11. use PHPUnit\Framework\TestCase;
  12. use Symfony\Component\Form\Guess\Guess;
  13. class TestGuess extends Guess
  14. {
  15. }
  16. class GuessTest extends TestCase
  17. {
  18. public function testGetBestGuessReturnsGuessWithHighestConfidence()
  19. {
  20. $guess1 = new TestGuess(Guess::MEDIUM_CONFIDENCE);
  21. $guess2 = new TestGuess(Guess::LOW_CONFIDENCE);
  22. $guess3 = new TestGuess(Guess::HIGH_CONFIDENCE);
  23. $this->assertSame($guess3, Guess::getBestGuess(array($guess1, $guess2, $guess3)));
  24. }
  25. /**
  26. * @expectedException \InvalidArgumentException
  27. */
  28. public function testGuessExpectsValidConfidence()
  29. {
  30. new TestGuess(5);
  31. }
  32. }