-
Notifications
You must be signed in to change notification settings - Fork 5
Edit test system En
In this page, we show how this test system works and how you should edit. Before reading this manual, you should understand how phpunit works. Below page will help you. http://phpunit.de/manual/3.7/en/automating-tests.html
Langrid-php-library-master //Home Directory of Multilingual Studio
├...
└test //Home Directory of test system
├...
├task.sh //Shell file for starting test.You can add e-mail address for getting result.
├AllTests.php //Used in task.sh as parameter of phpunit, and call whole testsytem.
├test_settings.php //Setting of test system such as Language Grid ID and password is written.
├resource
├...
├KyotoLangridResourceTest.php //Implement test code for each service type
└service_list.php //Write parameters for each service
-
"task.sh" run When "task.sh" is run, phpunit is called with AllTests.php as parameter.
-
"AllTests.php" is called as a parameter of phpunit. And in "AllTests.php", three files -- "LocalServiceAllTests.php","BridgeAllTests.php" and "KyotoLangridResourceTest.php" are called as suite.
In "LocalServiceAllTests.php", necessary functions in local server such as deploying dictionary is tested. In "BridgeAllTests.php", status of database is checked. Writer of this document(Nishimura) is not sure about these two files.(14/01/06) In "KyotoLangridResourceTest.php", test of each service is called.
-
Test of each service is started. At first, "KyotoLangridResourceTest.php" reads "service_list.php". In "service_list.php", parameters for test of each service. After that, test of each service is run. Content of each service type is written in "KyotoLangridResourceTest.php".
-
Result is send by e-mail Test result is send to outside with postfix. Now we use sendmail.kuins.net which is the smtp server provided by KUINS. We need ECS-ID, ID and Password for KUINS, to use sendmail.kuins.net. In sparrow server, we use Nishimura's ECS-ID temporarily.
If you want to add/edit service to test system, please edit "service_list.php" If you want to implement test code for a service type, please edit "KyotoLangridResourceTest.php".
In "service_list.php", write word data or parallel text for doing test. Each service type need different parameter. You can find which parameter is needed in first line of each service type.
For example, about "ParallelText" service type, you can find below code in "service_list.php".
<?php
// $endpoint, $headLang, $targetLang, $text, $mat(デフォルト MatchingMethod::COMPLETE)
'ParallelText' => array(
"kyoto1.langrid:KanagawaPrefectureSchoolEntranceParalleltext" => array( // Service ID
"http://langrid.org/service_manager/wsdl/kyoto1.langrid:KanagawaPrefectureSchoolEntranceParalleltext", // WSDL
"en", // Original language
"ja", // Target language
"Approximate school fees", // Example of parallel text in original language
"参考", //Example of parallel text in target language
MatchingMethod::COMPLETE, // Matching Method
),
)You can get information of each service in "Language Grid Service Manager"(http://langrid.org/service_manager/overview/) .
You can find summary of services in menu --> View of Language Grid --> Language Services
You will know which language is supported by each service. And you also can know service ID and WSDL.
##KyotoLangridResourceTest.php Implement how to test each service type. For example, test of "ParrallelText" service type is implemented as below.
<?php
//$endpoint: endpoint URL of service
//$headLang: original language
//$targetLang: target language
//$text: query for searching parallel text
//$answer: desirable result of the searching
//$mat: matching method. Default is "PREFIX"
public function testParallelTextResource($endpoint, $headLang, $targetLang, $text, $answer, $mat = MatchingMethod::PREFIX)
{
$client = ClientFactory::createParallelTextClient($endpoint); //Make instance of service client with endpoint URL of target service
$result = $client->search(
Language::get($headLang),
Language::get($targetLang),
$text,
$mat
); //Do search and get result.
$this->assertEquals($answer,$result[0]->target); // We get result in the form of array. However, we must verify whether result is desirable or not. So, extract data from appropriate part of array (in this case, "$result[0]->target") and compare result with desirable one. If they are same, return true. Otherwise, return false.
}