woocommerce_segment = $this->createMock(WooCommerceSegment::class); $this->woocommerce_helper = $this->createMock(WooCommerceHelper::class); $this->worker = new WooCommerceSync($this->woocommerce_segment, $this->woocommerce_helper, microtime(true)); } function testItWillNotRunIfWooCommerceIsDisabled() { $this->woocommerce_helper->method('isWooCommerceActive') ->willReturn(false); expect($this->worker->checkProcessingRequirements())->false(); } function testItWillRunIfWooCommerceIsEnabled() { $this->woocommerce_helper->method('isWooCommerceActive') ->willReturn(true); expect($this->worker->checkProcessingRequirements())->true(); } function testItCallsWooCommerceSync() { $this->woocommerce_segment->expects($this->once()) ->method('synchronizeCustomers'); $task = $this->createScheduledTask(); expect($this->worker->processTaskStrategy($task))->equals(true); } private function createScheduledTask() { $task = ScheduledTask::create(); $task->type = WooCommerceSync::TASK_TYPE; $task->status = null; $task->scheduled_at = Carbon::createFromTimestamp(current_time('timestamp')); $task->save(); return $task; } function _after() { \ORM::raw_execute('TRUNCATE ' . ScheduledTask::$_table); } }