File tree Expand file tree Collapse file tree 5 files changed +34
-1
lines changed Expand file tree Collapse file tree 5 files changed +34
-1
lines changed Original file line number Diff line number Diff line change 22
33## [ Unreleased]
44
5+ ### Fixed
6+ * Correct sanitation of job names which previously blocked creation of class based batch jobs
7+
58## v0.2.0 (2017-04-07)
69
710### Added
Original file line number Diff line number Diff line change 88 "LukeWaite\\ LaravelQueueAwsBatch\\ " : " src/"
99 }
1010 },
11+ "autoload-dev" : {
12+ "psr-4" : {
13+ ":vendor\\ :package_name\\ " : " tests"
14+ }
15+ },
1116 "require" : {
1217 "illuminate/support" : " ~5.1.0" ,
1318 "aws/aws-sdk-php" : " ^3.20.6"
Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ protected function getDisplayName($job)
6363 {
6464 if (is_object ($ job )) {
6565 return method_exists ($ job , 'displayName ' )
66- ? $ job ->displayName () : get_class ($ job );
66+ ? $ job ->displayName () : str_replace ( '\\' , ' _ ' , ( string ) get_class ($ job) );
6767 } else {
6868 return is_string ($ job ) ? explode ('@ ' , $ job )[0 ] : null ;
6969 }
Original file line number Diff line number Diff line change 11<?php
22
3+ namespace LukeWaite \LaravelQueueAwsBatch \Tests ;
4+
35use Mockery as m ;
46use PHPUnit \Framework \TestCase ;
57
Original file line number Diff line number Diff line change 11<?php
22
3+ namespace LukeWaite \LaravelQueueAwsBatch \Tests ;
4+
35use Mockery as m ;
46use PHPUnit \Framework \TestCase ;
57
@@ -51,6 +53,22 @@ public function testPushProperlyPushesJobOntoDatabase()
5153 $ this ->queue ->push ('foo ' , ['data ' ]);
5254 }
5355
56+ public function testPushProperlySanitizesJobName ()
57+ {
58+ $ this ->database ->shouldReceive ('table ' )->with ('table ' )->andReturn ($ query = m::mock ('StdClass ' ));
59+
60+ $ query ->shouldReceive ('insertGetId ' )->once ()->andReturnUsing (function ($ array ) {
61+ return 1 ;
62+ });
63+
64+ $ this ->batch ->shouldReceive ('submitJob ' )->once ()->andReturnUsing (function ($ array ) {
65+ $ this ->assertRegExp ('/^[a-zA-Z0-9_]+$/ ' , $ array ['jobName ' ]);
66+ $ this ->assertEquals ('LukeWaite_LaravelQueueAwsBatch_Tests_TestJob ' , $ array ['jobName ' ]);
67+ });
68+
69+ $ this ->queue ->push (new TestJob ());
70+ }
71+
5472 public function testGetJobById ()
5573 {
5674 $ this ->database ->shouldReceive ('table ' )->once ()->with ('table ' )->andReturn ($ query = m::mock ('StdClass ' ));
@@ -108,3 +126,8 @@ public function testReleaseWithDelayThrowsException()
108126 $ this ->queue ->release ('default ' , $ job , 10 );
109127 }
110128}
129+
130+ class TestJob
131+ {
132+ //
133+ }
You can’t perform that action at this time.
0 commit comments