55use Enqueue \Consumption \Extension \LimitConsumedMessagesExtension ;
66use Enqueue \Consumption \Extension \LimitConsumerMemoryExtension ;
77use Enqueue \Consumption \Extension \LimitConsumptionTimeExtension ;
8+ use Enqueue \Consumption \Extension \NicenessExtension ;
89use Enqueue \Tests \Symfony \Consumption \Mock \LimitsExtensionsCommand ;
910use PHPUnit \Framework \TestCase ;
1011use Symfony \Component \Console \Tester \CommandTester ;
@@ -17,10 +18,11 @@ public function testShouldAddExtensionsOptions()
1718
1819 $ options = $ trait ->getDefinition ()->getOptions ();
1920
20- $ this ->assertCount (3 , $ options );
21+ $ this ->assertCount (4 , $ options );
2122 $ this ->assertArrayHasKey ('memory-limit ' , $ options );
2223 $ this ->assertArrayHasKey ('message-limit ' , $ options );
2324 $ this ->assertArrayHasKey ('time-limit ' , $ options );
25+ $ this ->assertArrayHasKey ('niceness ' , $ options );
2426 }
2527
2628 public function testShouldAddMessageLimitExtension ()
@@ -57,7 +59,8 @@ public function testShouldAddTimeLimitExtension()
5759
5860 public function testShouldThrowExceptionIfTimeLimitExpressionIsNotValid ()
5961 {
60- $ this ->setExpectedException (\Exception::class, 'Failed to parse time string (time is not valid) at position ' );
62+ $ this ->expectException (\Exception::class);
63+ $ this ->expectExceptionMessage ('Failed to parse time string (time is not valid) at position ' );
6164
6265 $ command = new LimitsExtensionsCommand ('name ' );
6366
@@ -104,4 +107,18 @@ public function testShouldAddThreeLimitExtensions()
104107 $ this ->assertInstanceOf (LimitConsumptionTimeExtension::class, $ result [1 ]);
105108 $ this ->assertInstanceOf (LimitConsumerMemoryExtension::class, $ result [2 ]);
106109 }
110+
111+ public function testShouldAddNicenessExtension ()
112+ {
113+ $ command = new LimitsExtensionsCommand ('name ' );
114+ $ tester = new CommandTester ($ command );
115+ $ tester ->execute ([
116+ '--niceness ' => 1 ,
117+ ]);
118+
119+ $ result = $ command ->getExtensions ();
120+ $ this ->assertCount (1 , $ result );
121+
122+ $ this ->assertInstanceOf (NicenessExtension::class, $ result [0 ]);
123+ }
107124}
0 commit comments