Example #1
0
 /**
  * Translates the "read" call to DataStore
  *
  * @see \zaboy\scheduler\Callback\Factory\DataStoreAbstractFactory
  * @see \zaboy\rest\DataStore\Interfaces\DataStoresInterface
  * @param array $options
  * @return array|null
  * @throws CallbackException
  */
 private function read(array $options = [])
 {
     if (!isset($options['item_data']['id'])) {
         throw new CallbackException("Expected necessary parameter \"id\" in the options array");
     }
     return $this->dataStore->read($options['item_data']['id']);
 }
 public function test_scriptProxy()
 {
     // Clear log before testing
     $this->log->deleteAll();
     $callbackManager = $this->container->get('callback_manager');
     /** @var \zaboy\scheduler\Callback\Script $scriptCallback */
     $scriptProxyCallback = $callbackManager->get('test_scriptproxy_callback');
     $options = ['param1' => 'value1', 'param2' => ['value21', 'value22']];
     $scriptProxyCallback->call($options);
     // Expected that in the log will be one entry
     $item = $this->log->read(1);
     $this->assertEquals(print_r($options, 1), $item['step']);
     // Clear log again
     $this->log->deleteAll();
 }
 public function test_createFilterTask()
 {
     /** @var \zaboy\scheduler\Scheduler\Scheduler $scheduler */
     $scheduler = $this->container->get('scheduler');
     $filterData = $scheduler->create(['rql' => 'eq(tp_seconds,0)', 'callback' => function () {
         return 'ky';
     }, 'active' => 1]);
     $callbackServiceNameFromDataStore = $this->filterDs->read($filterData['id'])['callback'];
     $this->assertEquals($filterData['callback'], $callbackServiceNameFromDataStore);
     $filterData = $scheduler->read($filterData['id']);
     $callback = $filterData['callback'];
     $this->assertEquals('ky', $callback());
 }