コード例 #1
0
 /**
  * Test get_strings
  */
 public function test_get_strings()
 {
     $this->resetAfterTest(true);
     $service = new stdClass();
     $service->name = 'Dummy Service';
     $service->id = 12;
     $returnedstrings = core_external::get_strings(array(array('stringid' => 'addservice', 'component' => 'webservice', 'stringparams' => array(array('name' => 'name', 'value' => $service->name), array('name' => 'id', 'value' => $service->id))), array('stringid' => 'addaservice', 'component' => 'webservice')));
     foreach ($returnedstrings as $returnedstring) {
         $corestring = get_string($returnedstring['stringid'], $returnedstring['component'], $service);
         $this->assertEquals($corestring, $returnedstring['string']);
     }
 }
コード例 #2
0
 /**
  * Test get_strings
  */
 public function test_get_strings()
 {
     $this->resetAfterTest(true);
     $service = new stdClass();
     $service->name = 'Dummy Service';
     $service->id = 12;
     $returnedstrings = core_external::get_strings(array(array('stringid' => 'addservice', 'component' => 'webservice', 'stringparams' => array(array('name' => 'name', 'value' => $service->name), array('name' => 'id', 'value' => $service->id))), array('stringid' => 'addaservice', 'component' => 'webservice')));
     // We need to execute the return values cleaning process to simulate the web service server.
     $returnedstrings = external_api::clean_returnvalue(core_external::get_strings_returns(), $returnedstrings);
     foreach ($returnedstrings as $returnedstring) {
         $corestring = get_string($returnedstring['stringid'], $returnedstring['component'], $service);
         $this->assertEquals($corestring, $returnedstring['string']);
     }
 }
コード例 #3
0
ファイル: external_test.php プロジェクト: aleph-n/lms.aaenl
 /**
  * Test get_strings with arguments containing HTML.
  */
 public function test_get_strings_with_args_containing_html()
 {
     $result = core_external::get_strings([['stringid' => 'added', 'stringparams' => [['value' => '<strong>Test</strong>']]], ['stringid' => 'loggedinas', 'stringparams' => [['value' => '<strong>Test</strong>']]]]);
     $actual = external_api::clean_returnvalue(core_external::get_strings_returns(), $result);
     $this->assertSame(get_string('added', 'moodle', '<strong>Test</strong>'), $actual[0]['string']);
     $this->assertSame(get_string('loggedinas', 'moodle', '<strong>Test</strong>'), $actual[1]['string']);
 }