5
5
use Enqueue \Consumption \Extension \LimitConsumedMessagesExtension ;
6
6
use Enqueue \Consumption \Extension \LimitConsumerMemoryExtension ;
7
7
use Enqueue \Consumption \Extension \LimitConsumptionTimeExtension ;
8
+ use Enqueue \Consumption \Extension \NicenessExtension ;
8
9
use Enqueue \Tests \Symfony \Consumption \Mock \LimitsExtensionsCommand ;
9
10
use PHPUnit \Framework \TestCase ;
10
11
use Symfony \Component \Console \Tester \CommandTester ;
@@ -17,10 +18,11 @@ public function testShouldAddExtensionsOptions()
17
18
18
19
$ options = $ trait ->getDefinition ()->getOptions ();
19
20
20
- $ this ->assertCount (3 , $ options );
21
+ $ this ->assertCount (4 , $ options );
21
22
$ this ->assertArrayHasKey ('memory-limit ' , $ options );
22
23
$ this ->assertArrayHasKey ('message-limit ' , $ options );
23
24
$ this ->assertArrayHasKey ('time-limit ' , $ options );
25
+ $ this ->assertArrayHasKey ('niceness ' , $ options );
24
26
}
25
27
26
28
public function testShouldAddMessageLimitExtension ()
@@ -57,7 +59,8 @@ public function testShouldAddTimeLimitExtension()
57
59
58
60
public function testShouldThrowExceptionIfTimeLimitExpressionIsNotValid ()
59
61
{
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 ' );
61
64
62
65
$ command = new LimitsExtensionsCommand ('name ' );
63
66
@@ -104,4 +107,18 @@ public function testShouldAddThreeLimitExtensions()
104
107
$ this ->assertInstanceOf (LimitConsumptionTimeExtension::class, $ result [1 ]);
105
108
$ this ->assertInstanceOf (LimitConsumerMemoryExtension::class, $ result [2 ]);
106
109
}
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
+ }
107
124
}
0 commit comments