PageRenderTime 52ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/Phrozn/Runner/CommandLine/ReaderTest.php

http://github.com/farazdagi/phrozn
PHP | 60 lines | 26 code | 10 blank | 24 comment | 0 complexity | 44362641c716d017e805bd71cdd19c7a MD5 | raw file
Possible License(s): Apache-2.0
  1. <?php
  2. /**
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. *
  15. * @category Phrozn
  16. * @package Phrozn\Runner\CommandLine
  17. * @author Victor Farazdagi
  18. * @license http://www.apache.org/licenses/LICENSE-2.0
  19. */
  20. namespace PhroznTest\Runner\CommandLine;
  21. use Phrozn\Runner\CommandLine\Reader,
  22. Phrozn\Outputter\TestOutputter as Outputter;
  23. /**
  24. * @category Phrozn
  25. * @package Phrozn\Runner
  26. * @author Victor Farazdagi
  27. */
  28. class ReaderTest
  29. extends \PHPUnit_Framework_TestCase
  30. {
  31. public function testReader()
  32. {
  33. $handle = fopen(dirname(__FILE__) . '/stdin', 'w+');
  34. $outputter = new Outputter($this);
  35. $reader = new Reader($handle, $outputter);
  36. fputs($handle, "yes\n");
  37. $out = $reader->readLine("Input prompt:");
  38. //$this->assertSame("yes", $out);
  39. ob_start();
  40. var_dump($handle);
  41. $dump = trim(ob_get_clean());
  42. $this->assertTrue(strpos($dump, 'of type (stream)') > 0);
  43. unset($reader); // free up handler
  44. ob_start();
  45. var_dump($handle);
  46. $dump = trim(ob_get_clean());
  47. $this->assertTrue(strpos($dump, 'of type (Unknown)') > 0);
  48. unlink(dirname(__FILE__) . '/stdin');
  49. }
  50. }