@@ -57,6 +57,29 @@ public function testExecuteSuccess(): void
57
57
$ this ->assertTrue (true );
58
58
}
59
59
60
+ /**
61
+ * Tests BlockFixupAndSquashCommits::execute
62
+ */
63
+ public function testExecuteSuccessBecauseOfUnprotectedBranch (): void
64
+ {
65
+ $ input = ['refs/heads/foo 12345 refs/heads/foo 98765 ' ];
66
+ $ io = $ this ->createIOMock ();
67
+ $ repo = $ this ->createRepositoryMock ();
68
+ $ config = $ this ->createConfigMock ();
69
+ $ action = $ this ->createActionConfigMock ();
70
+ $ operator = $ this ->createGitLogOperator ();
71
+ $ options = new Options (['protectedBranches ' => ['main ' ]]);
72
+ $ action ->expects ($ this ->once ())->method ('getOptions ' )->willReturn ($ options );
73
+ $ io ->expects ($ this ->once ())->method ('getStandardInput ' )->willReturn ($ input );
74
+ $ operator ->method ('getCommitsBetween ' )->willReturn ($ this ->getFakeCommits ());
75
+ $ repo ->method ('getLogOperator ' )->willReturn ($ operator );
76
+
77
+ $ blocker = new BlockFixupAndSquashCommits ();
78
+ $ blocker ->execute ($ config , $ io , $ repo , $ action );
79
+
80
+ $ this ->assertTrue (true );
81
+ }
82
+
60
83
/**
61
84
* Tests BlockFixupAndSquashCommits::execute
62
85
*/
@@ -78,6 +101,7 @@ public function testExecuteSuccessWithNoChangesFromLocalAndRemote(): void
78
101
79
102
$ this ->assertTrue (true );
80
103
}
104
+
81
105
/**
82
106
* Tests BlockFixupAndSquashCommits::execute
83
107
*/
@@ -100,6 +124,29 @@ public function testExecuteBlockFixup(): void
100
124
$ blocker ->execute ($ config , $ io , $ repo , $ action );
101
125
}
102
126
127
+ /**
128
+ * Tests BlockFixupAndSquashCommits::execute
129
+ */
130
+ public function testExecuteBlockFixupForProtectedBranch (): void
131
+ {
132
+ $ this ->expectException (Exception::class);
133
+
134
+ $ input = ['refs/heads/main 12345 refs/heads/main 98765 ' ];
135
+ $ io = $ this ->createIOMock ();
136
+ $ repo = $ this ->createRepositoryMock ();
137
+ $ config = $ this ->createConfigMock ();
138
+ $ action = $ this ->createActionConfigMock ();
139
+ $ operator = $ this ->createGitLogOperator ();
140
+ $ options = new Options (['protectedBranches ' => ['main ' ]]);
141
+ $ action ->expects ($ this ->once ())->method ('getOptions ' )->willReturn ($ options );
142
+ $ io ->expects ($ this ->once ())->method ('getStandardInput ' )->willReturn ($ input );
143
+ $ operator ->method ('getCommitsBetween ' )->willReturn ($ this ->getFakeCommits ('fixup! Foo ' ));
144
+ $ repo ->method ('getLogOperator ' )->willReturn ($ operator );
145
+
146
+ $ blocker = new BlockFixupAndSquashCommits ();
147
+ $ blocker ->execute ($ config , $ io , $ repo , $ action );
148
+ }
149
+
103
150
/**
104
151
* Tests BlockFixupAndSquashCommits::execute
105
152
*/
0 commit comments