diff options
author | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-10-21 18:19:23 +0200 |
---|---|---|
committer | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-10-21 18:19:23 +0200 |
commit | 66c73a96ac2dda076bcfe0dc0a1ca2a7e169149d (patch) | |
tree | dc0318fa459e4f313217ee38e4bc63524513d721 /tests | |
parent | f5e64d35c05b14016eb4fffff7199386a97a9b43 (diff) |
first try to set indention limit at 80 characters in php
Diffstat (limited to 'tests')
26 files changed, 355 insertions, 197 deletions
diff --git a/tests/classloader.php b/tests/classloader.php index c660057df..7992b1b23 100644 --- a/tests/classloader.php +++ b/tests/classloader.php @@ -14,20 +14,25 @@ require_once __DIR__ . '/../3rdparty/ZendXml/vendor/autoload.php'; require_once __DIR__ . '/../3rdparty/simplepie/autoloader.php'; require_once __DIR__ . '/../3rdparty/Net_URL2/Net/URL2.php'; -require_once __DIR__ . '/../../../tests/lib/appframework/db/mappertestutility.php'; +require_once + __DIR__ . '/../../../tests/lib/appframework/db/mappertestutility.php'; // to execute without owncloud, we need to create our own classloader spl_autoload_register(function ($className){ if (strpos($className, 'OCA\\') === 0) { - $path = strtolower(str_replace('\\', '/', substr($className, 3)) . '.php'); + $path = strtolower( + str_replace('\\', '/', substr($className, 3)) . '.php' + ); $relPath = __DIR__ . '/../..' . $path; if(file_exists($relPath)){ require_once $relPath; } } else if(strpos($className, 'OCP\\') === 0) { - $path = strtolower(str_replace('\\', '/', substr($className, 3)) . '.php'); + $path = strtolower( + str_replace('\\', '/', substr($className, 3)) . '.php' + ); $relPath = __DIR__ . '/../../../lib/public' . $path; if(file_exists($relPath)){ diff --git a/tests/unit/articleenhancer/GlobalArticleEnhancerTest.php b/tests/unit/articleenhancer/GlobalArticleEnhancerTest.php index 3add03eb5..79647a882 100644 --- a/tests/unit/articleenhancer/GlobalArticleEnhancerTest.php +++ b/tests/unit/articleenhancer/GlobalArticleEnhancerTest.php @@ -26,8 +26,12 @@ class GlobalArticleEnhancerTest extends \PHPUnit_Framework_TestCase { public function testNoReplaceYoutubeAutoplay() { - $body = '<iframe width="728" height="410" src="//www.youtube.com/embed/autoplay=1/AWE6UpXQoGU" frameborder="0" allowfullscreen=""></iframe>'; - $expected = '<div><iframe width="728" height="410" src="//www.youtube.com/embed/autoplay=1/AWE6UpXQoGU" frameborder="0" allowfullscreen=""></iframe></div>'; + $body = '<iframe width="728" height="410" ' . + 'src="//www.youtube.com/embed/autoplay=1/AWE6UpXQoGU" ' . + 'frameborder="0" allowfullscreen=""></iframe>'; + $expected = '<div><iframe width="728" height="410" ' . + 'src="//www.youtube.com/embed/autoplay=1/AWE6UpXQoGU" ' . + 'frameborder="0" allowfullscreen=""></iframe></div>'; $item = new Item(); $item->setBody($body); @@ -37,8 +41,14 @@ class GlobalArticleEnhancerTest extends \PHPUnit_Framework_TestCase { public function testReplaceYoutubeAutoplay() { - $body = 'test <iframe width="728" height="410" src="//www.youtube.com/embed/AWE6UpXQoGU?tst=1&autoplay=1&abc=1" frameborder="0" allowfullscreen=""></iframe>'; - $expected = '<div>test <iframe width="728" height="410" src="//www.youtube.com/embed/AWE6UpXQoGU?tst=1&autoplay=0&abc=1" frameborder="0" allowfullscreen=""></iframe></div>'; + $body = 'test <iframe width="728" height="410" ' . + 'src="//www.youtube.com/embed' . + '/AWE6UpXQoGU?tst=1&autoplay=1&abc=1" frameborder="0" ' . + 'allowfullscreen=""></iframe>'; + $expected = '<div>test <iframe width="728" height="410" ' . + 'src="//www.youtube.com/embed' . + '/AWE6UpXQoGU?tst=1&autoplay=0&abc=1" frameborder="0" ' . + 'allowfullscreen=""></iframe></div>'; $item = new Item(); $item->setBody($body); diff --git a/tests/unit/articleenhancer/XPathArticleEnhancerTest.php b/tests/unit/articleenhancer/XPathArticleEnhancerTest.php index 0d4130e9e..00c4e7cb0 100644 --- a/tests/unit/articleenhancer/XPathArticleEnhancerTest.php +++ b/tests/unit/articleenhancer/XPathArticleEnhancerTest.php @@ -30,7 +30,8 @@ class XPathArticleEnhancerTest extends \PHPUnit_Framework_TestCase { protected function setUp() { $this->timeout = 30; - $this->fileFactory = $this->getMockBuilder('\OCA\News\Utility\SimplePieAPIFactory') + $this->fileFactory = $this + ->getMockBuilder('\OCA\News\Utility\SimplePieAPIFactory') ->disableOriginalConstructor() ->getMock(); $this->proxyHost = 'test'; @@ -56,7 +57,8 @@ class XPathArticleEnhancerTest extends \PHPUnit_Framework_TestCase { $this->testEnhancer = new XPathArticleEnhancer( $this->fileFactory, [ - '/explosm.net\/comics/' => '//*[@id=\'maincontent\']/div[2]/div/span', + '/explosm.net\/comics/' => + '//*[@id=\'maincontent\']/div[2]/div/span', '/explosm.net\/shorts/' => '//*[@id=\'maincontent\']/div/div', '/explosm.net\/all/' => '//body/*', '/themerepublic.net/' => '//*[@class=\'post hentry\']' @@ -259,8 +261,12 @@ class XPathArticleEnhancerTest extends \PHPUnit_Framework_TestCase { $result = $this->testEnhancer->enhance($item); $this->assertEquals('<div>' . - '<a target="_blank" href="https://www.explosm.net/a/relative/url.html?a=1#b">link</a>' . - '<a target="_blank" href="https://www.explosm.net/all/b/relative/url.html">link2</a>' . + '<a target="_blank" ' . + 'href="https://www.explosm.net/a/relative/url.html?a=1#b">' . + 'link</a>' . + '<a target="_blank" ' . + 'href="https://www.explosm.net/all/b/relative/url.html">' . + 'link2</a>' . '<img src="https://www.explosm.net/another/relative/link.jpg">' . '</div>', $result->getBody()); } @@ -288,7 +294,9 @@ class XPathArticleEnhancerTest extends \PHPUnit_Framework_TestCase { $result = $this->testEnhancer->enhance($item); $this->assertEquals( - '<div><img src="https://username:secret@www.explosm.net/all/relative/url.png?a=1&b=2"></div>', + '<div><img src="' . + 'https://username:secret@www.explosm.net' . + '/all/relative/url.png?a=1&b=2"></div>', $result->getBody()); } diff --git a/tests/unit/config/ConfigTest.php b/tests/unit/config/ConfigTest.php index 6a2b07c71..2032c2169 100644 --- a/tests/unit/config/ConfigTest.php +++ b/tests/unit/config/ConfigTest.php @@ -32,7 +32,9 @@ class ConfigTest extends \PHPUnit_Framework_TestCase { 'file_exists' ]); $this->loggerParams = ['hi']; - $this->config = new Config($this->fileSystem, $this->logger, $this->loggerParams); + $this->config = new Config( + $this->fileSystem, $this->logger, $this->loggerParams + ); $this->configPath = 'config.json'; } @@ -55,7 +57,9 @@ class ConfigTest extends \PHPUnit_Framework_TestCase { $this->fileSystem->expects($this->once()) ->method('file_get_contents') ->with($this->equalTo($this->configPath)) - ->will($this->returnValue("autoPurgeCount = 3\nuseCronUpdates = true")); + ->will($this->returnValue( + 'autoPurgeCount = 3' . "\n" . 'useCronUpdates = true') + ); $this->config->read($this->configPath); @@ -68,7 +72,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase { $this->fileSystem->expects($this->once()) ->method('file_get_contents') ->with($this->equalTo($this->configPath)) - ->will($this->returnValue("autoPurgeMinimumInterval = 59")); + ->will($this->returnValue('autoPurgeMinimumInterval = 59')); $this->config->read($this->configPath); @@ -81,7 +85,9 @@ class ConfigTest extends \PHPUnit_Framework_TestCase { $this->fileSystem->expects($this->once()) ->method('file_get_contents') ->with($this->equalTo($this->configPath)) - ->will($this->returnValue("autoPurgeCount = 3\nuseCronUpdates = false")); + ->will($this->returnValue( + 'autoPurgeCount = 3' . "\n" . 'useCronUpdates = false') + ); $this->config->read($this->configPath); @@ -120,20 +126,20 @@ class ConfigTest extends \PHPUnit_Framework_TestCase { public function testWrite () { - $json = "autoPurgeMinimumInterval = 60\n" . - "autoPurgeCount = 3\n" . - "simplePieCacheDuration = 1800\n" . - "feedFetcherTimeout = 60\n" . - "useCronUpdates = true\n" . - "proxyHost = yo man\n" . - "proxyPort = 12\n" . - "proxyUser = this is a test\n". - "proxyPassword = se"; + $json = 'autoPurgeMinimumInterval = 60' . "\n" . + 'autoPurgeCount = 3' . "\n" . + 'simplePieCacheDuration = 1800' . "\n" . + 'feedFetcherTimeout = 60' . "\n" . + 'useCronUpdates = true' . "\n" . + 'proxyHost = yo man' . "\n" . + 'proxyPort = 12' . "\n" . + 'proxyUser = this is a test' . "\n". + 'proxyPassword = se'; $this->config->setAutoPurgeCount(3); - $this->config->setProxyHost("yo man"); + $this->config->setProxyHost('yo man'); $this->config->setProxyPort(12); - $this->config->setProxyUser("this is a test"); - $this->config->setProxyPassword("se"); + $this->config->setProxyUser('this is a test'); + $this->config->setProxyPassword('se'); $this->fileSystem->expects($this->once()) ->method('file_put_contents') @@ -157,15 +163,15 @@ class ConfigTest extends \PHPUnit_Framework_TestCase { $this->config->setUseCronUpdates(false); - $json = "autoPurgeMinimumInterval = 60\n" . - "autoPurgeCount = 200\n" . - "simplePieCacheDuration = 1800\n" . - "feedFetcherTimeout = 60\n" . - "useCronUpdates = false\n" . - "proxyHost = \n" . - "proxyPort = 8080\n" . - "proxyUser = \n" . - "proxyPassword = "; + $json = 'autoPurgeMinimumInterval = 60' . "\n" . + 'autoPurgeCount = 200' . "\n" . + 'simplePieCacheDuration = 1800' . "\n" . + 'feedFetcherTimeout = 60' . "\n" . + 'useCronUpdates = false' . "\n" . + 'proxyHost = ' . "\n" . + 'proxyPort = 8080' . "\n" . + 'proxyUser = ' . "\n" . + 'proxyPassword = '; $this->fileSystem->expects($this->once()) ->method('file_put_contents') @@ -177,8 +183,8 @@ class ConfigTest extends \PHPUnit_Framework_TestCase { public function testEncodesUserAndPasswordInHTTPBasicAuth() { - $this->config->setProxyUser("this is a test"); - $this->config->setProxyPassword("se"); + $this->config->setProxyUser('this is a test'); + $this->config->setProxyPassword('se'); $this->assertEquals('this is a test:se', $this->config->getProxyAuth()); } diff --git a/tests/unit/controller/ExportControllerTest.php b/tests/unit/controller/ExportControllerTest.php index 29760e6f4..635209041 100644 --- a/tests/unit/controller/ExportControllerTest.php +++ b/tests/unit/controller/ExportControllerTest.php @@ -113,7 +113,10 @@ class ExportControllerTest extends \PHPUnit_Framework_TestCase { $return = $this->controller->articles(); $headers = $return->getHeaders(); - $this->assertEquals('attachment; filename="articles.json"', $headers ['Content-Disposition']); + $this->assertEquals( + 'attachment; filename="articles.json"', + $headers ['Content-Disposition'] + ); $this->assertEquals('[{"guid":null,"url":null,"title":null,' . '"author":null,"pubDate":null,"body":null,"enclosureMime":null,' . diff --git a/tests/unit/controller/FeedApiControllerTest.php b/tests/unit/controller/FeedApiControllerTest.php index d14782856..c73f49288 100644 --- a/tests/unit/controller/FeedApiControllerTest.php +++ b/tests/unit/controller/FeedApiControllerTest.php @@ -135,7 +135,9 @@ class FeedApiControllerTest extends \PHPUnit_Framework_TestCase { public function testDeleteDoesNotExist() { $this->feedService->expects($this->once()) ->method('delete') - ->will($this->throwException(new ServiceNotFoundException($this->msg))); + ->will($this->throwException( + new ServiceNotFoundException($this->msg)) + ); $response = $this->feedAPI->delete(2); @@ -203,7 +205,9 @@ class FeedApiControllerTest extends \PHPUnit_Framework_TestCase { ->with($this->equalTo($this->user), $this->equalTo(false)); $this->feedService->expects($this->once()) ->method('create') - ->will($this->throwException(new ServiceConflictException($this->msg))); + ->will( + $this->throwException(new ServiceConflictException($this->msg)) + ); $response = $this->feedAPI->create('ho', 3); @@ -216,7 +220,9 @@ class FeedApiControllerTest extends \PHPUnit_Framework_TestCase { public function testCreateError() { $this->feedService->expects($this->once()) ->method('create') - ->will($this->throwException(new ServiceNotFoundException($this->msg))); + ->will( + $this->throwException(new ServiceNotFoundException($this->msg)) + ); $response = $this->feedAPI->create('ho', 3); @@ -253,7 +259,9 @@ class FeedApiControllerTest extends \PHPUnit_Framework_TestCase { public function testMoveDoesNotExist() { $this->feedService->expects($this->once()) ->method('move') - ->will($this->throwException(new ServiceNotFoundException($this->msg))); + ->will( + $this->throwException(new ServiceNotFoundException($this->msg)) + ); $response = $this->feedAPI->move(3, 4); diff --git a/tests/unit/controller/FeedControllerTest.php b/tests/unit/controller/FeedControllerTest.php index 34b0a847b..e7f19a2b8 100644 --- a/tests/unit/controller/FeedControllerTest.php +++ b/tests/unit/controller/FeedControllerTest.php @@ -43,13 +43,16 @@ class FeedControllerTest extends \PHPUnit_Framework_TestCase { '\OCP\IConfig') ->disableOriginalConstructor() ->getMock(); - $this->itemService = $this->getMockBuilder('\OCA\News\Service\ItemService') + $this->itemService = $this + ->getMockBuilder('\OCA\News\Service\ItemService') ->disableOriginalConstructor() ->getMock(); - $this->feedService = $this->getMockBuilder('\OCA\News\Service\FeedService') + $this->feedService = $this + ->getMockBuilder('\OCA\News\Service\FeedService') ->disableOriginalConstructor() ->getMock(); - $this->folderService = $this->getMockBuilder('\OCA\News\Service\FolderService') + $this->folderService = $this + ->getMockBuilder('\OCA\News\Service\FolderService') ->disableOriginalConstructor() ->getMock(); $this->request = $this->getMockBuilder( @@ -276,7 +279,9 @@ class FeedControllerTest extends \PHPUnit_Framework_TestCase { $params = json_decode($response->render(), true); $this->assertEquals($msg, $params['message']); - $this->assertEquals($response->getStatus(), Http::STATUS_UNPROCESSABLE_ENTITY); + $this->assertEquals( + $response->getStatus(), Http::STATUS_UNPROCESSABLE_ENTITY + ); } @@ -427,7 +432,7 @@ class FeedControllerTest extends \PHPUnit_Framework_TestCase { $this->feedService->expects($this->once()) ->method('importArticles') - ->with($this->equalTo(array('json')), + ->with($this->equalTo(['json']), $this->equalTo($this->user)) ->will($this->returnValue($feed)); @@ -436,7 +441,7 @@ class FeedControllerTest extends \PHPUnit_Framework_TestCase { ->with($this->equalTo($this->user)) ->will($this->returnValue(3)); - $response = $this->controller->import(array('json')); + $response = $this->controller->import(['json']); $this->assertEquals($expected, $response); } @@ -445,7 +450,7 @@ class FeedControllerTest extends \PHPUnit_Framework_TestCase { public function testImportCreatesNoAdditionalFeed() { $this->feedService->expects($this->once()) ->method('importArticles') - ->with($this->equalTo(array('json')), + ->with($this->equalTo(['json']), $this->equalTo($this->user)) ->will($this->returnValue(null)); @@ -454,7 +459,7 @@ class FeedControllerTest extends \PHPUnit_Framework_TestCase { ->with($this->equalTo($this->user)) ->will($this->returnValue(3)); - $response = $this->controller->import(array('json')); + $response = $this->controller->import(['json']); $this->assertEquals(['starred' => 3], $response); } diff --git a/tests/unit/controller/FolderApiControllerTest.php b/tests/unit/controller/FolderApiControllerTest.php index c0371661a..550cd298c 100644 --- a/tests/unit/controller/FolderApiControllerTest.php +++ b/tests/unit/controller/FolderApiControllerTest.php @@ -130,7 +130,9 @@ class FolderApiControllerTest extends \PHPUnit_Framework_TestCase { $data = $response->getData(); $this->assertEquals($msg, $data['message']); - $this->assertEquals(Http::STATUS_UNPROCESSABLE_ENTITY, $response->getStatus()); + $this->assertEquals( + Http::STATUS_UNPROCESSABLE_ENTITY, $response->getStatus() + ); } @@ -149,7 +151,11 @@ class FolderApiControllerTest extends \PHPUnit_Framework_TestCase { $this->folderService->expects($this->once()) ->method('delete') - ->will($this->throwException(new ServiceNotFoundException($this->msg))); + ->will( + $this->throwException( + new ServiceNotFoundException($this->msg) + ) + ); $response = $this->folderAPI->delete($folderId); @@ -178,7 +184,11 @@ class FolderApiControllerTest extends \PHPUnit_Framework_TestCase { $this->folderService->expects($this->once()) ->method('rename') - ->will($this->throwException(new ServiceNotFoundException($this->msg))); + ->will( + $this->throwException( + new ServiceNotFoundException($this->msg) + ) + ); $response = $this->folderAPI->update($folderId, $folderName); @@ -194,7 +204,11 @@ class FolderApiControllerTest extends \PHPUnit_Framework_TestCase { $this->folderService->expects($this->once()) ->method('rename') - ->will($this->throwException(new ServiceConflictException($this->msg))); + ->will( + $this->throwException( + new ServiceConflictException($this->msg) + ) + ); $response = $this->folderAPI->update($folderId, $folderName); @@ -210,13 +224,19 @@ class FolderApiControllerTest extends \PHPUnit_Framework_TestCase { $this->folderService->expects($this->once()) ->method('rename') - ->will($this->throwException(new ServiceValidationException($this->msg))); + ->will( + $this->throwException( + new ServiceValidationException($this->msg) + ) + ); $response = $this->folderAPI->update($folderId, $folderName); $data = $response->getData(); $this->assertEquals($this->msg, $data['message']); - $this->assertEquals(Http::STATUS_UNPROCESSABLE_ENTITY, $response->getStatus()); + $this->assertEquals( + Http::STATUS_UNPROCESSABLE_ENTITY, $response->getStatus() + ); } diff --git a/tests/unit/controller/FolderControllerTest.php b/tests/unit/controller/FolderControllerTest.php index b06c97c79..5a5daff3d 100644 --- a/tests/unit/controller/FolderControllerTest.php +++ b/tests/unit/controller/FolderControllerTest.php @@ -91,7 +91,9 @@ class FolderControllerTest extends \PHPUnit_Framework_TestCase { public function testOpenDoesNotExist(){ $this->folderService->expects($this->once()) ->method('open') - ->will($this->throwException(new ServiceNotFoundException($this->msg))); + ->will($this->throwException( + new ServiceNotFoundException($this->msg)) + ); $response = $this->controller->open(5, true); @@ -144,7 +146,8 @@ class FolderControllerTest extends \PHPUnit_Framework_TestCase { $response = $this->controller->create('tech'); $params = json_decode($response->render(), true); - $this->assertEquals($response->getStatus(), Http::STATUS_UNPROCESSABLE_ENTITY); + $this->assertEquals($response->getStatus(), + Http::STATUS_UNPROCESSABLE_ENTITY); $this->assertEquals($msg, $params['message']); } @@ -217,7 +220,8 @@ class FolderControllerTest extends \PHPUnit_Framework_TestCase { $response = $this->controller->rename('tech', 4); $params = json_decode($response->render(), true); - $this->assertEquals($response->getStatus(), Http::STATUS_UNPROCESSABLE_ENTITY); + $this->assertEquals($response->getStatus(), + Http::STATUS_UNPROCESSABLE_ENTITY); $this->assertEquals($msg, $params['message']); } @@ -285,7 +289,9 @@ class FolderControllerTest extends \PHPUnit_Framework_TestCase { public function testRestoreDoesNotExist(){ $this->folderService->expects($this->once()) ->method('unmarkDeleted') - ->will($this->throwException(new ServiceNotFoundException($this->msg))); + ->will( + $this->throwException(new ServiceNotFoundException($this->msg)) + ); $response = $this->controller->restore(5); diff --git a/tests/unit/controller/ItemApiControllerTest.php b/tests/unit/controller/ItemApiControllerTest.php index 12b9d3225..8ab35010a 100644 --- a/tests/unit/controller/ItemApiControllerTest.php +++ b/tests/unit/controller/ItemApiControllerTest.php @@ -135,7 +135,9 @@ class ItemApiControllerTest extends \PHPUnit_Framework_TestCase { public function testReadDoesNotExist() { $this->itemService->expects($this->once()) ->method('read') - ->will($this->throwException(new ServiceNotFoundException($this->msg))); + ->will($this->throwException( + new ServiceNotFoundException($this->msg)) + ); $response = $this->itemAPI->read(2); @@ -161,7 +163,9 @@ class ItemApiControllerTest extends \PHPUnit_Framework_TestCase { public function testUnreadDoesNotExist() { $this->itemService->expects($this->once()) ->method('read') - ->will($this->throwException(new ServiceNotFoundException($this->msg))); + ->will($this->throwException( + new ServiceNotFoundException($this->msg)) + ); $response = $this->itemAPI->unread(2); @@ -188,7 +192,9 @@ class ItemApiControllerTest extends \PHPUnit_Framework_TestCase { public function testStarDoesNotExist() { $this->itemService->expects($this->once()) ->method('star') - ->will($this->throwException(new ServiceNotFoundException($this->msg))); + ->will($this->throwException( + new ServiceNotFoundException($this->msg)) + ); $response = $this->itemAPI->star(2, 'test'); @@ -215,7 +221,9 @@ class ItemApiControllerTest extends \PHPUnit_Framework_TestCase { public function testUnstarDoesNotExist() { $this->itemService->expects($this->once()) ->method('star') - ->will($this->throwException(new ServiceNotFoundException($this->msg))); + ->will($this->throwException( + new ServiceNotFoundException($this->msg)) + ); $response = $this->itemAPI->unstar(2, 'test'); diff --git a/tests/unit/controller/ItemControllerTest.php b/tests/unit/controller/ItemControllerTest.php index fd0904ef7..88e49c690 100644 --- a/tests/unit/controller/ItemControllerTest.php +++ b/tests/unit/controller/ItemControllerTest.php @@ -134,7 +134,7 @@ class ItemControllerTest extends \PHPUnit_Framework_TestCase { $this->itemService->expects($this->once()) ->method('star') - ->will($this->throwException(new ServiceNotFoundException($msg)));; + ->will($this->throwException(new ServiceNotFoundException($msg))); $response = $this->controller->star(4, 'test', false); $params = json_decode($response->render(), true); diff --git a/tests/unit/controller/PageControllerTest.php b/tests/unit/controller/PageControllerTest.php i |