11<?php
22namespace PHPCR \Tests \Connecting ;
33
4+ use PHPCR \LoginException ;
5+
46require_once (__DIR__ . '/../../inc/BaseCase.php ' );
57
68class RepositoryTest extends \PHPCR \Test \BaseCase
@@ -23,6 +25,7 @@ public function testLoginSession()
2325 $ repository = self ::$ loader ->getRepository ();
2426 $ session = $ repository ->login (self ::$ loader ->getCredentials (), self ::$ loader ->getWorkspaceName ());
2527 $ this ->assertInstanceOf ('PHPCR\SessionInterface ' , $ session );
28+ $ this ->assertEquals (self ::$ loader ->getWorkspaceName (), $ session ->getWorkspace ()->getName ());
2629 }
2730
2831 public function testDefaultWorkspace ()
@@ -33,17 +36,29 @@ public function testDefaultWorkspace()
3336 $ this ->assertEquals ('default ' , $ session ->getWorkspace ()->getName ());
3437 }
3538
36- /** external authentication */
39+ /**
40+ * external authentication
41+ */
3742 public function testNoLogin ()
3843 {
3944 $ repository = self ::$ loader ->getRepository ();
45+ if (! self ::$ loader ->prepareAnonymousLogin ()) {
46+ $ this ->setExpectedException ('PHPCR\LoginException ' );
47+ }
4048 $ session = $ repository ->login (null , self ::$ loader ->getWorkspaceName ());
4149 $ this ->assertInstanceOf ('PHPCR\SessionInterface ' , $ session );
50+ $ this ->assertEquals (self ::$ loader ->getWorkspaceName (), $ session ->getWorkspace ()->getName ());
4251 }
4352
53+ /**
54+ * external authentication
55+ */
4456 public function testNoLoginAndWorkspace ()
4557 {
4658 $ repository = self ::$ loader ->getRepository ();
59+ if (! self ::$ loader ->prepareAnonymousLogin ()) {
60+ $ this ->setExpectedException ('PHPCR\LoginException ' );
61+ }
4762 $ session = $ repository ->login ();
4863 $ this ->assertInstanceOf ('PHPCR\SessionInterface ' , $ session );
4964 $ this ->assertEquals ('default ' , $ session ->getWorkspace ()->getName ());
@@ -55,16 +70,16 @@ public function testNoLoginAndWorkspace()
5570 public function testLoginException ()
5671 {
5772 $ repository = self ::$ loader ->getRepository ();
58- $ session = $ repository ->login (self ::$ loader ->getInvalidCredentials ());
73+ $ repository ->login (self ::$ loader ->getInvalidCredentials ());
5974 }
6075
6176 /**
62- * @expectedException PHPCR\NoSuchWorkspaceException
77+ * @expectedException \ PHPCR\NoSuchWorkspaceException
6378 */
6479 public function testLoginNoSuchWorkspace ()
6580 {
6681 $ repository = self ::$ loader ->getRepository ();
67- $ session = $ repository ->login (self ::$ loader ->getCredentials (), 'notexistingworkspace ' );
82+ $ repository ->login (self ::$ loader ->getCredentials (), 'notexistingworkspace ' );
6883 }
6984
7085 /**
@@ -73,6 +88,6 @@ public function testLoginNoSuchWorkspace()
7388 public function testLoginRepositoryException ()
7489 {
7590 $ repository = self ::$ loader ->getRepository ();
76- $ session = $ repository ->login (self ::$ loader ->getCredentials (), '// ' );
91+ $ repository ->login (self ::$ loader ->getCredentials (), '// ' );
7792 }
7893}
0 commit comments