#9528: added missing data provider for JSON formatter test, added changelog and upgrade note, added @since tag to new property

This commit is contained in:
Alexander Makarov
2015-11-25 05:52:15 +03:00
parent 4f81b4a99d
commit 45432cc653
4 changed files with 15 additions and 0 deletions

View File

@ -74,6 +74,7 @@ Yii Framework 2 Change Log
- Chg #9411: `DetailView` now automatically sets container tag ID in case it's not specified (samdark)
- Chg #9953: `TimestampBehavior::getValue()` changed to make value processing consistent with `AttributeBehavior::getValue()` (silverfire)
- Chg #6419: Added `yii\web\ErrorHandler::displayVars` make list of displayed vars customizable. `$_ENV` and `$_SERVER` are not displayed by default anymore (silverfire)
- Chg #9528: Traversable objects are now formatted as arrays in `yii\web\XmlResponseFormatter` to support SPL objects and Generators (MaXL-ru)
- New #10083: Added wrapper for PHP webserver (samdark)
- New: Added new requirement: ICU Data version >= 49.1 (SilverFire)

View File

@ -34,6 +34,8 @@ initialization to support wider range of allowed characters. Because of this cha
the event.
- If you overrode the `yii.confirm` function and accessed the `yii` object through `this`, you must access it
with global variable `yii` instead.
* Traversable objects are now formatted as arrays in XML response to support SPL objects and Generators. Previous
behavior could be turned on by setting `XmlResponseFormatter::$useTraversableAsArray` to `false`.
Upgrade from Yii 2.0.5
----------------------

View File

@ -46,6 +46,7 @@ class XmlResponseFormatter extends Component implements ResponseFormatterInterfa
public $itemTag = 'item';
/**
* @var boolean whether to enable to interpret implemented \Traversable interface objects as array
* @since 2.0.7
*/
public $useTraversableAsArray = true;

View File

@ -73,4 +73,15 @@ class JsonResponseFormatterTest extends FormatterTest
], '{"0":{"id":123,"title":"<>"},"a":{"id":456,"title":"def"}}'],
];
}
public function formatTraversableObjectDataProvider()
{
$postsStack = new \SplStack();
$postsStack->push(new Post(915, 'record1'));
$postsStack->push(new Post(456, 'record2'));
return [
[$postsStack, '{"1":{"id":456,"title":"record2"},"0":{"id":915,"title":"record1"}}']
];
}
}