Skip to content

Commit 44694c1

Browse files
exptomhellogerard
authored andcommitted
Helper "get" methods. (jobbyphp#72)
Added getConfig() to BackgroundJob Added getJobs() to Jobby
1 parent 9cb6566 commit 44694c1

File tree

4 files changed

+52
-0
lines changed

4 files changed

+52
-0
lines changed

src/BackgroundJob.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,14 @@ public function run()
107107
}
108108
}
109109

110+
/**
111+
* @return array
112+
*/
113+
public function getConfig()
114+
{
115+
return $this->config;
116+
}
117+
110118
/**
111119
* @param string $lockFile
112120
*

src/Jobby.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,14 @@ public function getConfig()
9797
return $this->config;
9898
}
9999

100+
/**
101+
* @return array
102+
*/
103+
public function getJobs()
104+
{
105+
return $this->jobs;
106+
}
107+
100108
/**
101109
* Add a job.
102110
*

tests/BackgroundJobTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,15 @@ public function runProvider()
7171
];
7272
}
7373

74+
/**
75+
* @covers ::getConfig
76+
*/
77+
public function testGetConfig()
78+
{
79+
$job = new BackgroundJob('test job',[]);
80+
$this->assertInternalType('array',$job->getConfig());
81+
}
82+
7483
/**
7584
* @dataProvider runProvider
7685
*

tests/JobbyTest.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,33 @@ public function testSetConfig()
246246
$this->assertEquals('foo bar', $newCfg['dateFormat']);
247247
}
248248

249+
/**
250+
* @covers ::getJobs
251+
*/
252+
public function testGetJobs()
253+
{
254+
$jobby = new Jobby();
255+
$this->assertCount(0,$jobby->getJobs());
256+
257+
$jobby->add(
258+
'test job1',
259+
[
260+
'command' => 'test',
261+
'schedule' => '* * * * *'
262+
]
263+
);
264+
265+
$jobby->add(
266+
'test job2',
267+
[
268+
'command' => 'test',
269+
'schedule' => '* * * * *'
270+
]
271+
);
272+
273+
$this->assertCount(2,$jobby->getJobs());
274+
}
275+
249276
/**
250277
* @covers ::add
251278
* @expectedException \Jobby\Exception

0 commit comments

Comments
 (0)