'Fred', 'score' => 33, 'e-value' => '3.4e-55', ]; $hit->{'linkout_id'} = 'Sarah'; $result = tripal_blast_generate_linkout_link($url_prefix, $hit, $info); $expect = 'Sarah'; $this->assertEquals($expect, $result); // Check with Query paramters. $url_prefix = 'http://fake/url/prefix?me=you&he=her&hit='; $result = tripal_blast_generate_linkout_link($url_prefix, $hit, $info); $expect = 'Sarah'; $this->assertEquals($expect, $result); } /** * Test tripal_blast_generate_linkout_gbrowse(). * * @dataProvider provideBlastHit */ public function testGBrowseLinkout($hit) { // Process HSPs for $info. foreach ($hit->{'Hit_hsps'}->children() as $hsp_xml) { $HSPs[] = (array) $hsp_xml; } // Test with no query parameters. $url_prefix = 'http://fake/url/prefix'; $info = [ 'query_name' => 'Fred', 'score' => 33, 'e-value' => '3.4e-55', 'HSPs' => $HSPs, ]; $hit->{'linkout_id'} = 'Sarah'; $result = tripal_blast_generate_linkout_gbrowse($url_prefix, $hit, $info); $expect = 'Sarah'; $this->assertEquals($expect, $result); } /** * Test tripal_blast_generate_linkout_jbrowse(). * * @dataProvider provideBlastHit */ public function testJBrowseLinkout($hit) { // Proccess the HSPs for $info. foreach ($hit->{'Hit_hsps'}->children() as $hsp_xml) { $HSPs[] = (array) $hsp_xml; } // Test with no query parameters. $url_prefix = 'http://myserver.com/jbrowse/databasica/?tracks=myfavtrack,anoktrack,blast&'; $info = [ 'query_name' => 'Fred', 'score' => 33, 'e-value' => '3.4e-55', 'HSPs' => $HSPs, ]; $hit->{'linkout_id'} = 'Sarah'; $hit->{'hit_name'} = 'Needleman'; $result = tripal_blast_generate_linkout_jbrowse($url_prefix, $hit, $info); $expect = 'Sarah'; $this->assertEquals($expect, $result); } /** * Data Provider */ public function provideBlastHit() { $result = simplexml_load_file( DRUPAL_ROOT .'/'. drupal_get_path('module','blast_ui') .'/tests/test_files/Citrus_sinensis-orange1.1g015632m.blastresults.xml' ); $hit = $result->{'BlastOutput_iterations'}->{'Iteration'}[0]->{'Iteration_hits'}->{'Hit'}; return [[$hit]]; } }