Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable12] Allow overwriting of IOS theming values #5782

Merged
merged 2 commits into from Jul 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 30 additions & 1 deletion apps/theming/lib/ThemingDefaults.php
Expand Up @@ -51,6 +51,12 @@ class ThemingDefaults extends \OC_Defaults {
private $color;
/** @var Util */
private $util;
/** @var string */
private $iTunesAppId;
/** @var string */
private $iOSClientUrl;
/** @var string */
private $AndroidClientUrl;

/**
* ThemingDefaults constructor.
Expand Down Expand Up @@ -82,6 +88,9 @@ public function __construct(IConfig $config,
$this->url = parent::getBaseUrl();
$this->slogan = parent::getSlogan();
$this->color = parent::getColorPrimary();
$this->iTunesAppId = parent::getiTunesAppId();
$this->iOSClientUrl = parent::getiOSClientUrl();
$this->AndroidClientUrl = parent::getAndroidClientUrl();
}

public function getName() {
Expand Down Expand Up @@ -180,6 +189,27 @@ public function getBackground() {
return $this->urlGenerator->linkToRoute('theming.Theming.getLoginBackground') . '?v=' . $cacheBusterCounter;
}

/**
* @return string
*/
public function getiTunesAppId() {
return $this->config->getAppValue('theming', 'iTunesAppId', $this->iTunesAppId);
}

/**
* @return string
*/
public function getiOSClientUrl() {
return $this->config->getAppValue('theming', 'iOSClientUrl', $this->iOSClientUrl);
}

/**
* @return string
*/
public function getAndroidClientUrl() {
return $this->config->getAppValue('theming', 'AndroidClientUrl', $this->AndroidClientUrl);
}


/**
* @return array scss variables to overwrite
Expand Down Expand Up @@ -290,5 +320,4 @@ public function undo($setting) {

return $returnValue;
}

}
61 changes: 61 additions & 0 deletions apps/theming/tests/ThemingDefaultsTest.php
Expand Up @@ -543,4 +543,65 @@ public function testGetScssVariables() {
];
$this->assertEquals($expected, $this->template->getScssVariables());
}

public function testGetDefaultAndroidURL() {
$this->config
->expects($this->once())
->method('getAppValue')
->with('theming', 'AndroidClientUrl', 'https://play.google.com/store/apps/details?id=com.nextcloud.client')
->willReturn('https://play.google.com/store/apps/details?id=com.nextcloud.client');

$this->assertEquals('https://play.google.com/store/apps/details?id=com.nextcloud.client', $this->template->getAndroidClientUrl());
}

public function testGetCustomAndroidURL() {
$this->config
->expects($this->once())
->method('getAppValue')
->with('theming', 'AndroidClientUrl', 'https://play.google.com/store/apps/details?id=com.nextcloud.client')
->willReturn('https://play.google.com/store/apps/details?id=com.mycloud.client');

$this->assertEquals('https://play.google.com/store/apps/details?id=com.mycloud.client', $this->template->getAndroidClientUrl());
}

public function testGetDefaultiOSURL() {
$this->config
->expects($this->once())
->method('getAppValue')
->with('theming', 'iOSClientUrl', 'https://itunes.apple.com/us/app/nextcloud/id1125420102?mt=8')
->willReturn('https://itunes.apple.com/us/app/nextcloud/id1125420102?mt=8');

$this->assertEquals('https://itunes.apple.com/us/app/nextcloud/id1125420102?mt=8', $this->template->getiOSClientUrl());
}

public function testGetCustomiOSURL() {
$this->config
->expects($this->once())
->method('getAppValue')
->with('theming', 'iOSClientUrl', 'https://itunes.apple.com/us/app/nextcloud/id1125420102?mt=8')
->willReturn('https://itunes.apple.com/us/app/nextcloud/id1234567890?mt=8');

$this->assertEquals('https://itunes.apple.com/us/app/nextcloud/id1234567890?mt=8', $this->template->getiOSClientUrl());
}

public function testGetDefaultiTunesAppId() {
$this->config
->expects($this->once())
->method('getAppValue')
->with('theming', 'iTunesAppId', '1125420102')
->willReturn('1125420102');

$this->assertEquals('1125420102', $this->template->getiTunesAppId());
}

public function testGetCustomiTunesAppId() {
$this->config
->expects($this->once())
->method('getAppValue')
->with('theming', 'iTunesAppId', '1125420102')
->willReturn('1234567890');

$this->assertEquals('1234567890', $this->template->getiTunesAppId());
}

}