3
3
4
4
require_once (__DIR__ . '/../../inc/BaseCase.php ' );
5
5
6
+ use PHPCR \RepositoryInterface ;
6
7
use \PHPCR \Transaction ;
7
8
8
9
/**
@@ -25,23 +26,21 @@ public function setUp()
25
26
26
27
public function testGetTransactionManager ()
27
28
{
28
- $ session = self ::$ staticSharedFixture ['session ' ];
29
- $ utx = $ session ->getWorkspace ()->getTransactionManager ();
29
+ $ utx = $ this ->session ->getWorkspace ()->getTransactionManager ();
30
30
31
31
$ this ->assertInstanceOf ('\PHPCR\Transaction\UserTransactionInterface ' , $ utx );
32
32
}
33
33
34
34
public function testTransactionCommit ()
35
35
{
36
- $ session = self ::$ staticSharedFixture ['session ' ];
37
- $ utx = $ session ->getWorkspace ()->getTransactionManager ();
36
+ $ utx = $ this ->session ->getWorkspace ()->getTransactionManager ();
38
37
39
38
$ utx ->begin ();
40
39
$ child = $ this ->node ->addNode ('insideTransaction ' );
41
40
42
41
$ this ->assertEquals ($ this ->node ->getPath () . '/insideTransaction ' , $ child ->getPath ());
43
42
44
- $ session ->save ();
43
+ $ this -> session ->save ();
45
44
46
45
$ sessionbeforesave = self ::$ loader ->getSession ();
47
46
$ this ->assertFalse ($ sessionbeforesave ->nodeExists ($ child ->getPath ()));
@@ -55,19 +54,17 @@ public function testTransactionCommit()
55
54
56
55
public function testTransactionRollback ()
57
56
{
58
- $ session = self ::$ staticSharedFixture ['session ' ];
59
-
60
57
$ copy = $ this ->node ->addNode ('copyTransaction ' );
61
58
$ copiedNodePath = $ this ->node ->getPath ()."/copyTransactionCopy " ;
62
- $ session ->save ();
59
+ $ this -> session ->save ();
63
60
64
- $ utx = $ session ->getWorkspace ()->getTransactionManager ();
61
+ $ utx = $ this -> session ->getWorkspace ()->getTransactionManager ();
65
62
66
63
$ child = $ this ->node ->addNode ('insideTransaction ' );
67
64
$ utx ->begin ();
68
65
//workspace operation
69
- $ session ->getWorkspace ()->copy ($ copy ->getPath (),$ copiedNodePath );
70
- $ session ->save ();
66
+ $ this -> session ->getWorkspace ()->copy ($ copy ->getPath (),$ copiedNodePath );
67
+ $ this -> session ->save ();
71
68
$ this ->assertFalse ($ child ->isNew ());
72
69
$ utx ->rollback ();
73
70
@@ -79,7 +76,7 @@ public function testTransactionRollback()
79
76
80
77
// semantics of rollback is that the local session state does not roll back
81
78
// this must work
82
- $ session ->save ();
79
+ $ this -> session ->save ();
83
80
84
81
$ sessionaftersave = self ::$ loader ->getSession ();
85
82
$ this ->assertFalse ($ sessionaftersave ->nodeExists ($ child ->getPath ()));
@@ -88,20 +85,19 @@ public function testTransactionRollback()
88
85
89
86
public function testInTransaction ()
90
87
{
91
- $ session = self ::$ staticSharedFixture ['session ' ];
92
- $ utx = $ session ->getWorkspace ()->getTransactionManager ();
88
+ $ utx = $ this ->session ->getWorkspace ()->getTransactionManager ();
93
89
94
90
$ this ->assertFalse ($ utx ->inTransaction ());
95
91
$ utx ->begin ();
96
92
$ this ->node ->addNode ('insideTransaction0 ' );
97
- $ session ->save ();
93
+ $ this -> session ->save ();
98
94
$ this ->assertTrue ($ utx ->inTransaction ());
99
95
$ utx ->commit ();
100
96
$ this ->assertFalse ($ utx ->inTransaction ());
101
97
102
98
$ utx ->begin ();
103
99
$ this ->node ->addNode ('insideTransaction1 ' );
104
- $ session ->save ();
100
+ $ this -> session ->save ();
105
101
$ this ->assertTrue ($ utx ->inTransaction ());
106
102
$ utx ->rollback ();
107
103
$ this ->assertFalse ($ utx ->inTransaction ());
@@ -114,19 +110,16 @@ public function testInTransaction()
114
110
*/
115
111
public function testIllegalCheckin ()
116
112
{
117
- if (!self ::$ staticSharedFixture ['session ' ]->getRepository ()->getDescriptor ('option.versioning.supported ' )) {
118
- $ this ->markTestSkipped ('PHPCR repository doesn \'t support versioning ' );
119
- }
113
+ $ this ->skipIfNotSupported (RepositoryInterface::OPTION_VERSIONING_SUPPORTED );
120
114
121
- $ session = self ::$ staticSharedFixture ['session ' ];
122
- $ vm = $ session ->getWorkspace ()->getVersionManager ();
115
+ $ vm = $ this ->session ->getWorkspace ()->getVersionManager ();
123
116
124
- $ utx = $ session ->getWorkspace ()->getTransactionManager ();
117
+ $ utx = $ this -> session ->getWorkspace ()->getTransactionManager ();
125
118
$ vm ->checkout ($ this ->node ->getPath ());
126
119
$ this ->node ->setProperty ('foo ' , 'bar2 ' );
127
120
128
121
$ utx ->begin ();
129
- $ session ->save ();
122
+ $ this -> session ->save ();
130
123
131
124
$ vm ->checkin ($ this ->node ->getPath ());
132
125
}
0 commit comments