This repository was archived by the owner on Jan 29, 2020. It is now read-only.
This repository was archived by the owner on Jan 29, 2020. It is now read-only.
AcceptableViewModelSelector returns wrong View Model #194
Closed
Description
I tried using the AcceptableViewModelSelector with this Accept-Header in my request (Its the standard header for HTML in FF):
text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Expectation:
It should return "ViewModel" with the given Accept-Header and it should return a JsonModel with "application/json" in my Accept-Header.
Reality:
Testcase 1:
$viewModel = $this->acceptableViewModelSelector(
[
JsonModel::class => ['application/json'],
FeedModel::class => ['application/rss+xml'],
]
);
Returns
- JsonModel if application/json
- FeedModel if application/rss+xml
- JsonModel with the Accept-Header above
Testcase 2:
$viewModel = $this->acceptableViewModelSelector(
[
FeedModel::class => ['application/rss+xml'],
JsonModel::class => ['application/json'],
]
);
Returns
- JsonModel if application/json
- FeedModel if application/rss+xml
- FeedModel with the Accept-Header above
Testcase 3:
$viewModel = $this->acceptableViewModelSelector(
[
FeedModel::class => ['application/rss+xml'],
JsonModel::class => ['application/json'],
ViewModel::class => ['text/html'],
]
);
Returns
- JsonModel if application/json
- FeedModel if application/rss+xml
- ViewModel with the Accept-Header above
Observation
It seems like the fallback to defaultViewModel does not work and it'll returns the first Model it gets if no match was successfull.