diff options
author | Bernhard Posselt <dev@bernhard-posselt.com> | 2016-07-23 21:24:54 +0200 |
---|---|---|
committer | Bernhard Posselt <dev@bernhard-posselt.com> | 2016-07-23 21:24:54 +0200 |
commit | 004fcbbcc7609ca83807f2e38967ef54f469bf72 (patch) | |
tree | 49eb99b4ea92b2045793fc567f719b31ec7f9042 /tests/unit/utility | |
parent | 60abc0ed4438c9b6fda245b0dc33cb483bc2aeaf (diff) |
Move to new directory structure
Diffstat (limited to 'tests/unit/utility')
-rw-r--r-- | tests/unit/utility/OPMLExporterTest.php | 123 | ||||
-rw-r--r-- | tests/unit/utility/ProxyConfigParserTest.php | 93 | ||||
-rw-r--r-- | tests/unit/utility/UpdaterTest.php | 62 |
3 files changed, 0 insertions, 278 deletions
diff --git a/tests/unit/utility/OPMLExporterTest.php b/tests/unit/utility/OPMLExporterTest.php deleted file mode 100644 index 416d476a8..000000000 --- a/tests/unit/utility/OPMLExporterTest.php +++ /dev/null @@ -1,123 +0,0 @@ -<?php -/** - * ownCloud - News - * - * This file is licensed under the Affero General Public License version 3 or - * later. See the COPYING file. - * - * @author Alessandro Cosentino <cosenal@gmail.com> - * @author Bernhard Posselt <dev@bernhard-posselt.com> - * @copyright Alessandro Cosentino 2012 - * @copyright Bernhard Posselt 2012, 2014 - */ - -namespace OCA\News\Utility; - -use \OCA\News\Db\Folder; -use \OCA\News\Db\Feed; - - -class OPMLExporterTest extends \PHPUnit_Framework_TestCase { - - private $exporter; - private $feed1; - private $feed2; - - protected function setUp() { - $this->exporter = new OPMLExporter(); - $this->folder1 = new Folder(); - $this->folder1->setId(3); - $this->folder1->setParentId(0); - $this->folder1->setName('Örgendwas'); - $this->folder2 = new Folder(); - $this->folder2->setId(1); - $this->folder2->setParentId(3); - $this->folder2->setName('a ergendwas'); - $this->feed1 = new Feed(); - $this->feed1->setUrl('url 1'); - $this->feed1->setTitle('tötel'); - $this->feed1->setFolderId(0); - $this->feed2 = new Feed(); - $this->feed2->setUrl('url'); - $this->feed2->setTitle('ttel df'); - $this->feed2->setLink('goooooogel'); - $this->feed2->setFolderId(1); - } - - - private function getAttribute($item, $name) { - // used to fix scrutinizer errors - if ($item instanceof \DOMElement) { - return $item->getAttribute($name); - } else { - return null; - } - } - - - public function testBuildEmpty(){ - $result = $this->exporter->build([], []); - $xpath = new \DOMXpath($result); - - $this->assertEquals(0, $xpath->query('//outline')->length); - } - - - public function testBuildReturnsFolders() { - $result = $this->exporter->build([$this->folder1, $this->folder2], []); - $xpath = new \DOMXpath($result); - $elems = $xpath->query('/opml/body/outline'); - - $this->assertEquals(2, $elems->length); - $this->assertEquals($this->folder1->getName(), - $this->getAttribute($elems->item(0), 'title')); - $this->assertEquals($this->folder1->getName(), - $this->getAttribute($elems->item(0), 'text')); - $this->assertEquals($this->folder2->getName(), - $this->getAttribute($elems->item(1), 'title')); - $this->assertEquals($this->folder2->getName(), - $this->getAttribute($elems->item(1), 'text')); - } - - - public function testBuildReturnsOnlyOneFeedIfParentFolderNotThere() { - $result = $this->exporter->build([], [$this->feed1, $this->feed2]); - $xpath = new \DOMXpath($result); - $elems = $xpath->query('//outline'); - - $this->assertEquals(1, $elems->length); - $this->assertEquals($this->feed1->getTitle(), - $this->getAttribute($elems->item(0), 'title')); - $this->assertEquals($this->feed1->getTitle(), - $this->getAttribute($elems->item(0), 'text')); - $this->assertEquals($this->feed1->getUrl(), - $this->getAttribute($elems->item(0), 'xmlUrl')); - $this->assertEquals('', - $this->getAttribute($elems->item(0), 'htmlUrl')); - } - - - public function testBuildReturnsFeedsAndFolders() { - $result = $this->exporter->build( - [$this->folder1, $this->folder2], - [$this->feed1, $this->feed2] - ); - $xpath = new \DOMXpath($result); - $elems = $xpath->query('/opml/body/outline'); - - $this->assertEquals(3, $elems->length); - - - $this->assertEquals($this->folder1->getName(), - $this->getAttribute($elems->item(0), 'title')); - $this->assertEquals($this->folder2->getName(), - $this->getAttribute($elems->item(1), 'text')); - $this->assertEquals($this->feed1->getUrl(), - $this->getAttribute($elems->item(2), 'xmlUrl')); - $this->assertEquals($this->feed2->getLink(), - $this->getAttribute($elems->item(1)->childNodes->item(0), 'htmlUrl') - ); - } - - -}
\ No newline at end of file diff --git a/tests/unit/utility/ProxyConfigParserTest.php b/tests/unit/utility/ProxyConfigParserTest.php deleted file mode 100644 index 39f6e61a3..000000000 --- a/tests/unit/utility/ProxyConfigParserTest.php +++ /dev/null @@ -1,93 +0,0 @@ -<?php -/** - * ownCloud - News - * - * This file is licensed under the Affero General Public License version 3 or - * later. See the COPYING file. - * - * @author Alessandro Cosentino <cosenal@gmail.com> - * @author Bernhard Posselt <dev@bernhard-posselt.com> - * @copyright Alessandro Cosentino 2012 - * @copyright Bernhard Posselt 2012, 2014 - */ - -namespace OCA\News\Utility; - - -class ProxyConfigParserTest extends \PHPUnit_Framework_TestCase { - - private $config; - private $feedService; - private $itemService; - private $parser; - - protected function setUp() { - $this->config = $this->getMockBuilder( - '\OCP\IConfig') - ->disableOriginalConstructor() - ->getMock(); - $this->parser = new ProxyConfigParser($this->config); - } - - private function setExpectedProxy($proxy=null, $userpasswd=null) { - $this->config->expects($this->at(0)) - ->method('getSystemValue') - ->with($this->equalTo('proxy')) - ->will($this->returnValue($proxy)); - $this->config->expects($this->at(1)) - ->method('getSystemValue') - ->with($this->equalTo('proxyuserpwd')) - ->will($this->returnValue($userpasswd)); - } - - public function testParsesNoProxy() { - $expected = [ - 'host' => null, - 'port' => null, - 'user' => null, - 'password' => null - ]; - $this->setExpectedProxy(); - $result = $this->parser->parse(); - $this->assertEquals($expected, $result); - } - - - public function testParsesHost() { - $expected = [ - 'host' => 'http://google.com/mytest', - 'port' => null, - 'user' => null, - 'password' => null - ]; - $this->setExpectedProxy('http://google.com/mytest'); - $result = $this->parser->parse(); - $this->assertEquals($expected, $result); - } - - - public function testParsesHostAndPort() { - $expected = [ - 'host' => 'http://google.com/mytest', - 'port' => 89, - 'user' => null, - 'password' => null - ]; - $this->setExpectedProxy('http://google.com:89/mytest'); - $result = $this->parser->parse(); - $this->assertEquals($expected, $result); - } - - - public function testParsesUser() { - $expected = [ - 'host' => null, - 'port' => null, - 'user' => 'john', - 'password' => 'doe:hey' - ]; - $this->setExpectedProxy(null, 'john:doe:hey'); - $result = $this->parser->parse(); - $this->assertEquals($expected, $result); - } -}
\ No newline at end of file diff --git a/tests/unit/utility/UpdaterTest.php b/tests/unit/utility/UpdaterTest.php deleted file mode 100644 index edca29f67..000000000 --- a/tests/unit/utility/UpdaterTest.php +++ /dev/null @@ -1,62 +0,0 @@ -<?php -/** - * ownCloud - News - * - * This file is licensed under the Affero General Public License version 3 or - * later. See the COPYING file. - * - * @author Alessandro Cosentino <cosenal@gmail.com> - * @author Bernhard Posselt <dev@bernhard-posselt.com> - * @copyright Alessandro Cosentino 2012 - * @copyright Bernhard Posselt 2012, 2014 - */ - -namespace OCA\News\Utility; - - -class UpdaterTest extends \PHPUnit_Framework_TestCase { - - private $folderService; - private $feedService; - private $itemService; - private $updater; - - protected function setUp() { - $this->folderService = $this->getMockBuilder( - '\OCA\News\Service\FolderService') - ->disableOriginalConstructor() - ->getMock(); - $this->feedService = $this->getMockBuilder( - '\OCA\News\Service\FeedService') - ->disableOriginalConstructor() - ->getMock(); - $this->itemService = $this->getMockBuilder( - '\OCA\News\Service\ItemService') - ->disableOriginalConstructor() - ->getMock(); - $this->updater = new Updater($this->folderService, - $this->feedService, - $this->itemService); - } - - public function testBeforeUpdate() { - $this->folderService->expects($this->once()) - ->method('purgeDeleted'); - $this->feedService->expects($this->once()) - ->method('purgeDeleted'); - $this->updater->beforeUpdate(); - } - - - public function testAfterUpdate() { - $this->itemService->expects($this->once()) - ->method('autoPurgeOld'); - $this->updater->afterUpdate(); - } - - public function testUpdate() { - $this->feedService->expects($this->once()) - ->method('updateAll'); - $this->updater->update(); - } -}
\ No newline at end of file |