Re: [SMW-devel] SMWQueryResult mock object for testing SemanticResultFormat

2017-08-03 Thread Stephan Gambke via Semediawiki-devel
Yes, SRF does not have a lot of testing, so thx for improving and sorry for not having much to copy from! Maybe [0] could give you an idea on how to create your mock object. See [1] for documentation on how to work with mock objects. Cheers Stephan [0]

[SMW-devel] SMWQueryResult mock object for testing SemanticResultFormat

2017-08-03 Thread planetenxin
I want to enhance existing SRF graph format test. My idea is, to create a mock SMWQueryResult (=test data) that will be passed to function getResultText (at the moment, could be getGraphvizCode or something later). I had a look at existing tests [1] and docs [2][3] as well as

Re: [SMW-devel] SMWQueryResult mock object for testing SemanticResultFormat

2017-08-03 Thread planetenxin
Stephan, thanks for your feedback. In the meanwhile I had another idea. How about creating test data from serialized SMWQueryResults? I saw, that SMWQueryResult provides a serializeToArray() function [1]. Is there an easy way to "unserializeFromArray()"? [1]

Re: [SMW-devel] SMWQueryResult mock object for testing SemanticResultFormat

2017-08-03 Thread planetenxin
roundtrip example $sf = new SerializerFactory(); $queryResultJSON = json_encode( $sf->getSerializerFor( $queryResult )->serialize( $queryResult ) ); $decodedQueryResult = json_decode( $queryResultJSON ); $queryResultFromJSON = $sf->getDeserializerFor( $decodedQueryResult )->deserialize(

Re: [SMW-devel] SMWQueryResult mock object for testing SemanticResultFormat

2017-08-03 Thread planetenxin
found https://doc.semantic-mediawiki.org/classSMW_1_1Serializers_1_1QueryResultSerializer.html Let's see if this can be used... Am 03.08.2017 um 14:37 schrieb planetenxin: > Another option would be json_encode / json_decode but this would require > implementing JsonSerializable interface as far

Re: [SMW-devel] SMWQueryResult mock object for testing SemanticResultFormat

2017-08-03 Thread planetenxin
Another option would be json_encode / json_decode but this would require implementing JsonSerializable interface as far as I can see. @mwjames: any ideas suggestions from your side? Am 03.08.2017 um 12:46 schrieb Stephan Gambke: > Although, i just found a class QueryFactory, that has a function