WizardTest.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php declare(strict_types=1);
  2. /*
  3. * This file is part of sebastian/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(): void
  22. {
  23. $this->wizard = new Wizard;
  24. }
  25. public function testMethodCanBeLookedUp(): Wizard
  26. {
  27. require __DIR__ . '/_fixture/Foo.php';
  28. $this->assertEquals(
  29. 'Foo::method',
  30. $this->wizard->lookup(
  31. __DIR__ . '/_fixture/Foo.php',
  32. 12
  33. )
  34. );
  35. return $this->wizard;
  36. }
  37. /**
  38. * @depends testMethodCanBeLookedUp
  39. */
  40. public function testMethodCanBeLookedUp2(Wizard $wizard): void
  41. {
  42. require __DIR__ . '/_fixture/Bar.php';
  43. $this->assertEquals(
  44. 'Bar::method',
  45. $wizard->lookup(
  46. __DIR__ . '/_fixture/Bar.php',
  47. 12
  48. )
  49. );
  50. }
  51. public function testReturnsFilenameAndLineNumberAsStringWhenNotInCodeUnit(): void
  52. {
  53. $this->assertEquals(
  54. 'file.php:1',
  55. $this->wizard->lookup('file.php', 1)
  56. );
  57. }
  58. }