diff options
author | Sean Molenaar <SMillerDev@users.noreply.github.com> | 2018-03-27 15:35:06 +0200 |
---|---|---|
committer | Bernhard Posselt <BernhardPosselt@users.noreply.github.com> | 2018-03-27 15:35:06 +0200 |
commit | 5b94705cf3918dc7986c6043b1fbe776bf22958f (patch) | |
tree | 4e8059818a0a913d24938e35238913a721fa6373 /tests/Unit/Utility | |
parent | f3c9d13551cef5968baea99c2f25085baee0ed5f (diff) |
Core: Fix compatibility with nextcloud codestyle (#280)
Diffstat (limited to 'tests/Unit/Utility')
-rw-r--r-- | tests/Unit/Utility/OPMLExporterTest.php | 98 | ||||
-rw-r--r-- | tests/Unit/Utility/ProxyConfigParserTest.php | 32 | ||||
-rw-r--r-- | tests/Unit/Utility/UpdaterTest.php | 38 |
3 files changed, 108 insertions, 60 deletions
diff --git a/tests/Unit/Utility/OPMLExporterTest.php b/tests/Unit/Utility/OPMLExporterTest.php index cf33b779b..7f2c7dfdf 100644 --- a/tests/Unit/Utility/OPMLExporterTest.php +++ b/tests/Unit/Utility/OPMLExporterTest.php @@ -5,10 +5,10 @@ * 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 + * @author Alessandro Cosentino <cosenal@gmail.com> + * @author Bernhard Posselt <dev@bernhard-posselt.com> + * @copyright 2012 Alessandro Cosentino + * @copyright 2012-2014 Bernhard Posselt */ namespace OCA\News\Tests\Unit\Utility; @@ -18,13 +18,15 @@ use \OCA\News\Db\Feed; use OCA\News\Utility\OPMLExporter; -class OPMLExporterTest extends \PHPUnit_Framework_TestCase { +class OPMLExporterTest extends \PHPUnit_Framework_TestCase +{ private $exporter; private $feed1; private $feed2; - protected function setUp() { + protected function setUp() + { $this->exporter = new OPMLExporter(); $this->folder1 = new Folder(); $this->folder1->setId(3); @@ -46,7 +48,8 @@ class OPMLExporterTest extends \PHPUnit_Framework_TestCase { } - private function getAttribute($item, $name) { + private function getAttribute($item, $name) + { // used to fix scrutinizer errors if ($item instanceof \DOMElement) { return $item->getAttribute($name); @@ -56,7 +59,8 @@ class OPMLExporterTest extends \PHPUnit_Framework_TestCase { } - public function testBuildEmpty(){ + public function testBuildEmpty() + { $result = $this->exporter->build([], []); $xpath = new \DOMXpath($result); @@ -64,41 +68,60 @@ class OPMLExporterTest extends \PHPUnit_Framework_TestCase { } - public function testBuildReturnsFolders() { + 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')); + $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() { + 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')); + $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() { + public function testBuildReturnsFeedsAndFolders() + { $result = $this->exporter->build( [$this->folder1, $this->folder2], [$this->feed1, $this->feed2] @@ -109,13 +132,20 @@ class OPMLExporterTest extends \PHPUnit_Framework_TestCase { $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->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') ); } diff --git a/tests/Unit/Utility/ProxyConfigParserTest.php b/tests/Unit/Utility/ProxyConfigParserTest.php index cc7833c31..a2a92fd38 100644 --- a/tests/Unit/Utility/ProxyConfigParserTest.php +++ b/tests/Unit/Utility/ProxyConfigParserTest.php @@ -5,10 +5,10 @@ * 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 + * @author Alessandro Cosentino <cosenal@gmail.com> + * @author Bernhard Posselt <dev@bernhard-posselt.com> + * @copyright 2012 Alessandro Cosentino + * @copyright 2012-2014 Bernhard Posselt */ namespace OCA\News\Tests\Unit\Utility; @@ -16,22 +16,26 @@ namespace OCA\News\Tests\Unit\Utility; use OCA\News\Utility\ProxyConfigParser; -class ProxyConfigParserTest extends \PHPUnit_Framework_TestCase { +class ProxyConfigParserTest extends \PHPUnit_Framework_TestCase +{ private $config; private $feedService; private $itemService; private $parser; - protected function setUp() { + protected function setUp() + { $this->config = $this->getMockBuilder( - '\OCP\IConfig') + '\OCP\IConfig' + ) ->disableOriginalConstructor() ->getMock(); $this->parser = new ProxyConfigParser($this->config); } - private function setExpectedProxy($proxy=null, $userpasswd=null) { + private function setExpectedProxy($proxy=null, $userpasswd=null) + { $this->config->expects($this->at(0)) ->method('getSystemValue') ->with($this->equalTo('proxy')) @@ -42,7 +46,8 @@ class ProxyConfigParserTest extends \PHPUnit_Framework_TestCase { ->will($this->returnValue($userpasswd)); } - public function testParsesNoProxy() { + public function testParsesNoProxy() + { $expected = [ 'host' => null, 'port' => null, @@ -55,7 +60,8 @@ class ProxyConfigParserTest extends \PHPUnit_Framework_TestCase { } - public function testParsesHost() { + public function testParsesHost() + { $expected = [ 'host' => 'http://google.com/mytest', 'port' => null, @@ -68,7 +74,8 @@ class ProxyConfigParserTest extends \PHPUnit_Framework_TestCase { } - public function testParsesHostAndPort() { + public function testParsesHostAndPort() + { $expected = [ 'host' => 'http://google.com/mytest', 'port' => 89, @@ -81,7 +88,8 @@ class ProxyConfigParserTest extends \PHPUnit_Framework_TestCase { } - public function testParsesUser() { + public function testParsesUser() + { $expected = [ 'host' => null, 'port' => null, diff --git a/tests/Unit/Utility/UpdaterTest.php b/tests/Unit/Utility/UpdaterTest.php index 76ebe74f7..87bbe31b9 100644 --- a/tests/Unit/Utility/UpdaterTest.php +++ b/tests/Unit/Utility/UpdaterTest.php @@ -5,10 +5,10 @@ * 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 + * @author Alessandro Cosentino <cosenal@gmail.com> + * @author Bernhard Posselt <dev@bernhard-posselt.com> + * @copyright 2012 Alessandro Cosentino + * @copyright 2012-2014 Bernhard Posselt */ namespace OCA\News\Tests\Unit\Utility; @@ -16,32 +16,40 @@ namespace OCA\News\Tests\Unit\Utility; use OCA\News\Utility\Updater; -class UpdaterTest extends \PHPUnit_Framework_TestCase { +class UpdaterTest extends \PHPUnit_Framework_TestCase +{ private $folderService; private $feedService; private $itemService; private $updater; - protected function setUp() { + protected function setUp() + { $this->folderService = $this->getMockBuilder( - '\OCA\News\Service\FolderService') + '\OCA\News\Service\FolderService' + ) ->disableOriginalConstructor() ->getMock(); $this->feedService = $this->getMockBuilder( - '\OCA\News\Service\FeedService') + '\OCA\News\Service\FeedService' + ) ->disableOriginalConstructor() ->getMock(); $this->itemService = $this->getMockBuilder( - '\OCA\News\Service\ItemService') + '\OCA\News\Service\ItemService' + ) ->disableOriginalConstructor() ->getMock(); - $this->updater = new Updater($this->folderService, + $this->updater = new Updater( + $this->folderService, $this->feedService, - $this->itemService); + $this->itemService + ); } - public function testBeforeUpdate() { + public function testBeforeUpdate() + { $this->folderService->expects($this->once()) ->method('purgeDeleted'); $this->feedService->expects($this->once()) @@ -50,13 +58,15 @@ class UpdaterTest extends \PHPUnit_Framework_TestCase { } - public function testAfterUpdate() { + public function testAfterUpdate() + { $this->itemService->expects($this->once()) ->method('autoPurgeOld'); $this->updater->afterUpdate(); } - public function testUpdate() { + public function testUpdate() + { $this->feedService->expects($this->once()) ->method('updateAll'); $this->updater->update(); |