Re: [SMW-devel] SMWQueryResult mock object for testing SemanticResultFormat
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] https://github.com/SemanticMediaWiki/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 Time: August 3, 2017 9:40 AM > UTC Time: August 3, 2017 7:40 AM > From: planeten...@web.de > To: Semediawiki-devel@lists.sourceforge.net > 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 > CoreMockObjectRepository Class [4] but could not find an example how to > create a mock for SMWQueryResult. > Is creating a mock for SMWQueryResult a good idea at all? > Could someone help with an example? > Many thx! > [1] > https://github.com/SemanticMediaWiki/SemanticResultFormats/tree/master/tests/phpunit/Unit/Formats > [2] https://www.semantic-mediawiki.org/wiki/Help:Using_mock_objects > [3] > https://www.semantic-mediawiki.org/wiki/Writing_result_printers#Writing_tests > [4] > https://doc.semantic-mediawiki.org/classSMW_1_1Tests_1_1Utils_1_1Mock_1_1CoreMockObjectRepository.html#a0346be0a0d6284eaea8e79228455ac09 > -- > Check out the vibrant tech community on one of the world"s most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > ___ > Semediawiki-devel mailing list > Semediawiki-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/semediawiki-devel-- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot___ Semediawiki-devel mailing list Semediawiki-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/semediawiki-devel
[SMW-devel] SMWQueryResult mock object for testing SemanticResultFormat
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 CoreMockObjectRepository Class [4] but could not find an example how to create a mock for SMWQueryResult. Is creating a mock for SMWQueryResult a good idea at all? Could someone help with an example? Many thx! [1] https://github.com/SemanticMediaWiki/SemanticResultFormats/tree/master/tests/phpunit/Unit/Formats [2] https://www.semantic-mediawiki.org/wiki/Help:Using_mock_objects [3] https://www.semantic-mediawiki.org/wiki/Writing_result_printers#Writing_tests [4] https://doc.semantic-mediawiki.org/classSMW_1_1Tests_1_1Utils_1_1Mock_1_1CoreMockObjectRepository.html#a0346be0a0d6284eaea8e79228455ac09 -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot ___ Semediawiki-devel mailing list Semediawiki-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/semediawiki-devel
Re: [SMW-devel] SMWQueryResult mock object for testing SemanticResultFormat
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] https://doc.semantic-mediawiki.org/classSMWQueryResult.html#a275ce1f7f02fe2e13ad73f49512185b6 Am 03.08.2017 um 09:58 schrieb Stephan Gambke: > 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] > https://github.com/SemanticMediaWiki/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 > -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot ___ Semediawiki-devel mailing list Semediawiki-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/semediawiki-devel
Re: [SMW-devel] SMWQueryResult mock object for testing SemanticResultFormat
roundtrip example $sf = new SerializerFactory(); $queryResultJSON = json_encode( $sf->getSerializerFor( $queryResult )->serialize( $queryResult ) ); $decodedQueryResult = json_decode( $queryResultJSON ); $queryResultFromJSON = $sf->getDeserializerFor( $decodedQueryResult )->deserialize( $decodedQueryResult ); Am 03.08.2017 um 15:05 schrieb planetenxin: > found > > https://doc.semantic-mediawiki.org/classSMW_1_1Serializers_1_1QueryResultSerializer.html > > Let's see if this can be used... -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot ___ Semediawiki-devel mailing list Semediawiki-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/semediawiki-devel
Re: [SMW-devel] SMWQueryResult mock object for testing SemanticResultFormat
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 as I can see. -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot ___ Semediawiki-devel mailing list Semediawiki-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/semediawiki-devel
Re: [SMW-devel] SMWQueryResult mock object for testing SemanticResultFormat
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 > newQueryResult( Store $store, Query $query, $results = array(), > $continue = false ) that might be of use. > Maybe James HK has a better idea. -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot ___ Semediawiki-devel mailing list Semediawiki-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/semediawiki-devel