Details

    • Type: Sub-task
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 2.4
    • Fix Version/s: 2.4
    • Component/s: Unit tests
    • Labels:
    • Testing Instructions:
      Hide

      1/ go to your moodle dirroot
      2/ install composer - see http://getcomposer.org/doc/00-intro.md
      3/ "php composer.phar install"
      4/ execute "vendor/bin/phpunit" (sorry, *nix only instructions for now)
      5/ bump up some version number
      6/ execute again and verify the init script works too
      7/ try the hidden web interface at admin/tool/phpunit/webrunner.php
      8/ repeat the testing with & without standard PHPUnit from PEAR

      Show
      1/ go to your moodle dirroot 2/ install composer - see http://getcomposer.org/doc/00-intro.md 3/ "php composer.phar install" 4/ execute "vendor/bin/phpunit" (sorry, *nix only instructions for now) 5/ bump up some version number 6/ execute again and verify the init script works too 7/ try the hidden web interface at admin/tool/phpunit/webrunner.php 8/ repeat the testing with & without standard PHPUnit from PEAR
    • Affected Branches:
      MOODLE_24_STABLE
    • Fixed Branches:
      MOODLE_24_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      w47_MDL-36701_m24_composer

      Description

      should be a lot better than PEAR...

      http://getcomposer.org

      Sample installation of PHPUnit into moodle project:

      $ cd yourmoodledir
      $ curl -s https://getcomposer.org/installer | php
      $ php composer.phar install

      Execution of PHPUnit:

      $ cd yourmoodledir
      $ vendor/bin/phpunit

      Upgrade to next PHPUnit version:

      $ cd yourmoodledir
      $ php composer.phar update

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

              Hide
              skodak Petr Skoda added a comment -

              There is a known problem execution hints when some tests fail, for now it does not print path to the original execution script. I will fix that later...

              Show
              skodak Petr Skoda added a comment - There is a known problem execution hints when some tests fail, for now it does not print path to the original execution script. I will fix that later...
              Hide
              skodak Petr Skoda added a comment -

              working on some more improvements...

              Show
              skodak Petr Skoda added a comment - working on some more improvements...
              Hide
              skodak Petr Skoda added a comment -

              All known issues fixed.

              Show
              skodak Petr Skoda added a comment - All known issues fixed.
              Hide
              timhunt Tim Hunt added a comment -

              I just tested on Windows 7 + Cygwin (with existing PHPunit already installed). It took me a bit of time to get composer installed since http://getcomposer.org/doc/00-intro.md#using-the-installer does not consider does not consider that you might be behind a HTTP proxy. Apart from that, it worked fine.

              Nice one Petr.

              Show
              timhunt Tim Hunt added a comment - I just tested on Windows 7 + Cygwin (with existing PHPunit already installed). It took me a bit of time to get composer installed since http://getcomposer.org/doc/00-intro.md#using-the-installer does not consider does not consider that you might be behind a HTTP proxy. Apart from that, it worked fine. Nice one Petr.
              Hide
              nebgor Aparup Banerjee added a comment -

              Hm i've gotten an interesting:

              moodle_page_test::test_pagetype_defaults_to_script
              Failed asserting that two strings are equal.
              — Expected
              +++ Actual
              @@ @@
              -'site-index'
              +'vendor-phpunit-phpunit-composer-bin-phpunit'

              /Users/aparup/Sites/i/lib/tests/pagelib_test.php:191
              /Users/aparup/Sites/i/lib/phpunit/classes/advanced_testcase.php:76

              To re-run:
              phpunit moodle_page_test lib/tests/pagelib_test.php

              Show
              nebgor Aparup Banerjee added a comment - Hm i've gotten an interesting: moodle_page_test::test_pagetype_defaults_to_script Failed asserting that two strings are equal. — Expected +++ Actual @@ @@ -'site-index' +'vendor-phpunit-phpunit-composer-bin-phpunit' /Users/aparup/Sites/i/lib/tests/pagelib_test.php:191 /Users/aparup/Sites/i/lib/phpunit/classes/advanced_testcase.php:76 To re-run: phpunit moodle_page_test lib/tests/pagelib_test.php
              Hide
              skodak Petr Skoda added a comment - - edited

              Strange, I already tweaked the test to fix this, I will try the latest integration branch again and look for any caching problems.

              Thanks!

              Show
              skodak Petr Skoda added a comment - - edited Strange, I already tweaked the test to fix this, I will try the latest integration branch again and look for any caching problems. Thanks!
              Hide
              skodak Petr Skoda added a comment -

              oh, the line number 191 indicates you are not using my latest version of the patch.

              Show
              skodak Petr Skoda added a comment - oh, the line number 191 indicates you are not using my latest version of the patch.
              Hide
              nebgor Aparup Banerjee added a comment -

              ah confirmed this works for me.

              Please update lib/phpunit/readme.md to reflect adding of composer support and then i guess this could go into integration now (late but i see no risk)

              Show
              nebgor Aparup Banerjee added a comment - ah confirmed this works for me. Please update lib/phpunit/readme.md to reflect adding of composer support and then i guess this could go into integration now (late but i see no risk)
              Hide
              skodak Petr Skoda added a comment -

              oh, I completely forgot we have that readme!

              fixing...

              Show
              skodak Petr Skoda added a comment - oh, I completely forgot we have that readme! fixing...
              Hide
              skodak Petr Skoda added a comment -

              readme updated, thanks

              Show
              skodak Petr Skoda added a comment - readme updated, thanks
              Hide
              nebgor Aparup Banerjee added a comment -

              cool, thanks been integrated. passing this too

              Show
              nebgor Aparup Banerjee added a comment - cool, thanks been integrated. passing this too
              Hide
              nebgor Aparup Banerjee added a comment -

              both phpunit binaries work here.

              the web runner (new to me) is experimental and didn't run fine for me due to very basic db connection failure very likely due to it being incomplete.


              Debug info:

              Warning: mysqli::mysqli() [mysqli.mysqli]: [2002] No such file or directory (trying to connect via unix:///var/mysql/mysql.sock) in /Users/aparup/Sites/i/lib/dml/mysqli_native_moodle_database.php on line 381

              Warning: mysqli::mysqli() [mysqli.mysqli]: (HY000/2002): No such file or directory in /Users/aparup/Sites/i/lib/dml/mysqli_native_moodle_database.php on line 381

              Error code: dbconnectionfailed
              Stack trace: * line 388 of /lib/dml/mysqli_native_moodle_database.php: dml_connection_exception thrown

              • line 344 of /lib/dmllib.php: call to mysqli_native_moodle_database->connect()
              • line 479 of /lib/setup.php: call to setup_DB()
              • line 199 of /lib/phpunit/bootstrap.php: call to require()
              • line 77 of /admin/tool/phpunit/cli/util.php: call to require()

              Notice: Use of undefined constant NO_MOODLE_COOKIES - assumed 'NO_MOODLE_COOKIES' in /Users/aparup/Sites/i/lib/sessionlib.php on line 168

              Notice: Use of undefined constant NO_MOODLE_COOKIES - assumed 'NO_MOODLE_COOKIES' in /Users/aparup/Sites/i/lib/sessionlib.php on line 306

              Notice: Use of undefined constant NO_MOODLE_COOKIES - assumed 'NO_MOODLE_COOKIES' in /Users/aparup/Sites/i/lib/sessionlib.php on line 250

              Show
              nebgor Aparup Banerjee added a comment - both phpunit binaries work here. the web runner (new to me) is experimental and didn't run fine for me due to very basic db connection failure very likely due to it being incomplete. Debug info: Warning: mysqli::mysqli() [mysqli.mysqli] : [2002] No such file or directory (trying to connect via unix:///var/mysql/mysql.sock) in /Users/aparup/Sites/i/lib/dml/mysqli_native_moodle_database.php on line 381 Warning: mysqli::mysqli() [mysqli.mysqli] : (HY000/2002): No such file or directory in /Users/aparup/Sites/i/lib/dml/mysqli_native_moodle_database.php on line 381 Error code: dbconnectionfailed Stack trace: * line 388 of /lib/dml/mysqli_native_moodle_database.php: dml_connection_exception thrown line 344 of /lib/dmllib.php: call to mysqli_native_moodle_database->connect() line 479 of /lib/setup.php: call to setup_DB() line 199 of /lib/phpunit/bootstrap.php: call to require() line 77 of /admin/tool/phpunit/cli/util.php: call to require() Notice: Use of undefined constant NO_MOODLE_COOKIES - assumed 'NO_MOODLE_COOKIES' in /Users/aparup/Sites/i/lib/sessionlib.php on line 168 Notice: Use of undefined constant NO_MOODLE_COOKIES - assumed 'NO_MOODLE_COOKIES' in /Users/aparup/Sites/i/lib/sessionlib.php on line 306 Notice: Use of undefined constant NO_MOODLE_COOKIES - assumed 'NO_MOODLE_COOKIES' in /Users/aparup/Sites/i/lib/sessionlib.php on line 250
              Hide
              skodak Petr Skoda added a comment -

              Interesting, it worked fine for me when I tested it without any problems, I will try the webrunner again and file new issues if necessary.

              Show
              skodak Petr Skoda added a comment - Interesting, it worked fine for me when I tested it without any problems, I will try the webrunner again and file new issues if necessary.
              Hide
              skodak Petr Skoda added a comment -

              The reason might be that webrunner uses different PHP because it runs under your apache account which may have different paths.

              I am afraid we can not do much about that, it is experimental feature used mostly by OU...

              Show
              skodak Petr Skoda added a comment - The reason might be that webrunner uses different PHP because it runs under your apache account which may have different paths. I am afraid we can not do much about that, it is experimental feature used mostly by OU...
              Hide
              skodak Petr Skoda added a comment -

              here is the new issue for NO_MOODLE_COOKIES: MDL-36779

              Show
              skodak Petr Skoda added a comment - here is the new issue for NO_MOODLE_COOKIES: MDL-36779
              Hide
              skodak Petr Skoda added a comment -

              Documented at http://docs.moodle.org/dev/PHPUnit, I am going to blog about it too.

              Show
              skodak Petr Skoda added a comment - Documented at http://docs.moodle.org/dev/PHPUnit , I am going to blog about it too.
              Hide
              poltawski Dan Poltawski added a comment -

              Congratulations! Another bug solved.. only another 7330 to go, thanks for contributing to contributing to 0.8% of all bugs being fixed this week!

              ciao
              Dan

              Show
              poltawski Dan Poltawski added a comment - Congratulations! Another bug solved.. only another 7330 to go, thanks for contributing to contributing to 0.8% of all bugs being fixed this week! ciao Dan
              Hide
              dmonllao David Monllaó added a comment - - edited

              Hi,

              I like this issue I see that phpunit is declared as a 'require' package, composer has the 'require-dev' attribute which is more appropriate for dev/test purposes, if in future Moodle intends to use composer to manage other libraries dependencies (used by Moodle core) this package could be moved to 'require-dev'. The only difference using this attribute instead of 'require' is that composer has to be executed with --dev option (http://getcomposer.org/doc/04-schema.md#require-dev)

              Show
              dmonllao David Monllaó added a comment - - edited Hi, I like this issue I see that phpunit is declared as a 'require' package, composer has the 'require-dev' attribute which is more appropriate for dev/test purposes, if in future Moodle intends to use composer to manage other libraries dependencies (used by Moodle core) this package could be moved to 'require-dev'. The only difference using this attribute instead of 'require' is that composer has to be executed with --dev option ( http://getcomposer.org/doc/04-schema.md#require-dev )
              Hide
              skodak Petr Skoda added a comment -

              Good idea, could you please create a new issue for 2.5dev, I suppose it should not be a problem to change it there.

              Show
              skodak Petr Skoda added a comment - Good idea, could you please create a new issue for 2.5dev, I suppose it should not be a problem to change it there.
              Hide
              nebgor Aparup Banerjee added a comment -

              note: 'require-dev' suggestion is implemented in MDL-36936 and backported via MDL-36817.

              Show
              nebgor Aparup Banerjee added a comment - note: 'require-dev' suggestion is implemented in MDL-36936 and backported via MDL-36817 .

                People

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

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Fix Release Date:
                    3/Dec/12