@@ -24,13 +24,14 @@ final class YieldTest extends AbstractTokenizerTestCase
2424 /**
2525 * Test that the yield keyword is tokenized as such.
2626 *
27- * @param string $testMarker The comment which prefaces the target token in the test file.
27+ * @param string $testMarker The comment which prefaces the target token in the test file.
28+ * @param string $expectedContent Expected token content.
2829 *
2930 * @dataProvider dataYieldKeyword
3031 *
3132 * @return void
3233 */
33- public function testYieldKeyword ($ testMarker )
34+ public function testYieldKeyword ($ testMarker, $ expectedContent )
3435 {
3536 $ tokens = $ this ->phpcsFile ->getTokens ();
3637 $ target = $ this ->getTargetToken ($ testMarker , [T_YIELD , T_YIELD_FROM , T_STRING ]);
@@ -39,6 +40,8 @@ public function testYieldKeyword($testMarker)
3940 $ this ->assertSame (T_YIELD , $ tokenArray ['code ' ], 'Token tokenized as ' .$ tokenArray ['type ' ].', not T_YIELD (code) ' );
4041 $ this ->assertSame ('T_YIELD ' , $ tokenArray ['type ' ], 'Token tokenized as ' .$ tokenArray ['type ' ].', not T_YIELD (type) ' );
4142
43+ $ this ->assertSame ($ expectedContent , $ tokenArray ['content ' ], 'Token content does not match expectation ' );
44+
4245 }//end testYieldKeyword()
4346
4447
@@ -52,9 +55,18 @@ public function testYieldKeyword($testMarker)
5255 public static function dataYieldKeyword ()
5356 {
5457 return [
55- 'yield ' => ['/* testYield */ ' ],
56- 'yield followed by comment ' => ['/* testYieldFollowedByComment */ ' ],
57- 'yield at end of file, live coding ' => ['/* testYieldLiveCoding */ ' ],
58+ 'yield ' => [
59+ 'testMarker ' => '/* testYield */ ' ,
60+ 'expectedContent ' => 'yield ' ,
61+ ],
62+ 'yield followed by comment ' => [
63+ 'testMarker ' => '/* testYieldFollowedByComment */ ' ,
64+ 'expectedContent ' => 'YIELD ' ,
65+ ],
66+ 'yield at end of file, live coding ' => [
67+ 'testMarker ' => '/* testYieldLiveCoding */ ' ,
68+ 'expectedContent ' => 'yield ' ,
69+ ],
5870 ];
5971
6072 }//end dataYieldKeyword()
@@ -64,23 +76,24 @@ public static function dataYieldKeyword()
6476 * Test that the yield from keyword is tokenized as a single token when it in on a single line
6577 * and only has whitespace between the words.
6678 *
67- * @param string $testMarker The comment which prefaces the target token in the test file.
68- * @param string $content Optional. The test token content to search for.
69- * Defaults to null.
79+ * @param string $testMarker The comment which prefaces the target token in the test file.
80+ * @param string $expectedContent Expected token content.
7081 *
7182 * @dataProvider dataYieldFromKeywordSingleToken
7283 *
7384 * @return void
7485 */
75- public function testYieldFromKeywordSingleToken ($ testMarker , $ content = null )
86+ public function testYieldFromKeywordSingleToken ($ testMarker , $ expectedContent )
7687 {
7788 $ tokens = $ this ->phpcsFile ->getTokens ();
78- $ target = $ this ->getTargetToken ($ testMarker , [T_YIELD , T_YIELD_FROM , T_STRING ], $ content );
89+ $ target = $ this ->getTargetToken ($ testMarker , [T_YIELD , T_YIELD_FROM , T_STRING ]);
7990 $ tokenArray = $ tokens [$ target ];
8091
8192 $ this ->assertSame (T_YIELD_FROM , $ tokenArray ['code ' ], 'Token tokenized as ' .$ tokenArray ['type ' ].', not T_YIELD_FROM (code) ' );
8293 $ this ->assertSame ('T_YIELD_FROM ' , $ tokenArray ['type ' ], 'Token tokenized as ' .$ tokenArray ['type ' ].', not T_YIELD_FROM (type) ' );
8394
95+ $ this ->assertSame ($ expectedContent , $ tokenArray ['content ' ], 'Token content does not match expectation ' );
96+
8497 }//end testYieldFromKeywordSingleToken()
8598
8699
@@ -95,13 +108,16 @@ public static function dataYieldFromKeywordSingleToken()
95108 {
96109 return [
97110 'yield from ' => [
98- 'testMarker ' => '/* testYieldFrom */ ' ,
111+ 'testMarker ' => '/* testYieldFrom */ ' ,
112+ 'expectedContent ' => 'yield from ' ,
99113 ],
100114 'yield from with extra space between ' => [
101- 'testMarker ' => '/* testYieldFromWithExtraSpacesBetween */ ' ,
115+ 'testMarker ' => '/* testYieldFromWithExtraSpacesBetween */ ' ,
116+ 'expectedContent ' => 'Yield From ' ,
102117 ],
103118 'yield from with tab between ' => [
104- 'testMarker ' => '/* testYieldFromWithTabBetween */ ' ,
119+ 'testMarker ' => '/* testYieldFromWithTabBetween */ ' ,
120+ 'expectedContent ' => 'yield from ' ,
105121 ],
106122 ];
107123
0 commit comments