Brak opisu

ClassTest.php 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. /*
  3. * This file is part of the PHP_TokenStream package.
  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. /**
  11. * Tests for the PHP_Token_CLASS class.
  12. *
  13. * @package PHP_TokenStream
  14. * @subpackage Tests
  15. * @author Laurent Laville <pear@laurent-laville.org>
  16. * @copyright Sebastian Bergmann <sebastian@phpunit.de>
  17. * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
  18. * @version Release: @package_version@
  19. * @link http://github.com/sebastianbergmann/php-token-stream/
  20. * @since Class available since Release 1.0.2
  21. */
  22. class PHP_Token_ClassTest extends PHPUnit_Framework_TestCase
  23. {
  24. protected $class;
  25. protected $function;
  26. protected function setUp()
  27. {
  28. $ts = new PHP_Token_Stream(TEST_FILES_PATH . 'source2.php');
  29. foreach ($ts as $token) {
  30. if ($token instanceof PHP_Token_CLASS) {
  31. $this->class = $token;
  32. }
  33. if ($token instanceof PHP_Token_FUNCTION) {
  34. $this->function = $token;
  35. break;
  36. }
  37. }
  38. }
  39. /**
  40. * @covers PHP_Token_CLASS::getKeywords
  41. */
  42. public function testGetClassKeywords()
  43. {
  44. $this->assertEquals('abstract', $this->class->getKeywords());
  45. }
  46. /**
  47. * @covers PHP_Token_FUNCTION::getKeywords
  48. */
  49. public function testGetFunctionKeywords()
  50. {
  51. $this->assertEquals('abstract,static', $this->function->getKeywords());
  52. }
  53. /**
  54. * @covers PHP_Token_FUNCTION::getVisibility
  55. */
  56. public function testGetFunctionVisibility()
  57. {
  58. $this->assertEquals('public', $this->function->getVisibility());
  59. }
  60. public function testIssue19()
  61. {
  62. $ts = new PHP_Token_Stream(TEST_FILES_PATH . 'issue19.php');
  63. foreach ($ts as $token) {
  64. if ($token instanceof PHP_Token_CLASS) {
  65. $this->assertFalse($token->hasInterfaces());
  66. }
  67. }
  68. }
  69. public function testIssue30()
  70. {
  71. $ts = new PHP_Token_Stream(TEST_FILES_PATH . 'issue30.php');
  72. $this->assertCount(1, $ts->getClasses());
  73. }
  74. }