@@ -67,12 +67,12 @@ public function testDenyAccessPrettySetStatusCode() {
6767 /**
6868 * @covers ::denyAccess
6969 */
70- public function testDenyAccessChooses418WhenConfigured () {
70+ public function testDenyAccessChooses418WhenBothRawAndUse418 () {
7171 $ factory = $ this ->getMockBuilder ( ResponseFactory::class )
7272 ->setConstructorArgs ( [
7373 new ServiceOptions ( ResponseFactory::CONSTRUCTOR_OPTIONS , [
7474 'CrawlerProtectionUse418 ' => true ,
75- 'CrawlerProtectionRawDenial ' => false ,
75+ 'CrawlerProtectionRawDenial ' => true ,
7676 'CrawlerProtectionRawDenialHeader ' => '' ,
7777 'CrawlerProtectionRawDenialText ' => '' ,
7878 ] )
@@ -86,6 +86,35 @@ public function testDenyAccessChooses418WhenConfigured() {
8686 $ factory ->denyAccess ( $ output );
8787 }
8888
89+ /**
90+ * When RawDenial is false, Use418 should be a no-op and the factory
91+ * must fall through to the pretty 403 page.
92+ *
93+ * @covers ::denyAccess
94+ */
95+ public function testDenyAccessIgnoresUse418WhenRawDenialDisabled () {
96+ $ factory = $ this ->getMockBuilder ( ResponseFactory::class )
97+ ->setConstructorArgs ( [
98+ new ServiceOptions ( ResponseFactory::CONSTRUCTOR_OPTIONS , [
99+ 'CrawlerProtectionUse418 ' => true ,
100+ 'CrawlerProtectionRawDenial ' => false ,
101+ 'CrawlerProtectionRawDenialHeader ' => '' ,
102+ 'CrawlerProtectionRawDenialText ' => '' ,
103+ ] )
104+ ] )
105+ ->onlyMethods ( [ 'denyAccessPretty ' , 'denyAccessWith418 ' ] )
106+ ->getMock ();
107+
108+ $ factory ->expects ( $ this ->never () )->method ( 'denyAccessWith418 ' );
109+
110+ $ output = $ this ->createMock ( self ::$ outputPageClassName );
111+ $ factory ->expects ( $ this ->once () )
112+ ->method ( 'denyAccessPretty ' )
113+ ->with ( $ output );
114+
115+ $ factory ->denyAccess ( $ output );
116+ }
117+
89118 /**
90119 * @covers ::denyAccess
91120 */
0 commit comments