Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHPUnit test error #12

Open
suankan opened this issue Nov 29, 2016 · 1 comment
Open

PHPUnit test error #12

suankan opened this issue Nov 29, 2016 · 1 comment

Comments

@suankan
Copy link

suankan commented Nov 29, 2016

I've found this error during unit tests execution:

There was 1 error:

1) block_mhaairs_gradebookservice_update_item_testcase::test_update_grade_update_item
dml_read_exception: Error reading from database (ERROR:  invalid input syntax for integer: ""
SELECT * FROM phpu_grade_items WHERE  itemtype = $1 AND itemmodule = $2 AND iteminstance = $3 AND courseid = $4 AND itemnumber = $5 
[array (
  0 => 'manual',
  1 => 'mhaairs',
  2 => '',
  3 => '121000',
  4 => '0',
)])

/var/www/vhost_swsi/swsi/lib/dml/moodle_database.php:474
/var/www/vhost_swsi/swsi/lib/dml/pgsql_native_moodle_database.php:244
/var/www/vhost_swsi/swsi/lib/dml/pgsql_native_moodle_database.php:753
/var/www/vhost_swsi/swsi/lib/dml/moodle_database.php:1250
/var/www/vhost_swsi/swsi/lib/grade/grade_object.php:220
/var/www/vhost_swsi/swsi/lib/grade/grade_object.php:160
/var/www/vhost_swsi/swsi/lib/grade/grade_item.php:354
/var/www/vhost_swsi/swsi/blocks/mhaairs/tests/gradebookservice_update_item_test.php:222
/var/www/vhost_swsi/swsi/lib/phpunit/classes/advanced_testcase.php:80

To re-run:
 ./vendor/bin/phpunit block_mhaairs_gradebookservice_update_item_testcase blocks/mhaairs/tests/gradebookservice_update_item_test.php

FAILURES!
Tests: 3, Assertions: 30, Errors: 1.

As a quick fix I just added casting strings to integers in one place. Please see attached patch.

@suankan
Copy link
Author

suankan commented Nov 29, 2016

I attached the patch, but can't see it anywhere!

Here it is:

Index: tests/gradebookservice_update_item_test.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- tests/gradebookservice_update_item_test.php	(date 1478464381000)
+++ tests/gradebookservice_update_item_test.php	(revision )
@@ -215,9 +215,9 @@
             $giparams = array(
                 'itemtype' => 'manual',
                 'itemmodule' => 'mhaairs',
-                'iteminstance' => $case->iteminstance,
-                'courseid' => $this->course->id,
-                'itemnumber' => $case->itemnumber,
+                'iteminstance' => (int)$case->iteminstance,
+                'courseid' => (int)$this->course->id,
+                'itemnumber' => (int)$case->itemnumber,
             );
             $gitem = grade_item::fetch($giparams);
 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant