NullIOTest.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. /*
  3. * This file is part of Composer.
  4. *
  5. * (c) Nils Adermann <naderman@naderman.de>
  6. * Jordi Boggiano <j.boggiano@seld.be>
  7. *
  8. * For the full copyright and license information, please view the LICENSE
  9. * file that was distributed with this source code.
  10. */
  11. namespace Composer\Test\IO;
  12. use Composer\IO\NullIO;
  13. use Composer\Test\TestCase;
  14. class NullIOTest extends TestCase
  15. {
  16. public function testIsInteractive()
  17. {
  18. $io = new NullIO();
  19. $this->assertFalse($io->isInteractive());
  20. }
  21. public function testHasAuthorization()
  22. {
  23. $io = new NullIO();
  24. $this->assertFalse($io->hasAuthorization('foo'));
  25. }
  26. public function testGetLastPassword()
  27. {
  28. $io = new NullIO();
  29. $this->assertNull($io->getLastPassword());
  30. }
  31. public function testGetLastUsername()
  32. {
  33. $io = new NullIO();
  34. $this->assertNull($io->getLastUsername());
  35. }
  36. public function testAskAndHideAnswer()
  37. {
  38. $io = new NullIO();
  39. $this->assertNull($io->askAndHideAnswer('foo'));
  40. }
  41. public function testGetAuthorizations()
  42. {
  43. $io = new NullIO();
  44. $this->assertInternalType('array', $io->getAuthorizations());
  45. $this->assertEmpty($io->getAuthorizations());
  46. $this->assertEquals(array('username' => null, 'password' => null), $io->getAuthorization('foo'));
  47. }
  48. public function testAsk()
  49. {
  50. $io = new NullIO();
  51. $this->assertEquals('foo', $io->ask('bar', 'foo'));
  52. }
  53. public function testAskConfirmation()
  54. {
  55. $io = new NullIO();
  56. $this->assertEquals('foo', $io->askConfirmation('bar', 'foo'));
  57. }
  58. public function testAskAndValidate()
  59. {
  60. $io = new NullIO();
  61. $this->assertEquals('foo', $io->askAndValidate('question', 'validator', false, 'foo'));
  62. }
  63. }