182 lines
		
	
	
		
			No EOL
		
	
	
		
			6.3 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			182 lines
		
	
	
		
			No EOL
		
	
	
		
			6.3 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
namespace local_treestudyplan;
 | 
						|
use \local_treestudyplan\local\aggregators\bistate_aggregator;
 | 
						|
 | 
						|
 class bistate_aggregator_test extends \basic_testcase {
 | 
						|
 | 
						|
    private function goalaggregation_test($configstr, $outcome, $completions,$required){
 | 
						|
        $ag = new bistate_aggregator($configstr);
 | 
						|
        // test aggregation with the required data
 | 
						|
        $result = $ag->aggregate_binary_goals($completions,$required);
 | 
						|
        // assert if the test is succesful
 | 
						|
        $this->assertEquals(completion::label($outcome),completion::label($result));
 | 
						|
    }
 | 
						|
 | 
						|
 | 
						|
    private function junctionaggregation_test($configstr, $outcome, $completions){
 | 
						|
        $ag = new bistate_aggregator($configstr);
 | 
						|
        // test aggregation with the minimum required data 
 | 
						|
        $result = $ag->aggregate_junction($completions);
 | 
						|
        // assert if the test is succesful
 | 
						|
        $this->assertEquals(completion::label($outcome),completion::label($result));
 | 
						|
    }
 | 
						|
 | 
						|
 | 
						|
    public function test_goalaggregation_0() {
 | 
						|
        $this->goalaggregation_test(
 | 
						|
            '{"thresh_excellent":100,"thresh_good":85,"thresh_completed":66,"thresh_progress":25,"use_failed":true,"accept_pending_as_submitted":true}',
 | 
						|
            completion::INCOMPLETE,
 | 
						|
            [
 | 
						|
 | 
						|
            ],
 | 
						|
            [],
 | 
						|
        );
 | 
						|
    }
 | 
						|
 | 
						|
    public function test_goalaggregation_1() {
 | 
						|
        $this->goalaggregation_test(
 | 
						|
            '{"thresh_excellent":100,"thresh_good":85,"thresh_completed":66,"thresh_progress":25,"use_failed":true,"accept_pending_as_submitted":true}',
 | 
						|
            completion::FAILED,
 | 
						|
            [ // completions
 | 
						|
                completion::FAILED,
 | 
						|
                completion::FAILED,
 | 
						|
                completion::FAILED,
 | 
						|
                completion::FAILED,
 | 
						|
                completion::FAILED,
 | 
						|
            ],
 | 
						|
            [] // required
 | 
						|
        );
 | 
						|
    }
 | 
						|
 | 
						|
    public function test_goalaggregation_2() {
 | 
						|
        $this->goalaggregation_test(
 | 
						|
            '{"thresh_excellent":100,"thresh_good":85,"thresh_completed":66,"thresh_progress":25,"use_failed":true,"accept_pending_as_submitted":true}',
 | 
						|
            completion::EXCELLENT,
 | 
						|
            [
 | 
						|
                completion::COMPLETED,
 | 
						|
                completion::COMPLETED,
 | 
						|
                completion::COMPLETED,
 | 
						|
                completion::COMPLETED,
 | 
						|
                completion::COMPLETED,
 | 
						|
            ],
 | 
						|
            [],
 | 
						|
        );
 | 
						|
    }
 | 
						|
 | 
						|
    public function test_goalaggregation_3() {
 | 
						|
        $this->goalaggregation_test(
 | 
						|
            '{"thresh_excellent":100,"thresh_good":85,"thresh_completed":66,"thresh_progress":25,"use_failed":true,"accept_pending_as_submitted":true}',
 | 
						|
            completion::INCOMPLETE,
 | 
						|
            [
 | 
						|
                completion::INCOMPLETE,
 | 
						|
                completion::INCOMPLETE,
 | 
						|
                completion::INCOMPLETE,
 | 
						|
                completion::INCOMPLETE,
 | 
						|
                completion::INCOMPLETE,
 | 
						|
            ],
 | 
						|
            [],
 | 
						|
        );
 | 
						|
    }
 | 
						|
 | 
						|
    public function test_goalaggregation_4() {
 | 
						|
        $this->goalaggregation_test(
 | 
						|
            '{"thresh_excellent":100,"thresh_good":85,"thresh_completed":66,"thresh_progress":25,"use_failed":true,"accept_pending_as_submitted":true}',
 | 
						|
            completion::PROGRESS,
 | 
						|
            [
 | 
						|
                completion::COMPLETED,
 | 
						|
                completion::COMPLETED,
 | 
						|
                completion::COMPLETED,
 | 
						|
                completion::PROGRESS,
 | 
						|
                completion::PROGRESS,
 | 
						|
            ],
 | 
						|
            [],
 | 
						|
        );
 | 
						|
    }
 | 
						|
 | 
						|
    public function test_goalaggregation_5() {
 | 
						|
        $this->goalaggregation_test(
 | 
						|
            '{"thresh_excellent":100,"thresh_good":85,"thresh_completed":66,"thresh_progress":25,"use_failed":true,"accept_pending_as_submitted":true}',
 | 
						|
            completion::COMPLETED,
 | 
						|
            [
 | 
						|
                completion::COMPLETED,
 | 
						|
                completion::COMPLETED,
 | 
						|
                completion::COMPLETED,
 | 
						|
                completion::COMPLETED,
 | 
						|
                completion::PROGRESS,
 | 
						|
            ],
 | 
						|
            [],
 | 
						|
        );
 | 
						|
    }
 | 
						|
 | 
						|
    public function test_goalaggregation_6() {
 | 
						|
        $this->goalaggregation_test(
 | 
						|
            '{"thresh_excellent":100,"thresh_good":85,"thresh_completed":66,"thresh_progress":25,"use_failed":true,"accept_pending_as_submitted":true}',
 | 
						|
            completion::PROGRESS,
 | 
						|
            [
 | 
						|
                completion::PROGRESS,
 | 
						|
                completion::PROGRESS,
 | 
						|
                completion::PROGRESS,
 | 
						|
                completion::PROGRESS,
 | 
						|
                completion::INCOMPLETE,
 | 
						|
                completion::INCOMPLETE,
 | 
						|
            ],
 | 
						|
            [],
 | 
						|
        );
 | 
						|
    }
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    public function test_junctionaggregation_0() {
 | 
						|
        $this->junctionaggregation_test(
 | 
						|
            '{"thresh_excellent":100,"thresh_good":85,"thresh_completed":66,"thresh_progress":25,"use_failed":true,"accept_pending_as_submitted":true}',
 | 
						|
            completion::FAILED,
 | 
						|
            [
 | 
						|
                completion::FAILED,
 | 
						|
                completion::FAILED,
 | 
						|
                completion::FAILED,
 | 
						|
                completion::FAILED,
 | 
						|
            ],
 | 
						|
        );
 | 
						|
    }
 | 
						|
 | 
						|
    public function test_junctionaggregation_1() {
 | 
						|
        $this->junctionaggregation_test(
 | 
						|
            '{"thresh_excellent":100,"thresh_good":85,"thresh_completed":66,"thresh_progress":25,"use_failed":true,"accept_pending_as_submitted":true}',
 | 
						|
            completion::INCOMPLETE,
 | 
						|
            [
 | 
						|
                completion::INCOMPLETE,
 | 
						|
                completion::INCOMPLETE,
 | 
						|
                completion::INCOMPLETE,
 | 
						|
                completion::INCOMPLETE,
 | 
						|
            ],
 | 
						|
        );
 | 
						|
    }
 | 
						|
 | 
						|
    public function test_junctionaggregation_2() {
 | 
						|
        $this->junctionaggregation_test(
 | 
						|
            '{"thresh_excellent":100,"thresh_good":85,"thresh_completed":66,"thresh_progress":25,"use_failed":true,"accept_pending_as_submitted":true}',
 | 
						|
            completion::FAILED,
 | 
						|
            [
 | 
						|
                completion::FAILED,
 | 
						|
                completion::INCOMPLETE,
 | 
						|
                completion::INCOMPLETE,
 | 
						|
                completion::INCOMPLETE,
 | 
						|
            ],
 | 
						|
        );
 | 
						|
    }
 | 
						|
 | 
						|
 | 
						|
    public function test_junctionaggregation_3() {
 | 
						|
        $this->junctionaggregation_test(
 | 
						|
            '{"thresh_excellent":100,"thresh_good":85,"thresh_completed":66,"thresh_progress":25,"use_failed":true,"accept_pending_as_submitted":true}',
 | 
						|
            completion::PROGRESS,
 | 
						|
            [
 | 
						|
                completion::PROGRESS,
 | 
						|
                completion::INCOMPLETE,
 | 
						|
                completion::INCOMPLETE,
 | 
						|
                completion::INCOMPLETE,
 | 
						|
            ],
 | 
						|
        );
 | 
						|
    }
 | 
						|
 | 
						|
} |