mirror of
				https://github.com/yiisoft/yii2.git
				synced 2025-10-31 02:28:35 +08:00 
			
		
		
		
	Fixed \yiiunit\framework\helpers\JsonTest::testEncode() for PHP 5.4 (#19798)
* Fixed \yiiunit\framework\helpers\JsonTest::testEncode() for PHP 5.4 '\Generator' is only supported since PHP 5.5 * Actually fixed \yiiunit\framework\helpers\JsonTest::testEncode() for PHP 5.4 Turned out the test already failed during file parsing. Now using eval to "hide" the `yield`
This commit is contained in:
		| @ -96,14 +96,18 @@ class JsonTest extends TestCase | |||||||
|         $data->data = (object) null; |         $data->data = (object) null; | ||||||
|         $this->assertSame('{}', Json::encode($data)); |         $this->assertSame('{}', Json::encode($data)); | ||||||
|  |  | ||||||
|         // Generator |         // Generator (Only supported since PHP 5.5) | ||||||
|         $data = function () { |         if (PHP_VERSION_ID >= 50500) { | ||||||
|             foreach (['a' => 1, 'b' => 2] as $name  => $value) { |             $data = eval(<<<'PHP' | ||||||
|                 yield $name => $value; |                 return function () { | ||||||
|             } |                     foreach (['a' => 1, 'b' => 2] as $name => $value) { | ||||||
|         }; |                         yield $name => $value; | ||||||
|  |                     } | ||||||
|         $this->assertSame('{"a":1,"b":2}', Json::encode($data())); |                 }; | ||||||
|  | PHP | ||||||
|  |             ); | ||||||
|  |             $this->assertSame('{"a":1,"b":2}', Json::encode($data())); | ||||||
|  |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public function testHtmlEncode() |     public function testHtmlEncode() | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 rhertogh
					rhertogh