Skip to content

Commit

Permalink
Helper "get" methods. (#72)
Browse files Browse the repository at this point in the history
Added getConfig() to BackgroundJob
Added getJobs() to Jobby
  • Loading branch information
exptom authored and hellogerard committed Jan 9, 2017
1 parent 9cb6566 commit 44694c1
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/BackgroundJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@ public function run()
}
}

/**
* @return array
*/
public function getConfig()
{
return $this->config;
}

/**
* @param string $lockFile
*
Expand Down
8 changes: 8 additions & 0 deletions src/Jobby.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ public function getConfig()
return $this->config;
}

/**
* @return array
*/
public function getJobs()
{
return $this->jobs;
}

/**
* Add a job.
*
Expand Down
9 changes: 9 additions & 0 deletions tests/BackgroundJobTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ public function runProvider()
];
}

/**
* @covers ::getConfig
*/
public function testGetConfig()
{
$job = new BackgroundJob('test job',[]);
$this->assertInternalType('array',$job->getConfig());
}

/**
* @dataProvider runProvider
*
Expand Down
27 changes: 27 additions & 0 deletions tests/JobbyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,33 @@ public function testSetConfig()
$this->assertEquals('foo bar', $newCfg['dateFormat']);
}

/**
* @covers ::getJobs
*/
public function testGetJobs()
{
$jobby = new Jobby();
$this->assertCount(0,$jobby->getJobs());

$jobby->add(
'test job1',
[
'command' => 'test',
'schedule' => '* * * * *'
]
);

$jobby->add(
'test job2',
[
'command' => 'test',
'schedule' => '* * * * *'
]
);

$this->assertCount(2,$jobby->getJobs());
}

/**
* @covers ::add
* @expectedException \Jobby\Exception
Expand Down

0 comments on commit 44694c1

Please sign in to comment.