Details

    • Type: Sub-task Sub-task
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.3
    • Fix Version/s: 2.3.1
    • Component/s: Course, Web Services
    • Labels:
      None

      Description

      create course/tests/externallib.php

        Gliffy Diagrams

          Issue Links

            Activity

            Hide
            Jérôme Mouneyrac added a comment -

            I increase the priority. All web service contribution reviews depend of this first web service PHPunit being integrated and shown as example. I'll also update the docs, following what we decide here about the userassigncap unit test feature: http://docs.moodle.org/dev/Web_Services_Unit_Test

            Show
            Jérôme Mouneyrac added a comment - I increase the priority. All web service contribution reviews depend of this first web service PHPunit being integrated and shown as example. I'll also update the docs, following what we decide here about the userassigncap unit test feature: http://docs.moodle.org/dev/Web_Services_Unit_Test
            Hide
            Rossiani Wijaya added a comment -

            Hi Jerome,

            I received the following failure:

            rwijaya@rwijaya-desktop:~/stable/master$ phpunit core_course_external_testcase course/tests/externallib_test.php
            PHPUnit 3.6.11 by Sebastian Bergmann.
             
            Configuration read from /stable/master/phpunit.xml
             
            ..F......
             
            Time: 12 seconds, Memory: 123.75Mb
             
            There was 1 failure:
             
            1) core_course_external_testcase::test_get_categories
            Failed asserting that 3 matches expected 2.
             
            /stable/master/course/tests/externallib_test.php:189
            /stable/master/lib/phpunit/classes/advanced_testcase.php:76
             
            To re-run:
             phpunit core_course_external_testcase course/tests/externallib_test.php
             
            FAILURES!
            Tests: 9, Assertions: 88, Failures: 1.
            

            Some feedback for the code:
            #. '@category external' should be '@category phpunit'
            #. Remove one of the phpdocs for the class.
            #. Line 189, should be 3, because you are including subcategories.

            The rest looks good.

            Show
            Rossiani Wijaya added a comment - Hi Jerome, I received the following failure: rwijaya@rwijaya-desktop:~/stable/master$ phpunit core_course_external_testcase course/tests/externallib_test.php PHPUnit 3.6.11 by Sebastian Bergmann.   Configuration read from /stable/master/phpunit.xml   ..F......   Time: 12 seconds, Memory: 123.75Mb   There was 1 failure:   1) core_course_external_testcase::test_get_categories Failed asserting that 3 matches expected 2.   /stable/master/course/tests/externallib_test.php:189 /stable/master/lib/phpunit/classes/advanced_testcase.php:76   To re-run: phpunit core_course_external_testcase course/tests/externallib_test.php   FAILURES! Tests: 9, Assertions: 88, Failures: 1. Some feedback for the code: #. '@category external' should be '@category phpunit' #. Remove one of the phpdocs for the class. #. Line 189, should be 3, because you are including subcategories. The rest looks good.
            Hide
            Petr Skoda added a comment -

            Please do not modify phpunit classes as part of other issue, the assignUserCapability() and unassignUserCapability() will not be accepted to core, please create your helper methods elsewhere if necessary, thanks.

            Show
            Petr Skoda added a comment - Please do not modify phpunit classes as part of other issue, the assignUserCapability() and unassignUserCapability() will not be accepted to core, please create your helper methods elsewhere if necessary, thanks.
            Hide
            Jérôme Mouneyrac added a comment -

            Petr: no problem, I'll move them outside PHPunit classes.
            Rosie: thanks, the issue you have is related to MDL-33776 not being integrated yet.

            Show
            Jérôme Mouneyrac added a comment - Petr: no problem, I'll move them outside PHPunit classes. Rosie: thanks, the issue you have is related to MDL-33776 not being integrated yet.
            Hide
            Petr Skoda added a comment -

            You can see questions code if you need example, it crates a shared abstract testcase class that is shared by all questions tests.

            Show
            Petr Skoda added a comment - You can see questions code if you need example, it crates a shared abstract testcase class that is shared by all questions tests.
            Hide
            Jérôme Mouneyrac added a comment -

            It's the alternative I was thinking to implement when you said to move it. I'll write an abstract testcase class for externallib, no problem

            Show
            Jérôme Mouneyrac added a comment - It's the alternative I was thinking to implement when you said to move it. I'll write an abstract testcase class for externallib, no problem
            Hide
            Jérôme Mouneyrac added a comment -

            Submitting to integration. Note I kept the PHPunit naming convention in the helpers.php file (so $this->... calls are consistent). This issue is dependent of MDL-33995

            Show
            Jérôme Mouneyrac added a comment - Submitting to integration. Note I kept the PHPunit naming convention in the helpers.php file (so $this->... calls are consistent). This issue is dependent of MDL-33995
            Hide
            Dan Poltawski added a comment -

            Thanks Jerome, integrated into 23_STABLE and master.

            Show
            Dan Poltawski added a comment - Thanks Jerome, integrated into 23_STABLE and master.
            Hide
            Dan Poltawski added a comment -

            Petr: just a comment - do you not think this is a use case for a helper function in core for assiging a user a capability? It seems a bit fiddlely to setup a role ans then assign capability and assign role, seems like this could be useful.

            Show
            Dan Poltawski added a comment - Petr: just a comment - do you not think this is a use case for a helper function in core for assiging a user a capability? It seems a bit fiddlely to setup a role ans then assign capability and assign role, seems like this could be useful.
            Hide
            Dan Poltawski added a comment -

            Jerome, big troubles:

            Fatal error: Cannot redeclare class externallib_testcase in /Users/danp/git/integration/webservice/tests/helpers.php on line 81

            Call Stack:
            0.0009 629640 1.

            {main}

            () /usr/local/Cellar/php/5.3.10/bin/phpunit:0
            0.0124 1182240 2. PHPUnit_TextUI_Command::main() /usr/local/Cellar/php/5.3.10/bin/phpunit:46
            0.0124 1182968 3. PHPUnit_TextUI_Command->run() /usr/local/Cellar/php/5.3.10/lib/php/PHPUnit/TextUI/Command.php:130
            0.0124 1182968 4. PHPUnit_TextUI_Command->handleArguments() /usr/local/Cellar/php/5.3.10/lib/php/PHPUnit/TextUI/Command.php:139
            1.2319 56050248 5. PHPUnit_Util_Configuration->getTestSuiteConfiguration() /usr/local/Cellar/php/5.3.10/lib/php/PHPUnit/TextUI/Command.php:671
            2.5408 150995224 6. PHPUnit_Util_Configuration->getTestSuite() /usr/local/Cellar/php/5.3.10/lib/php/PHPUnit/Util/Configuration.php:776
            2.5417 150998696 7. PHPUnit_Framework_TestSuite->addTestFiles() /usr/local/Cellar/php/5.3.10/lib/php/PHPUnit/Util/Configuration.php:848
            2.5498 151274488 8. PHPUnit_Framework_TestSuite->addTestFile() /usr/local/Cellar/php/5.3.10/lib/php/PHPUnit/Framework/TestSuite.php:419
            2.5503 151273840 9. PHPUnit_Util_Fileloader::checkAndLoad() /usr/local/Cellar/php/5.3.10/lib/php/PHPUnit/Framework/TestSuite.php:358
            2.5504 151273968 10. PHPUnit_Util_Fileloader::load() /usr/local/Cellar/php/5.3.10/lib/php/PHPUnit/Util/Fileloader.php:79
            2.5543 151706168 11. include_once('/Users/danp/git/integration/course/tests/externallib_test.php') /usr/local/Cellar/php/5.3.10/lib/php/PHPUnit/Util/Fileloader.php:95

            Show
            Dan Poltawski added a comment - Jerome, big troubles: Fatal error: Cannot redeclare class externallib_testcase in /Users/danp/git/integration/webservice/tests/helpers.php on line 81 Call Stack: 0.0009 629640 1. {main} () /usr/local/Cellar/php/5.3.10/bin/phpunit:0 0.0124 1182240 2. PHPUnit_TextUI_Command::main() /usr/local/Cellar/php/5.3.10/bin/phpunit:46 0.0124 1182968 3. PHPUnit_TextUI_Command->run() /usr/local/Cellar/php/5.3.10/lib/php/PHPUnit/TextUI/Command.php:130 0.0124 1182968 4. PHPUnit_TextUI_Command->handleArguments() /usr/local/Cellar/php/5.3.10/lib/php/PHPUnit/TextUI/Command.php:139 1.2319 56050248 5. PHPUnit_Util_Configuration->getTestSuiteConfiguration() /usr/local/Cellar/php/5.3.10/lib/php/PHPUnit/TextUI/Command.php:671 2.5408 150995224 6. PHPUnit_Util_Configuration->getTestSuite() /usr/local/Cellar/php/5.3.10/lib/php/PHPUnit/Util/Configuration.php:776 2.5417 150998696 7. PHPUnit_Framework_TestSuite->addTestFiles() /usr/local/Cellar/php/5.3.10/lib/php/PHPUnit/Util/Configuration.php:848 2.5498 151274488 8. PHPUnit_Framework_TestSuite->addTestFile() /usr/local/Cellar/php/5.3.10/lib/php/PHPUnit/Framework/TestSuite.php:419 2.5503 151273840 9. PHPUnit_Util_Fileloader::checkAndLoad() /usr/local/Cellar/php/5.3.10/lib/php/PHPUnit/Framework/TestSuite.php:358 2.5504 151273968 10. PHPUnit_Util_Fileloader::load() /usr/local/Cellar/php/5.3.10/lib/php/PHPUnit/Util/Fileloader.php:79 2.5543 151706168 11. include_once('/Users/danp/git/integration/course/tests/externallib_test.php') /usr/local/Cellar/php/5.3.10/lib/php/PHPUnit/Util/Fileloader.php:95
            Hide
            Petr Skoda added a comment - - edited

            Dan: the externallib assignUserCapability has several problems, let's see first where outside of externallib it could be used and then add some helper class for it similar to the generator if necessary - I believe the advanced_testcase should not directly contain methods that create new objects in our database.

            Show
            Petr Skoda added a comment - - edited Dan: the externallib assignUserCapability has several problems, let's see first where outside of externallib it could be used and then add some helper class for it similar to the generator if necessary - I believe the advanced_testcase should not directly contain methods that create new objects in our database.
            Hide
            Dan Poltawski added a comment -

            Tests passing succesfully. Thanks

            Show
            Dan Poltawski added a comment - Tests passing succesfully. Thanks
            Hide
            Sam Hemelryk added a comment -

            Congratulations your code is upstream - gold star for you!

            This issue + 79 others made it in in time for the minor releases.
            Thank you everyone involved for your exuberant efforts.

            Show
            Sam Hemelryk added a comment - Congratulations your code is upstream - gold star for you! This issue + 79 others made it in in time for the minor releases. Thank you everyone involved for your exuberant efforts.
            Hide
            Petr Skoda added a comment - - edited

            This test is failing for me randomly - see MDL-35190.

            Show
            Petr Skoda added a comment - - edited This test is failing for me randomly - see MDL-35190 .

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: