Boolean type is returned as string
I noticed that when you send a boolen it will be returned as a string. For example true ends up as "true".
{
"@context":{
"active":"http://localhost/app_dev.php/hydra/vocab#SomeDTO/active"
},
"@type":"http://localhost/app_dev.php/hydra/vocab#SomeDTO",
"active":true
}
I tried to add a unit test for it but the unit testing failed. With
PHP Warning: file_get_contents(/../vendor/ml/json-ld/ML/JsonLD/Test/tests/expand-manifest.jsonld): failed to open stream: No such file or directory in /../vendor/ml/json-ld/ML/JsonLD/Test/TestManifestIterator.php on line 44
Which is correct because there is no test directory??
How should the unit test be started so that I can add a unit test and try to fix this for boolean type?
Thanks Iwan for your bug report, even though I’m not sure yet it really is a bug. What exactly are you trying to do?
The “tests” directory is deliberately empty at the moment as it is filled with the test from the official JSON-LD test suite. Have a look at .travis.yml, it runs the following commands
git clone git://github.com/json-ld/json-ld.org.git
mv ./json-ld.org/test-suite/tests ./Test/
rm -rf ./json-ld.org
Doing that will fix the problem. I proposed to create a subtree split for the tests a while ago but there was some pushback. I'll try again shortly. This would mean that the tests can be fetched easily directly by composer.
@istaveren I've created a subtree split of the JSON-LD tests and included them directly as a composer package. You should now be able to run the PHPUnit tests by pulling the latest version and then doing a
php composer.phar update
Would love to see the test showing the bug you found.
Thanks.
You might be right that this is not a bug in this package. I fixed it in the hydra bundle where I hit it. https://github.com/istaveren/HydraBundle/commit/51e7d68d1723a20a715bec4c18767a635b5b729f
I will give it I try to reproduce it here.
Because Value->getValue() always should return a string this is not a bug. So it is an issue in the HydraBundle deserializer.