1111
1212namespace PHPCR \Test ;
1313
14+ use Exception ;
15+ use PHPCR \CredentialsInterface ;
1416use PHPCR \NoSuchWorkspaceException ;
1517use PHPCR \RepositoryFactoryInterface ;
18+ use PHPCR \RepositoryInterface ;
19+ use PHPCR \SessionInterface ;
20+ use PHPUnit_Framework_SkippedTestSuiteError ;
1621
1722/**
1823 * Base class for the bootstrapping to load your phpcr implementation for the
2227 */
2328abstract class AbstractLoader
2429{
30+ /**
31+ * @var string
32+ */
2533 protected $ factoryclass ;
34+
35+ /**
36+ * @var string
37+ */
2638 protected $ workspacename ;
39+
40+ /**
41+ * @var string
42+ */
2743 protected $ otherWorkspacename ;
2844
2945 /**
3046 * array with chapter names to skip all test cases in (without the numbers).
3147 */
32- protected $ unsupportedChapters = array ();
48+ protected $ unsupportedChapters = [];
49+
3350 /**
3451 * array in the format Chapter\FeatureTest with all cases to skip.
3552 */
36- protected $ unsupportedCases = array ();
53+ protected $ unsupportedCases = [];
54+
3755 /**
3856 * array in the format Chapter\FeatureTest::testName with all single tests to skip.
3957 */
40- protected $ unsupportedTests = array () ;
58+ protected $ unsupportedTests = [] ;
4159
4260 /**
4361 * Create the loader.
@@ -63,10 +81,12 @@ protected function __construct($factoryclass, $workspacename = 'tests', $otherWo
6381 * configured to provide things from your implementation.
6482 *
6583 * @return AbstractLoader loader for your implementation
84+ *
85+ * @throws Exception
6686 */
6787 public static function getInstance ()
6888 {
69- throw new \ Exception ('You need to overwrite this method, but php does not allow to declare it abstract. ' );
89+ throw new Exception ('You need to overwrite this method, but php does not allow to declare it abstract. ' );
7090 }
7191
7292 /**
@@ -89,26 +109,28 @@ abstract public function getRepositoryFactoryParameters();
89109 * The default implementation uses the factory, but if the factory has an
90110 * error, you will get failing tests all over.
91111 *
92- * @return \PHPCR\ RepositoryInterface the repository instance
112+ * @return RepositoryInterface the repository instance
93113 */
94114 public function getRepository ()
95115 {
96116 $ factoryclass = $ this ->getRepositoryFactoryClass ();
97117 $ factory = new $ factoryclass ();
118+
98119 if (!$ factory instanceof RepositoryFactoryInterface) {
99- throw new \ Exception ("$ factoryclass is not of type RepositoryFactoryInterface " );
120+ throw new Exception ("$ factoryclass is not of type RepositoryFactoryInterface " );
100121 }
122+
101123 /* @var $factory RepositoryFactoryInterface */
102124 return $ factory ->getRepository ($ this ->getRepositoryFactoryParameters ());
103125 }
104126
105127 /**
106- * @return \PHPCR\ CredentialsInterface the login credentials that lead to successful login into the repository
128+ * @return CredentialsInterface the login credentials that lead to successful login into the repository
107129 */
108130 abstract public function getCredentials ();
109131
110132 /**
111- * @return \PHPCR\ CredentialsInterface the login credentials that lead to login failure
133+ * @return CredentialsInterface the login credentials that lead to login failure
112134 */
113135 abstract public function getInvalidCredentials ();
114136
@@ -118,7 +140,7 @@ abstract public function getInvalidCredentials();
118140 *
119141 * The user may not have write access to /tests_general_base/numberPropertyNode/jcr:content/foo
120142 *
121- * @return \PHPCR\ CredentialsInterface the login credentials with limited permissions for testing impersonate and access control
143+ * @return CredentialsInterface the login credentials with limited permissions for testing impersonate and access control
122144 */
123145 abstract public function getRestrictedCredentials ();
124146
@@ -165,9 +187,9 @@ public function getOtherWorkspaceName()
165187 /**
166188 * Get a session for this implementation.
167189 *
168- * @param \PHPCR\ CredentialsInterface $credentials The credentials to log into the repository. If omitted, self::getCredentials should be used
190+ * @param CredentialsInterface $credentials The credentials to log into the repository. If omitted, self::getCredentials should be used
169191 *
170- * @return \PHPCR\ SessionInterface the session resulting from logging into the repository with the provided credentials
192+ * @return SessionInterface the session resulting from logging into the repository with the provided credentials
171193 */
172194 public function getSession ($ credentials = false )
173195 {
@@ -177,9 +199,9 @@ public function getSession($credentials = false)
177199 /**
178200 * Get a session corresponding to the additional workspace for this implementation.
179201 *
180- * @param \PHPCR\ CredentialsInterface $credentials The credentials to log into the repository. If omitted, self::getCredentials should be used
202+ * @param CredentialsInterface $credentials The credentials to log into the repository. If omitted, self::getCredentials should be used
181203 *
182- * @return \PHPCR\ SessionInterface the session resulting from logging into the repository with the provided credentials
204+ * @return SessionInterface the session resulting from logging into the repository with the provided credentials
183205 */
184206 public function getAdditionalSession ($ credentials = false )
185207 {
@@ -192,9 +214,9 @@ public function getAdditionalSession($credentials = false)
192214 *
193215 * Otherwise, the test regarding this feature is skipped.
194216 *
195- * @return \PHPCR\ SessionInterface
217+ * @return SessionInterface
196218 *
197- * @throws \ PHPUnit_Framework_SkippedTestSuiteError to make whole test
219+ * @throws PHPUnit_Framework_SkippedTestSuiteError to make whole test
198220 * suite skip if implementation does not support updating the
199221 * properties automatically.
200222 */
@@ -204,7 +226,7 @@ public function getSessionWithLastModified()
204226 return $ this ->getSession ();
205227 }
206228
207- throw new \ PHPUnit_Framework_SkippedTestSuiteError ('Not supported ' );
229+ throw new PHPUnit_Framework_SkippedTestSuiteError ('Not supported ' );
208230 }
209231
210232 /**
@@ -240,7 +262,7 @@ public function getTestSupported($chapter, $case, $name)
240262 }
241263
242264 /**
243- * @return \PHPCR\Test\ FixtureLoaderInterface implementation that is used to load test fixtures
265+ * @return FixtureLoaderInterface implementation that is used to load test fixtures
244266 */
245267 abstract public function getFixtureLoader ();
246268
@@ -249,6 +271,8 @@ abstract public function getFixtureLoader();
249271 * @param $workspaceName
250272 *
251273 * @return mixed
274+ *
275+ * @throws Exception
252276 */
253277 private function getSessionForWorkspace ($ credentials , $ workspaceName )
254278 {
@@ -263,8 +287,9 @@ private function getSessionForWorkspace($credentials, $workspaceName)
263287 $ adminRepository = $ this ->getRepository (); // get a new repository to log into
264288 $ session = $ adminRepository ->login ($ this ->getCredentials (), 'default ' );
265289 $ workspace = $ session ->getWorkspace ();
290+
266291 if (in_array ($ workspaceName , $ workspace ->getAccessibleWorkspaceNames ())) {
267- throw new \ Exception (sprintf ('Workspace "%s" already exists but could not login to it ' , $ workspaceName ), null , $ e );
292+ throw new Exception (sprintf ('Workspace "%s" already exists but could not login to it ' , $ workspaceName ), null , $ e );
268293 }
269294 $ workspace ->createWorkspace ($ workspaceName );
270295
0 commit comments