WizardTest.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /*
  3. * This file is part of code-unit-reverse-lookup.
  4. *
  5. * (c) Sebastian Bergmann <sebastian@phpunit.de>
  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 SebastianBergmann\CodeUnitReverseLookup;
  11. use PHPUnit\Framework\TestCase;
  12. /**
  13. * @covers SebastianBergmann\CodeUnitReverseLookup\Wizard
  14. */
  15. class WizardTest extends TestCase
  16. {
  17. /**
  18. * @var Wizard
  19. */
  20. private $wizard;
  21. protected function setUp()
  22. {
  23. $this->wizard = new Wizard;
  24. }
  25. public function testMethodCanBeLookedUp()
  26. {
  27. require __DIR__ . '/_fixture/Foo.php';
  28. $this->assertEquals(
  29. 'Foo::method',
  30. $this->wizard->lookup(
  31. __DIR__ . '/_fixture/Foo.php',
  32. 6
  33. )
  34. );
  35. return $this->wizard;
  36. }
  37. /**
  38. * @depends testMethodCanBeLookedUp
  39. */
  40. public function testMethodCanBeLookedUp2(Wizard $wizard)
  41. {
  42. require __DIR__ . '/_fixture/Bar.php';
  43. $this->assertEquals(
  44. 'Bar::method',
  45. $wizard->lookup(
  46. __DIR__ . '/_fixture/Bar.php',
  47. 6
  48. )
  49. );
  50. }
  51. public function testReturnsFilenameAndLineNumberAsStringWhenNotInCodeUnit()
  52. {
  53. $this->assertEquals(
  54. 'file.php:1',
  55. $this->wizard->lookup('file.php', 1)
  56. );
  57. }
  58. }