From 885b506695403465443b3dce124910fd2c9f66e6 Mon Sep 17 00:00:00 2001 From: Alessandro Cosentino Date: Mon, 29 Sep 2014 13:45:17 -0400 Subject: web app manifest --- tests/unit/controller/AppControllerTest.php | 69 +++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 tests/unit/controller/AppControllerTest.php (limited to 'tests/unit') diff --git a/tests/unit/controller/AppControllerTest.php b/tests/unit/controller/AppControllerTest.php new file mode 100644 index 000000000..50dcb173a --- /dev/null +++ b/tests/unit/controller/AppControllerTest.php @@ -0,0 +1,69 @@ + + * @author Bernhard Posselt + * @copyright Alessandro Cosentino 2014 + * @copyright Bernhard Posselt 2014 + */ + +namespace OCA\News\Controller; + + +class AppControllerTest extends \PHPUnit_Framework_TestCase { + + private $appName; + private $request; + private $urlGenerator; + private $appConfig; + private $controller; + private $configData; + + /** + * Gets run before each test + */ + public function setUp(){ + $this->appName = 'news'; + $this->request = $this->getMockBuilder( + '\OCP\IRequest') + ->disableOriginalConstructor() + ->getMock(); + $this->urlGenerator = $this->getMockBuilder( + '\OCP\IURLGenerator') + ->disableOriginalConstructor() + ->getMock(); + $this->appConfig = $this->getMockBuilder( + '\OCA\News\Config\AppConfig') + ->disableOriginalConstructor() + ->getMock(); + + $this->configData = [ + "name" => "AppTest", + "id" => "apptest", + "description" => "This is a test app", + "homepage" => "https://github.com/owncloud/test" + ]; + + $this->controller = new AppController($this->appName, $this->request, + $this->urlGenerator, $this->appConfig); + } + + public function testManifest(){ + $this->appConfig->expects($this->once()) + ->method('getConfig') + ->will($this->returnValue($this->configData)); + $result = $this->controller->manifest(); + $jsonResult = json_decode($result->render(), true); + $this->assertEquals($jsonResult['name'], + $this->configData['name']); + $this->assertEquals($jsonResult['description'], + $this->configData['description']); + $this->assertEquals($jsonResult['developer']['url'], + $this->configData['homepage']); + } + +} \ No newline at end of file -- cgit v1.2.3