/** * Test getIdByName() * * @covers ::getIdByName * @test * * @return void */ public function testGetIdByNameMakesGetRequest() { // Test values $getResponse = array('projects' => array(array('id' => 5, 'name' => 'Project 5'))); // Create the used mock objects $client = $this->getMockBuilder('Redmine\\Client')->disableOriginalConstructor()->getMock(); $client->expects($this->once())->method('get')->with($this->stringStartsWith('/projects.json'))->willReturn($getResponse); // Create the object under test $api = new Project($client); // Perform the tests $this->assertFalse($api->getIdByName('Project 1')); $this->assertSame(5, $api->getIdByName('Project 5')); }