@@ -35,6 +35,8 @@ public function testArchiveShouldReturnErrorWhenRepositoryIsWrong(): void
35
35
36
36
public function testArchiveShouldReturnErrorWhenArchivingErrored (): void
37
37
{
38
+ $ this ->transaction ->expects (self ::once ())->method ('rollBack ' );
39
+
38
40
$ category = $ this ->createMock (CategoryRepositoryInterface::class);
39
41
$ category ->method ('isArchived ' )->willReturn (false );
40
42
$ category ->method ('archive ' )->willReturn (false );
@@ -47,6 +49,8 @@ public function testArchiveShouldReturnErrorWhenArchivingErrored(): void
47
49
48
50
public function testArchiveShouldReturnErrorWhenCategoryIsAlreadyArchived (): void
49
51
{
52
+ $ this ->transaction ->expects (self ::once ())->method ('rollBack ' );
53
+
50
54
$ category = $ this ->createMock (CategoryRepositoryInterface::class);
51
55
$ category ->method ('isArchived ' )->willReturn (true );
52
56
$ result = $ this ->service ->archive ($ category );
@@ -57,6 +61,8 @@ public function testArchiveShouldReturnErrorWhenCategoryIsAlreadyArchived(): voi
57
61
58
62
public function testArchiveShouldReturnSuccessWhenArchivingIsDone (): void
59
63
{
64
+ $ this ->transaction ->expects (self ::once ())->method ('commit ' );
65
+
60
66
$ category = $ this ->createMock (CategoryRepositoryInterface::class);
61
67
$ category ->method ('isArchived ' )->willReturn (false );
62
68
$ category ->method ('archive ' )->willReturn (true );
@@ -67,6 +73,8 @@ public function testArchiveShouldReturnSuccessWhenArchivingIsDone(): void
67
73
68
74
public function testArchiveShouldReturnErrorWhenArchivingThrowsException (): void
69
75
{
76
+ $ this ->transaction ->expects (self ::once ())->method ('rollBack ' );
77
+
70
78
$ category = $ this ->createMock (CategoryRepositoryInterface::class);
71
79
$ category ->method ('isArchived ' )->willReturn (false );
72
80
$ category ->method ('archive ' )->willThrowException (new Exception ('exc ' ));
@@ -91,6 +99,8 @@ public function testReviveShouldReturnErrorWhenRepositoryIsWrong(): void
91
99
92
100
public function testReviveShouldReturnErrorWhenRevivingErrored (): void
93
101
{
102
+ $ this ->transaction ->expects (self ::once ())->method ('rollBack ' );
103
+
94
104
$ category = $ this ->createMock (CategoryRepositoryInterface::class);
95
105
$ category ->method ('isArchived ' )->willReturn (true );
96
106
$ category ->method ('revive ' )->willReturn (false );
@@ -103,6 +113,8 @@ public function testReviveShouldReturnErrorWhenRevivingErrored(): void
103
113
104
114
public function testReviveShouldReturnErrorWhenCategoryIsNotArchived (): void
105
115
{
116
+ $ this ->transaction ->expects (self ::once ())->method ('rollBack ' );
117
+
106
118
$ category = $ this ->createMock (CategoryRepositoryInterface::class);
107
119
$ category ->method ('isArchived ' )->willReturn (false );
108
120
$ result = $ this ->service ->revive ($ category );
@@ -113,6 +125,8 @@ public function testReviveShouldReturnErrorWhenCategoryIsNotArchived(): void
113
125
114
126
public function testReviveShouldReturnSuccessWhenRevivingIsDone (): void
115
127
{
128
+ $ this ->transaction ->expects (self ::once ())->method ('commit ' );
129
+
116
130
$ category = $ this ->createMock (CategoryRepositoryInterface::class);
117
131
$ category ->method ('isArchived ' )->willReturn (true );
118
132
$ category ->method ('revive ' )->willReturn (true );
@@ -123,6 +137,8 @@ public function testReviveShouldReturnSuccessWhenRevivingIsDone(): void
123
137
124
138
public function testReviveShouldReturnErrorWhenRevivingThrowsException (): void
125
139
{
140
+ $ this ->transaction ->expects (self ::once ())->method ('rollBack ' );
141
+
126
142
$ category = $ this ->createMock (CategoryRepositoryInterface::class);
127
143
$ category ->method ('isArchived ' )->willReturn (true );
128
144
$ category ->method ('revive ' )->willThrowException (new Exception ('exc ' ));
0 commit comments