Title: minimum score error
Last modified: August 22, 2016

---

# minimum score error

 *  ResolvedPlugin Contributor [osfans](https://wordpress.org/support/users/osfans/)
 * (@osfans)
 * [11 years ago](https://wordpress.org/support/topic/minimum-score-error/)
 * > Scale value 8 must be within range from -8 to 8
   >  Scale value 8 must be within
   > range from -2 to 8 Scale value -9 must be within range from -4 to 8
 * The minimum scores should be -8,-8,-9. I have several scores below 0.
 * BTW, how to get [the InvalidArgumentException](https://github.com/garex/wp-testing/blob/develop/src/Model/Scale.php#L56)
   error message?
    I get the error message by “echo”.
 * [https://wordpress.org/plugins/wp-testing/](https://wordpress.org/plugins/wp-testing/)

Viewing 15 replies - 1 through 15 (of 27 total)

1 [2](https://wordpress.org/support/topic/minimum-score-error/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/minimum-score-error/page/2/?output_format=md)

 *  Plugin Contributor [ustimenko](https://wordpress.org/support/users/ustimenko/)
 * (@ustimenko)
 * [11 years ago](https://wordpress.org/support/topic/minimum-score-error/#post-5885990)
 * 1. Pls provide your concrete values how to repeat it.
 * 2.
 * > how to get the InvalidArgumentException
 * Only from bad code. Not from UI I think.
 * 3.
 * > I get the error message by “echo”.
 * Where and how? Pls describe more details.
 *  Plugin Contributor [osfans](https://wordpress.org/support/users/osfans/)
 * (@osfans)
 * [11 years ago](https://wordpress.org/support/topic/minimum-score-error/#post-5885991)
 * It seems to be caused by SQL in [buildScalesWithRange()](https://github.com/garex/wp-testing/blob/develop/src/Model/Test.php#L93)
 * 1. There are 8 questions, 4 answers(ABCD) and 3 scales(XYZ).
    1. X: 2 1 -1 -2
    2. X: 2 1 -1 -2
    3. X: 2 1 -1 -2
    4. X: 2 1 -1 -2
    5. Y: -4 -2 0 2
    6. Y: -1 0 1 2
    7. Y: -4 -2 2 4
    8. Z: -8 -4 4 8
 * So,
    sum(min(X))=-8 sum(min(Y))=-9 sum(min(Z))=-8
 * 3. My debug code:
 *     ```
       public function setValue($value)
           {
               $value = $this->filterValue($value, 'value');
               echo('Scale value ' . $value . ' must be within range from ' . $this->minimum . ' to ' . $this->maximum."\n");
               if (!($this->minimum <= $value) || !($value <= $this->maximum)) {
                   throw new InvalidArgumentException('Scale value ' . $value . ' must be within range from ' . $this->minimum . ' to ' . $this->maximum);
               }
               $this->value = $value;
               return $this;
           }
       ```
   
 *  Plugin Contributor [osfans](https://wordpress.org/support/users/osfans/)
 * (@osfans)
 * [11 years ago](https://wordpress.org/support/topic/minimum-score-error/#post-5885995)
 * I think the minimum should be the sum of every min score, not the min of all 
   scores, since the value here is the sum score of a scale.
 * I comment out these lines and the result page appears.
 *     ```
       if (!($this->minimum <= $value) || !($value <= $this->maximum)) {
           throw new InvalidArgumentException('Scale value ' . $value . ' must be within range from ' . $this->minimum . ' to ' . $this->maximum);
       }
       ```
   
 *  Plugin Contributor [ustimenko](https://wordpress.org/support/users/ustimenko/)
 * (@ustimenko)
 * [11 years ago](https://wordpress.org/support/topic/minimum-score-error/#post-5886000)
 * Yes, I think it’s a bug here with negative scores.
 * Can you provide example for test with 1 scale 2 questions and 1 answer in each?
 * Also you can try to fix it in PR. Main here will be not just fix, but also provide
   a new test case.
 *  Plugin Contributor [osfans](https://wordpress.org/support/users/osfans/)
 * (@osfans)
 * [11 years ago](https://wordpress.org/support/topic/minimum-score-error/#post-5886003)
 * Here’s a simple test case (1 scale(X), 2 questions(Q1 Q2) and 2 answers(Y N))
 * > Q1:1 -1
   >  Q2:1 -1
 * When I choose N for Q1 and Q2, exception happens in setValue and no result shows.
 * > Scale value -2 must be within range from -1 to 2
 *  Plugin Contributor [osfans](https://wordpress.org/support/users/osfans/)
 * (@osfans)
 * [11 years ago](https://wordpress.org/support/topic/minimum-score-error/#post-5886005)
 * I’m not sure of the meaning of PR. So what does PR mean?
 *  Plugin Contributor [ustimenko](https://wordpress.org/support/users/ustimenko/)
 * (@ustimenko)
 * [11 years ago](https://wordpress.org/support/topic/minimum-score-error/#post-5886009)
 * It’s a pull-request at github.
 * Do you know any programming language? python/ruby? If yes, then you should know
   PHP — it’s no so complex.
 * You can try to fix it and send pull request through github.
 * But by fix I understand not just fix in code but also adding test (in phpunit)
   to prove that fix working.
 * You can browse commits to see how it done usually.
 *  Plugin Contributor [osfans](https://wordpress.org/support/users/osfans/)
 * (@osfans)
 * [11 years ago](https://wordpress.org/support/topic/minimum-score-error/#post-5886029)
 * But I don’t know how to run phpunit. Error happens:
 * > PHP Warning: require_once(/home/osfans/prj/wp-testing/tests/phpunit/../../vendor/
   > autoload_52.php): failed to open stream: No such file or directory in /home/
   > osfans/prj/wp-testing/tests/phpunit/bootstrap.php on line 2
 * I fix the bug as follows.
 *     ```
       diff --git a/db/sql/scale-max-right.sql b/db/sql/scale-max-right.sql
       index 451aba0..6a9e197 100644
       --- a/db/sql/scale-max-right.sql
       +++ b/db/sql/scale-max-right.sql
       @@ -1,6 +1,6 @@
        SELECT
               scale_id,
       -       MIN(minimum_in_row) AS minimum_in_column,
       +       SUM(minimum_in_row) AS minimum_in_column,
               SUM(maximum_in_row) AS maximum_in_column,
               SUM(sum_in_row)     AS sum_in_column
        FROM (
       diff --git a/src/Model/Test.php b/src/Model/Test.php
       index 7777fa4..943aa95 100644
       --- a/src/Model/Test.php
       +++ b/src/Model/Test.php
       @@ -93,7 +93,7 @@ class WpTesting_Model_Test extends WpTesting_Model_AbstractModel
                $result       = $db->translatedQuery('
                    SELECT
                        scale_id,
       -                MIN(minimum_in_row) AS minimum_in_column,
       +                SUM(minimum_in_row) AS minimum_in_column,
                        SUM(maximum_in_row) AS maximum_in_column,
                        SUM(sum_in_row)     AS sum_in_column
                    FROM (
       ```
   
 *  Plugin Contributor [ustimenko](https://wordpress.org/support/users/ustimenko/)
 * (@ustimenko)
 * [11 years ago](https://wordpress.org/support/topic/minimum-score-error/#post-5886035)
 * Locally run `composer update` — it will install all that needs. Then also look
   at some config to have locally DB available.
 * Yes, I think it’s correct to use SUM there [https://github.com/garex/wp-testing/blob/develop/src/Model/Test.php#L96](https://github.com/garex/wp-testing/blob/develop/src/Model/Test.php#L96)
 * Try to run after composer just `vendor/bin/phpunit52`
 * Btw, on which OS do you working now? It’s all tools currently for linux.
 *  Plugin Contributor [osfans](https://wordpress.org/support/users/osfans/)
 * (@osfans)
 * [11 years ago](https://wordpress.org/support/topic/minimum-score-error/#post-5886038)
 * OK, I’ll have a try.
    I use arch linux.
 *  Plugin Contributor [ustimenko](https://wordpress.org/support/users/ustimenko/)
 * (@ustimenko)
 * [11 years ago](https://wordpress.org/support/topic/minimum-score-error/#post-5886040)
 * Good. You can see [https://github.com/garex/wp-testing/blob/develop/tests/integration-environment/create.sh](https://github.com/garex/wp-testing/blob/develop/tests/integration-environment/create.sh)
   as an example of environment creation.
 *  Plugin Contributor [osfans](https://wordpress.org/support/users/osfans/)
 * (@osfans)
 * [11 years ago](https://wordpress.org/support/topic/minimum-score-error/#post-5886144)
 * Sorry, I have to give up phpunit because of my network.
 * >  Failed: [Symfony\Component\Process\Exception\ProcessTimedOutException] The
   > process “git clone –no-checkout ‘git://github.com/garex/phpunit’ ‘/home/kyle/
   > prj/wp-testing/vendor/phpunit/phpunit-php52’ && cd ‘/home/kyle/prj/wp-testing/
   > vendor/phpunit/phpunit-php52’ && git remote add composer ‘git://github.com/
   > garex/phpunit’ && git fetch composer” exceeded the timeout of 300 seconds.
 *  Plugin Contributor [ustimenko](https://wordpress.org/support/users/ustimenko/)
 * (@ustimenko)
 * [11 years ago](https://wordpress.org/support/topic/minimum-score-error/#post-5886146)
 * osfans, it’s sad (( May be it’s a problems on github’s side?
 *  Plugin Contributor [osfans](https://wordpress.org/support/users/osfans/)
 * (@osfans)
 * [11 years ago](https://wordpress.org/support/topic/minimum-score-error/#post-5886166)
 * I’ve downloaded the repo with proxy.
 * But there’s an error and I can find the function in vendor/phpunit/phpunit-php52/
   PHPUnit/Util/Filesystem.php
 * > kyle@~/prj/wp/wp-testing % phpunit
   >  PHP Fatal error: Call to undefined method
   > PHPUnit_Util_Filesystem::fileExistsInIncludePath() in /home/kyle/prj/wp/wp-
   > testing/vendor/phpunit/phpunit-php52/PHPUnit/Autoload.php on line 209
 *  Plugin Contributor [ustimenko](https://wordpress.org/support/users/ustimenko/)
 * (@ustimenko)
 * [11 years ago](https://wordpress.org/support/topic/minimum-score-error/#post-5886167)
 * Yes, because it should be run with php5.2 compatible phpunit.
 * I’ve forked it and fixed for php 5.2.
 * See `vendor/bin/phpunit52`

Viewing 15 replies - 1 through 15 (of 27 total)

1 [2](https://wordpress.org/support/topic/minimum-score-error/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/minimum-score-error/page/2/?output_format=md)

The topic ‘minimum score error’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/wp-testing_fff0ea.svg)
 * [Psychological tests & quizzes](https://wordpress.org/plugins/wp-testing/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-testing/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-testing/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-testing/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-testing/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-testing/reviews/)

## Tags

 * [wp-testing-bug](https://wordpress.org/support/topic-tag/wp-testing-bug/)

 * 27 replies
 * 2 participants
 * Last reply from: [ustimenko](https://wordpress.org/support/users/ustimenko/)
 * Last activity: [11 years ago](https://wordpress.org/support/topic/minimum-score-error/page/2/#post-5886270)
 * Status: resolved