@@ -101,6 +101,50 @@ public static function provideVerbosityMappingTests(): array
101101 ];
102102 }
103103
104+ /**
105+ * @dataProvider provideHandleOrBubbleSilentTests
106+ */
107+ public function testHandleOrBubbleSilent (int $ verbosity ,Level $ level ,bool $ isHandling ,bool $ isBubbling ,array $ map = [])
108+ {
109+ $ output =$ this ->createMock (OutputInterface::class);
110+ $ output
111+ ->expects ($ this ->atLeastOnce ())
112+ ->method ('getVerbosity ' )
113+ ->willReturn ($ verbosity )
114+ ;
115+ $ handler =new ConsoleHandler ($ output ,false ,$ map );
116+ $ this ->assertSame ($ isHandling ,$ handler ->isHandling (RecordFactory::create ($ level )),'->isHandling returns correct value depending on console verbosity and log level ' );
117+
118+ // check that the handler actually outputs the record if it handles it at verbosity above SILENT
119+ $ levelName = Logger::getLevelName ($ level );
120+ $ levelName =\sprintf ('%-9s ' ,$ levelName );
121+
122+ $ realOutput =$ this ->getMockBuilder (Output::class)->onlyMethods (['doWrite ' ])->getMock ();
123+ $ realOutput ->setVerbosity ($ verbosity );
124+ $ log ="16:21:54 $ levelName [app] My info message \n" ;
125+ $ realOutput
126+ ->expects ($ isHandling &&$ verbosity > OutputInterface::VERBOSITY_SILENT ?$ this ->once () :$ this ->never ())
127+ ->method ('doWrite ' )
128+ ->with ($ log ,false );
129+ $ handler =new ConsoleHandler ($ realOutput ,false ,$ map );
130+
131+ $ infoRecord = RecordFactory::create ($ level ,'My info message ' ,'app ' , datetime:new \DateTimeImmutable ('2013-05-29 16:21:54 ' ));
132+ $ this ->assertSame (!$ isBubbling ,$ handler ->handle ($ infoRecord ),'The handler bubbled correctly when it did not output the message. ' );
133+ }
134+
135+ public static function provideHandleOrBubbleSilentTests ():array
136+ {
137+ return [
138+ [OutputInterface::VERBOSITY_SILENT , Level::Warning,false ,true ],
139+ [OutputInterface::VERBOSITY_NORMAL , Level::Warning,true ,false ],
140+ [OutputInterface::VERBOSITY_SILENT , Level::Warning,true ,false , [OutputInterface::VERBOSITY_SILENT => Level::Warning]],
141+ [OutputInterface::VERBOSITY_SILENT , Level::Warning,false ,true , [OutputInterface::VERBOSITY_SILENT => Level::Error]],
142+ [OutputInterface::VERBOSITY_SILENT , Level::Emergency,false ,true ],
143+ [OutputInterface::VERBOSITY_SILENT , Level::Emergency,true ,false , [OutputInterface::VERBOSITY_SILENT => Level::Emergency]],
144+ ];
145+ }
146+
147+
104148public function testVerbosityChanged ()
105149 {
106150$ output =$ this ->createMock (OutputInterface::class);