GuessTest.php 925 B

123456789101112131415161718192021222324252627282930313233343536
  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\Tests\Component\Form\Guess;
  11. use Symfony\Component\Form\Guess\Guess;
  12. class TestGuess extends Guess {}
  13. class GuessTest extends \PHPUnit_Framework_TestCase
  14. {
  15. public function testGetBestGuessReturnsGuessWithHighestConfidence()
  16. {
  17. $guess1 = new TestGuess(Guess::MEDIUM_CONFIDENCE);
  18. $guess2 = new TestGuess(Guess::LOW_CONFIDENCE);
  19. $guess3 = new TestGuess(Guess::HIGH_CONFIDENCE);
  20. $this->assertSame($guess3, Guess::getBestGuess(array($guess1, $guess2, $guess3)));
  21. }
  22. /**
  23. * @expectedException \UnexpectedValueException
  24. */
  25. public function testGuessExpectsValidConfidence()
  26. {
  27. new TestGuess(5);
  28. }
  29. }