From 17e85dd5079b7ee0b1f18a450b66ec5df3cf5eb3 Mon Sep 17 00:00:00 2001 From: Sean Molenaar Date: Sun, 18 Mar 2018 15:01:08 +0100 Subject: Unit: Fix unittests (#278) * Unit: Fix unittests Issue #171 * Tests: Move test namespace to the expected nextcloud namespace --- tests/Unit/Service/FolderServiceTest.php | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'tests/Unit/Service/FolderServiceTest.php') diff --git a/tests/Unit/Service/FolderServiceTest.php b/tests/Unit/Service/FolderServiceTest.php index 65563b644..68dcda3f1 100644 --- a/tests/Unit/Service/FolderServiceTest.php +++ b/tests/Unit/Service/FolderServiceTest.php @@ -11,9 +11,10 @@ * @copyright Bernhard Posselt 2012, 2014 */ -namespace OCA\News\Service; +namespace OCA\News\Tests\Unit\Service; use \OCA\News\Db\Folder; +use OCA\News\Service\FolderService; class FolderServiceTest extends \PHPUnit_Framework_TestCase { @@ -80,6 +81,11 @@ class FolderServiceTest extends \PHPUnit_Framework_TestCase { ->with($this->equalTo($folder)) ->will($this->returnValue($folder)); + $this->folderMapper->expects($this->once()) + ->method('findByName') + ->with('hey', 'john') + ->will($this->returnValue([])); + $result = $this->folderService->create('hey', 'john', 5); $this->assertEquals($folder, $result); @@ -103,7 +109,9 @@ class FolderServiceTest extends \PHPUnit_Framework_TestCase { $this->folderService->create($folderName, 'john', 3); } - + /** + * @expectedException \OCA\News\Service\ServiceValidationException + */ public function testCreateThrowsExWhenFolderNameEmpty(){ $folderName = ''; @@ -112,9 +120,6 @@ class FolderServiceTest extends \PHPUnit_Framework_TestCase { ->with($this->equalTo($folderName)) ->will($this->returnValue([])); - $this->setExpectedException( - '\OCA\News\Service\ServiceValidationException' - ); $this->folderService->create($folderName, 'john', 3); } @@ -151,6 +156,11 @@ class FolderServiceTest extends \PHPUnit_Framework_TestCase { ->method('update') ->with($this->equalTo($folder)); + $this->folderMapper->expects($this->once()) + ->method('findByName') + ->with('bogus', '') + ->will($this->returnValue([])); + $this->folderService->rename(3, 'bogus', ''); $this->assertEquals('bogus', $folder->getName()); -- cgit v1.2.3