public function testActivityUrl() { $mock = $this->getMockBuilder('EndomondoApi')->setMethods(array('getAuth', 'get', 'setAuth'))->getMock(); $endomondo = new Endomondo("", "", "UTC", array($this, 'myEcho'), $mock); // not connected $mock->expects($this->at(0))->method('getAuth')->with()->willReturn(null); $this->assertNull($endomondo->activityUrl(11111111)); //connected, URL is based on userId $mock->expects($this->any())->method('setAuth'); $mock->expects($this->any())->method('getAuth')->willReturn("AUTH TOKEN"); $mock->expects($this->at(1))->method('get')->willReturn('{ "data": {"id": 9999999} }'); $endomondo->isConnected(); $this->assertEquals("https://www.endomondo.com/users/9999999/workouts/11111111", $endomondo->activityUrl(11111111)); }