aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorThomas Müller <DeepDiver1975@users.noreply.github.com>2016-04-12 12:49:11 +0200
committerThomas Müller <DeepDiver1975@users.noreply.github.com>2016-04-12 12:49:11 +0200
commitfdee771aca39f394c940edfcaa5a15826b078974 (patch)
tree400c956152f57c14bdfae094bbd3de265dd7baba /lib/private
parent276b8a583112203b9b71e4ac2b372e50ca62df9b (diff)
downloadnextcloud-server-fdee771aca39f394c940edfcaa5a15826b078974.tar.gz
nextcloud-server-fdee771aca39f394c940edfcaa5a15826b078974.zip
Add unit testing capabilities for templates (#23708)
Add unit testing capabilities for templates
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/template.php8
-rw-r--r--lib/private/template/base.php58
2 files changed, 39 insertions, 27 deletions
diff --git a/lib/private/template.php b/lib/private/template.php
index d39abdcd378..c6542356fac 100644
--- a/lib/private/template.php
+++ b/lib/private/template.php
@@ -34,6 +34,8 @@
*
*/
+use OC\TemplateLayout;
+
require_once __DIR__.'/template/functions.php';
/**
@@ -218,11 +220,11 @@ class OC_Template extends \OC\Template\Base {
* This function process the template. If $this->renderAs is set, it
* will produce a full page.
*/
- public function fetchPage() {
- $data = parent::fetchPage();
+ public function fetchPage($additionalParams = null) {
+ $data = parent::fetchPage($additionalParams);
if( $this->renderAs ) {
- $page = new \OC\TemplateLayout($this->renderAs, $this->app);
+ $page = new TemplateLayout($this->renderAs, $this->app);
// Add custom headers
$headers = '';
diff --git a/lib/private/template/base.php b/lib/private/template/base.php
index d06bcdc4b82..72abc38c36c 100644
--- a/lib/private/template/base.php
+++ b/lib/private/template/base.php
@@ -29,13 +29,17 @@ namespace OC\Template;
class Base {
private $template; // The template
private $vars; // Vars
- private $l10n; // The l10n-Object
- private $theme; // theme defaults
+
+ /** @var \OCP\IL10N */
+ private $l10n;
+
+ /** @var \OC_Defaults */
+ private $theme;
/**
* @param string $template
* @param string $requestToken
- * @param \OC_L10N $l10n
+ * @param \OCP\IL10N $l10n
* @param \OC_Defaults $theme
*/
public function __construct($template, $requestToken, $l10n, $theme ) {
@@ -47,34 +51,36 @@ class Base {
}
/**
- * @param string $serverroot
+ * @param string $serverRoot
* @param string|false $app_dir
* @param string $theme
* @param string $app
+ * @return array
*/
- protected function getAppTemplateDirs($theme, $app, $serverroot, $app_dir) {
+ protected function getAppTemplateDirs($theme, $app, $serverRoot, $app_dir) {
// Check if the app is in the app folder or in the root
if( file_exists($app_dir.'/templates/' )) {
- return array(
- $serverroot.'/themes/'.$theme.'/apps/'.$app.'/templates/',
+ return [
+ $serverRoot.'/themes/'.$theme.'/apps/'.$app.'/templates/',
$app_dir.'/templates/',
- );
+ ];
}
- return array(
- $serverroot.'/themes/'.$theme.'/'.$app.'/templates/',
- $serverroot.'/'.$app.'/templates/',
- );
+ return [
+ $serverRoot.'/themes/'.$theme.'/'.$app.'/templates/',
+ $serverRoot.'/'.$app.'/templates/',
+ ];
}
/**
- * @param string $serverroot
+ * @param string $serverRoot
* @param string $theme
+ * @return array
*/
- protected function getCoreTemplateDirs($theme, $serverroot) {
- return array(
- $serverroot.'/themes/'.$theme.'/core/templates/',
- $serverroot.'/core/templates/',
- );
+ protected function getCoreTemplateDirs($theme, $serverRoot) {
+ return [
+ $serverRoot.'/themes/'.$theme.'/core/templates/',
+ $serverRoot.'/core/templates/',
+ ];
}
/**
@@ -131,29 +137,33 @@ class Base {
/**
* Process the template
- * @return string
+ *
+ * @param array|null $additionalParams
+ * @return string This function processes the template.
*
* This function processes the template.
*/
- public function fetchPage() {
- return $this->load($this->template);
+ public function fetchPage($additionalParams = null) {
+ return $this->load($this->template, $additionalParams);
}
/**
* doing the actual work
+ *
* @param string $file
+ * @param array|null $additionalParams
* @return string content
*
* Includes the template file, fetches its output
*/
- protected function load( $file, $additionalparams = null ) {
+ protected function load($file, $additionalParams = null) {
// Register the variables
$_ = $this->vars;
$l = $this->l10n;
$theme = $this->theme;
- if( !is_null($additionalparams)) {
- $_ = array_merge( $additionalparams, $this->vars );
+ if( !is_null($additionalParams)) {
+ $_ = array_merge( $additionalParams, $this->vars );
}
// Include