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

2017-08-13 Thread Jeroen De Dauw
Hey, I concur with James on avoiding using SMWQueryResult in your tests directly. This class has many issues, most notably that it pretends to be some kind of Value Object, while actually not containing the data, but rather depending on services bound to persistence and framework to retrieve the

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

2017-08-04 Thread James HK
Hi, > CoreMockObjectRepository Class [4] but could not find an example how to > create a mock for SMWQueryResult. Please avoid using this object, it was created in the past and has since been considered to be deprecated with any remaining consumers to be converted in future. > @mwjames: any

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

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 Stephan Gambke via Semediawiki-devel
/SemanticResultFormats/blob/master/tests/phpunit/Unit/Formats/TreeTest.php#L56 [1] https://phpunit.de/manual/4.8/en/test-doubles.html#test-doubles.mock-objects > Original Message > Subject: [SMW-devel] SMWQueryResult mock object for testing > SemanticResultFormat > Local Ti

[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