woocommerceSegment = $this->createMock(WooCommerceSegment::class); $this->woocommerceHelper = $this->createMock(WooCommerceHelper::class); $this->scheduledTaskFactory = new ScheduledTaskFactory(); $this->worker = new WooCommerceSync($this->woocommerceSegment, $this->woocommerceHelper); } public function testItWillNotRunIfWooCommerceIsDisabled() { $this->woocommerceHelper->method('isWooCommerceActive') ->willReturn(false); verify($this->worker->checkProcessingRequirements())->false(); } public function testItWillRunIfWooCommerceIsEnabled() { $this->woocommerceHelper->method('isWooCommerceActive') ->willReturn(true); verify($this->worker->checkProcessingRequirements())->true(); } public function testItCallsWooCommerceSync() { $this->tester->createWooCommerceOrder(); $woocommerceHelper = $this->diContainer->get(WooCommerceHelper::class); $worker = new WooCommerceSync($this->woocommerceSegment, $woocommerceHelper); $this->woocommerceSegment->expects($this->once()) ->method('synchronizeCustomers') ->with(0, $this->greaterThan(0), WooCommerceSync::BATCH_SIZE) ->willReturn(1000); $task = $this->scheduledTaskFactory->create( WooCommerceSync::TASK_TYPE, null, Carbon::now()->millisecond(0) ); verify($worker->processTaskStrategy($task, microtime(true)))->equals(true); } }