[Pkg-owncloud-commits] [owncloud] 74/122: Add test for setEmailAddress

David Prévot taffit at moszumanska.debian.org
Sat May 9 00:00:17 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch stable8
in repository owncloud.

commit d36d14366b1d174cf3a2ea53b38f0955dc48ffd2
Author: Joas Schilling <nickvergessen at owncloud.com>
Date:   Tue May 5 12:57:15 2015 +0200

    Add test for setEmailAddress
---
 tests/settings/controller/userscontrollertest.php | 70 +++++++++++++++++++++++
 1 file changed, 70 insertions(+)

diff --git a/tests/settings/controller/userscontrollertest.php b/tests/settings/controller/userscontrollertest.php
index 25c935b..b9d45d7 100644
--- a/tests/settings/controller/userscontrollertest.php
+++ b/tests/settings/controller/userscontrollertest.php
@@ -1388,4 +1388,74 @@ class UsersControllerTest extends \Test\TestCase {
 		$this->assertEquals($expectedResult, $result);
 	}
 
+	public function setEmailAddressData() {
+		return [
+			['', true, false, true],
+			['foobar at localhost', true, true, false],
+			['foo at bar@localhost', false, false, false],
+		];
+	}
+
+	/**
+	 * @dataProvider setEmailAddressData
+	 *
+	 * @param string $mailAddress
+	 * @param bool $isValid
+	 * @param bool $expectsUpdate
+	 * @param bool $expectsDelete
+	 */
+	public function testSetEmailAddress($mailAddress, $isValid, $expectsUpdate, $expectsDelete) {
+		$this->container['IsAdmin'] = true;
+
+		$user = $this->getMockBuilder('\OC\User\User')
+			->disableOriginalConstructor()->getMock();
+		$user
+			->expects($this->any())
+			->method('getUID')
+			->will($this->returnValue('foo'));
+		$this->container['UserSession']
+			->expects($this->atLeastOnce())
+			->method('getUser')
+			->will($this->returnValue($user));
+		$this->container['Mailer']
+			->expects($this->any())
+			->method('validateMailAddress')
+			->with($mailAddress)
+			->willReturn($isValid);
+
+		if ($isValid) {
+			$user->expects($this->atLeastOnce())
+				->method('canChangeDisplayName')
+				->willReturn(true);
+
+			$this->container['UserManager']
+				->expects($this->atLeastOnce())
+				->method('get')
+				->with('foo')
+				->will($this->returnValue($user));
+		}
+
+		$this->container['Config']
+			->expects(($expectsUpdate) ? $this->once() : $this->never())
+			->method('setUserValue')
+			->with(
+				$this->equalTo($user->getUID()),
+				$this->equalTo('settings'),
+				$this->equalTo('email'),
+				$this->equalTo($mailAddress)
+
+			);
+		$this->container['Config']
+			->expects(($expectsDelete) ? $this->once() : $this->never())
+			->method('deleteUserValue')
+			->with(
+				$this->equalTo($user->getUID()),
+				$this->equalTo('settings'),
+				$this->equalTo('email')
+
+			);
+
+		$this->container['UsersController']->setMailAddress($user->getUID(), $mailAddress);
+	}
+
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list