TYPO3 CMS  TYPO3_6-2
ApplicationContextTest.php
Go to the documentation of this file.
1 <?php
3 
4 /* *
5  * This script belongs to the TYPO3 Flow framework. *
6  * *
7  * It is free software; you can redistribute it and/or modify it under *
8  * the terms of the GNU Lesser General Public License, either version 3 *
9  * of the License, or (at your option) any later version. *
10  * *
11  * The TYPO3 project - inspiring people to share! *
12  * */
13 
15 
20 
26  public function allowedContexts() {
27  return array(
28  array('Production'),
29  array('Testing'),
30  array('Development'),
31 
32  array('Development/MyLocalComputer'),
33  array('Development/MyLocalComputer/Foo'),
34  array('Production/SpecialDeployment/LiveSystem'),
35  );
36  }
37 
43  $context = new ApplicationContext($allowedContext);
44  $this->assertSame($allowedContext, (string)$context);
45  }
46 
52  public function forbiddenContexts() {
53  return array(
54  array('MySpecialContexz'),
55  array('Testing123'),
56  array('DevelopmentStuff'),
57  array('DevelopmentStuff/FooBar'),
58  );
59  }
60 
66  public function constructorThrowsExceptionIfMainContextIsForbidden($forbiddenContext) {
67  new ApplicationContext($forbiddenContext);
68  }
69 
75  public function isMethods() {
76  return array(
77  'Development' => array(
78  'contextName' => 'Development',
79  'isDevelopment' => TRUE,
80  'isProduction' => FALSE,
81  'isTesting' => FALSE,
82  'parentContext' => NULL
83  ),
84  'Development/YourSpecialContext' => array(
85  'contextName' => 'Development/YourSpecialContext',
86  'isDevelopment' => TRUE,
87  'isProduction' => FALSE,
88  'isTesting' => FALSE,
89  'parentContext' => 'Development'
90  ),
91 
92  'Production' => array(
93  'contextName' => 'Production',
94  'isDevelopment' => FALSE,
95  'isProduction' => TRUE,
96  'isTesting' => FALSE,
97  'parentContext' => NULL
98  ),
99  'Production/MySpecialContext' => array(
100  'contextName' => 'Production/MySpecialContext',
101  'isDevelopment' => FALSE,
102  'isProduction' => TRUE,
103  'isTesting' => FALSE,
104  'parentContext' => 'Production'
105  ),
106 
107  'Testing' => array(
108  'contextName' => 'Testing',
109  'isDevelopment' => FALSE,
110  'isProduction' => FALSE,
111  'isTesting' => TRUE,
112  'parentContext' => NULL
113  ),
114  'Testing/MySpecialContext' => array(
115  'contextName' => 'Testing/MySpecialContext',
116  'isDevelopment' => FALSE,
117  'isProduction' => FALSE,
118  'isTesting' => TRUE,
119  'parentContext' => 'Testing'
120  )
121  );
122  }
123 
128  public function contextMethodsReturnTheCorrectValues($contextName, $isDevelopment, $isProduction, $isTesting, $parentContext) {
129  $context = new ApplicationContext($contextName);
130  $this->assertSame($isDevelopment, $context->isDevelopment());
131  $this->assertSame($isProduction, $context->isProduction());
132  $this->assertSame($isTesting, $context->isTesting());
133  $this->assertSame((string)$parentContext, (string)$context->getParent());
134  }
135 
140  $context = new ApplicationContext('Production/Foo/Bar');
141  $parentContext = $context->getParent();
142  $this->assertSame('Production/Foo', (string) $parentContext);
143 
144  $rootContext = $parentContext->getParent();
145  $this->assertSame('Production', (string) $rootContext);
146  }
147 }
contextMethodsReturnTheCorrectValues($contextName, $isDevelopment, $isProduction, $isTesting, $parentContext)