. * */ namespace OCA\News\External; use \OCA\AppFramework\Http\JSONResponse; use \OCA\AppFramework\Utility\ControllerTestUtility; require_once(__DIR__ . "/../../classloader.php"); class NewsAPITest extends ControllerTestUtility { private $api; private $request; private $newsAPI; protected function setUp() { $this->api = $this->getMockBuilder( '\OCA\AppFramework\Core\API') ->disableOriginalConstructor() ->getMock(); $this->request = $this->getMockBuilder( '\OCA\AppFramework\Http\Request') ->disableOriginalConstructor() ->getMock(); $this->newsAPI = new NewsAPI($this->api, $this->request); } private function assertDefaultAnnotations($methodName){ $annotations = array('IsAdminExemption', 'IsSubAdminExemption', 'Ajax'); $this->assertAnnotations($this->newsAPI, $methodName, $annotations); } public function testVersionAnnotations(){ $this->assertDefaultAnnotations('version'); } public function testGetVersion(){ $this->api->expects($this->once()) ->method('getAppValue') ->with($this->equalTo('installed_version')) ->will($this->returnValue('1.0')); $response = $this->newsAPI->version(); $data = $response->getData(); $version = $data['version']; $this->assertEquals('1.0', $version); } }