Skip to content

Commit

Permalink
feat: Updated tests/Snps/ResourcesTest.php
Browse files Browse the repository at this point in the history
  • Loading branch information
sweep-ai[bot] committed Mar 10, 2024
1 parent 9f16ca7 commit 55aa9cb
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions tests/Snps/ResourcesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ public function testGetAssemblyMappingData(): void
return $this->resource->getAssemblyMappingData("NCBI36", "GRCh37");
};

$assembly_mapping_data = ($this->downloads_enabled) ?
$this->resource->getAssemblyMappingData("NCBI36", "GRCh37") :
$assembly_mapping_data = $this->downloads_enabled ?
$this->resource->getAssemblyMappingData(assembly: "NCBI36", target: "GRCh37") :
$f();

$this->assertCount(25, $assembly_mapping_data);
Expand Down Expand Up @@ -103,7 +103,7 @@ protected function _generateTestGsaResources(): void
}

$mockResponse = new Response(200, [], $s);
$httpClient = $this->createMockHttpClient([$mockResponse], true);
$httpClient = $this->createMockHttpClient(responses: [$mockResponse], mockDownload: true);
$this->resource->setHttpClient($httpClient);
$this->resource->getGsaRsid();

Expand Down Expand Up @@ -147,7 +147,7 @@ public function testGetAllResources()
$mock = $this->getMockBuilder(EnsemblRestClient::class)
->getMock();
$mock->method("perform_rest_action")
->willReturnOnConsecutiveCalls(...array_fill(0, 6, $effects));
->willReturnOnConsecutiveCalls(...array_fill(start_index: 0, count: 6, value: $effects));

$this->resource->setRestClient($mock);
return $this->resource->getAllResources();
Expand All @@ -164,7 +164,7 @@ protected function _generate_test_chip_clusters()
$responseContent = "1:1\tc1\n" . str_repeat("1:1\tc1\n", 2135213);

$mockResponse = new Response(200, [], $responseContent);
$httpClient = $this->createMockHttpClient([$mockResponse], true);
$httpClient = $this->createMockHttpClient(responses: [$mockResponse], mockDownload: true);
$this->resource->setHttpClient($httpClient);

return $this->resource->get_chip_clusters();
Expand Down Expand Up @@ -225,7 +225,8 @@ protected function testDownloadExampleDatasets()
public function testGetPathsReferenceSequencesInvalidAssembly()
{
[$assembly, $chroms, $urls, $paths] = $this->resource->getPathsReferenceSequences(
assembly: "36"
assembly: "36",
chroms: []
);

$chroms = $chroms;
Expand Down Expand Up @@ -263,8 +264,10 @@ protected function runCreateReferenceSequencesTest(string $assemblyExpect, strin
{
$f = function () use ($assemblyExpect, $urlExpect) {
[$assembly, $chroms, $urls, $paths] = $this->resource->getPathsReferenceSequences(
assembly: $assemblyExpect,
chroms: ["MT"]
assembly: $assemblyExpect,
chroms: ["MT"],
urls: [],
paths: []
);
$seqs = $this->resource->create_reference_sequences($assembly, $chroms, $urls, $paths);

Expand Down Expand Up @@ -316,8 +319,10 @@ public function testCreateReferenceSequencesInvalidPath()
{
$this->runReferenceSequencesTest(function () {
list($assembly, $chroms, $urls, $paths) = $this->resource->getPathsReferenceSequences(
assembly: "GRCh37",
chroms: ["MT"]
assembly: "GRCh37",
chroms: ["MT"],
urls: [],
paths: []
);
$paths[0] = "";
$seqs = $this->resource->create_reference_sequences($assembly, $chroms, $urls, $paths);
Expand Down Expand Up @@ -374,6 +379,7 @@ public function testGetReferenceSequences()
{
$this->runReferenceSequencesTest(function () {
$seqs = $this->resource->getReferenceSequences(
assembly: "GRCh37",
chroms: ['MT']
);
$this->assertCount(1, $seqs);
Expand Down Expand Up @@ -434,9 +440,9 @@ public function testGetReferenceSequencesInvalidAssembly()
public function testGetReferenceSequencesChromNotAvailable()
{
$this->runReferenceSequencesTest(function () {
$this->resource->getReferenceSequences(chroms: ['MT']);
unset($this->resource->getReferenceSequences()['GRCh37']['MT']);
$seqs = $this->resource->getReferenceSequences(chroms: ['MT']);
$this->resource->getReferenceSequences(assembly: "GRCh37", chroms: ['MT']);
unset($this->resource->getReferenceSequences(assembly: "GRCh37")['MT']);
$seqs = $this->resource->getReferenceSequences(assembly: "GRCh37", chroms: ['MT']);
$this->assertCount(1, $seqs);
$this->assertEquals(
$seqs['MT']->__toString(),
Expand Down

0 comments on commit 55aa9cb

Please sign in to comment.