12 require_once(dirname(dirname(dirname(__DIR__))) .
'/lib/php/Test/Reflectory.php');
13 require_once(dirname(dirname(dirname(__DIR__))) .
'/lib/php/Plugin/FO_Plugin.php');
14 require_once(dirname(dirname(dirname(__DIR__))) .
'/lib/php/common-plugin.php');
15 require_once(__DIR__ .
'/../../ui/agent-kotoba.php');
30 private $assertCountBefore;
36 protected function setUp():
void
38 $this->assertCountBefore = \Hamcrest\MatcherAssert::getCount();
40 global $container, $Plugins;
41 $this->
dbManager = M::mock(DbManager::class);
42 $container = M::mock(
'ContainerBuilder');
43 $container->shouldReceive(
'get')->with(
'db.manager')->andReturn($this->
dbManager);
49 protected function tearDown():
void
51 $this->addToAssertionCount(\Hamcrest\MatcherAssert::getCount() - $this->assertCountBefore);
59 $Plugins[$pluginName] = (object) [
'AgentName' => $agentName];
74 $this->
dbManager->shouldReceive(
'getSingleRow')
76 ->with(M::pattern(
'/jq_endtime IS NULL/'), [
'scancode', 42])
77 ->andReturn([
'jq_pk' => 7]);
79 $result = Reflectory::invokeObjectsMethodnameWith(
80 $this->plugin,
'isAgentScheduledForUpload', [42,
'agent_scancode']
83 $this->assertTrue($result);
97 $this->
dbManager->shouldReceive(
'getSingleRow')->once()->andReturn(
null);
99 $result = Reflectory::invokeObjectsMethodnameWith(
100 $this->plugin,
'isAgentScheduledForUpload', [42,
'agent_scancode']
103 $this->assertFalse($result);
114 $this->
dbManager->shouldNotReceive(
'getSingleRow');
116 $result = Reflectory::invokeObjectsMethodnameWith(
117 $this->plugin,
'isAgentScheduledForUpload', [42,
'agent_unknown']
120 $this->assertFalse($result);
133 $this->
dbManager->shouldReceive(
'getSingleRow')
135 ->with(M::any(), [
'nomos', 99])
136 ->andReturn([
'jq_pk' => 1]);
137 $this->
dbManager->shouldReceive(
'getSingleRow')
139 ->with(M::any(), [
'scancode', 99])
142 $nomosResult = Reflectory::invokeObjectsMethodnameWith(
143 $this->plugin,
'isAgentScheduledForUpload', [99,
'agent_nomos']
145 $scancodeResult = Reflectory::invokeObjectsMethodnameWith(
146 $this->plugin,
'isAgentScheduledForUpload', [99,
'agent_scancode']
149 $this->assertTrue($nomosResult);
150 $this->assertFalse($scancodeResult);
Test for class KotobaAgentPlugin::isAgentScheduledForUpload()
testReturnsFalseWhenAgentHasNoJob()
testReturnsFalseWithoutDbQueryWhenPluginNotFound()
registerStubPlugin($pluginName, $agentName)
testChecksEachAgentIndependently()
testReturnsTrueWhenAgentHasAnUnfinishedJob()
fo_dbManager * dbManager
fo_dbManager object