Skip to content
Snippets Groups Projects
Commit 1a6fecfd authored by Chris Sangwin's avatar Chris Sangwin
Browse files

Add in unit tests of validation.

parent a03b5295
No related branches found
No related tags found
No related merge requests found
...@@ -52,7 +52,7 @@ class parsons_block_test extends qtype_stack_testcase { ...@@ -52,7 +52,7 @@ class parsons_block_test extends qtype_stack_testcase {
/** /**
* @covers \qtype_stack\stack_cas_castext2_parsons * @covers \qtype_stack\stack_cas_castext2_parsons
*/ */
public function test_get_all_raw_casstrings() { public function test_basic_parsons_block() {
$raw = '[[parsons]]{' . $raw = '[[parsons]]{' .
'"1":"Assume that \\(n\\) is odd.",' . '"1":"Assume that \\(n\\) is odd.",' .
'"2":"Then there exists an \\(m\\in\\mathbb{Z}\\) such that \\(n=2m+1\\).", ' . '"2":"Then there exists an \\(m\\in\\mathbb{Z}\\) such that \\(n=2m+1\\).", ' .
...@@ -67,4 +67,22 @@ class parsons_block_test extends qtype_stack_testcase { ...@@ -67,4 +67,22 @@ class parsons_block_test extends qtype_stack_testcase {
$this->assertEquals($expected, $at1->get_rendered()); $this->assertEquals($expected, $at1->get_rendered());
} }
/**
* @covers \qtype_stack\stack_cas_castext2_parsons
*/
public function test_pasrons_validate_length() {
$raw = '[[parsons length="a"]]{' .
'"1":"Assume that \\(n\\) is odd.",' .
'"2":"Then there exists an \\(m\\in\\mathbb{Z}\\) such that \\(n=2m+1\\).", ' .
'"3":"\\[ n^2 = (2m+1)^2 = 2(2m^2+2m)+1.\\]", ' .
'"4":"Define \\(M=2m^2+2m\\in\\mathbb{Z}\\) then \\(n^2=2M+1\\).", ' .
'} [[/parsons]]';
$expected = '<div style="width:100%;height:480px;" id="stack-iframe-holder-1"></div>';
$at1 = castext2_evaluatable::make_from_source($raw, 'test-case');
$session = new stack_cas_session2([$at1]);
$this->assertFalse($at1->get_valid());
$this->assertEquals(stack_string('stackBlock_parsons_length_num'), $at1->get_errors());
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment