示例#1
0
 public function testSendPerSubscriber2()
 {
     $this->queue->setQueueStatus(1);
     $this->queue->setQueueStartAt(1);
     $collection = $this->getMockBuilder('\\Magento\\Framework\\Data\\Collection')->disableOriginalConstructor()->setMethods(['getItems'])->getMock();
     $item = $this->getMockBuilder('\\Magento\\Newsletter\\Model\\Subscriber')->disableOriginalConstructor()->setMethods(['getStoreId', 'getSubscriberEmail', 'getSubscriberFullName', 'received'])->getMock();
     $transport = $this->getMock('\\Magento\\Framework\\Mail\\TransportInterface');
     $this->subscribersCollection->expects($this->once())->method('getQueueJoinedFlag')->willReturn(false);
     $this->subscribersCollection->expects($this->once())->method('useQueue')->with($this->queue)->willReturnSelf();
     $this->subscribersCollection->expects($this->once())->method('getSize')->willReturn(5);
     $this->subscribersCollection->expects($this->once())->method('useOnlyUnsent')->willReturnSelf();
     $this->subscribersCollection->expects($this->once())->method('showCustomerInfo')->willReturnSelf();
     $this->subscribersCollection->expects($this->once())->method('setPageSize')->willReturnSelf();
     $this->subscribersCollection->expects($this->once())->method('setCurPage')->willReturnSelf();
     $this->subscribersCollection->expects($this->once())->method('load')->willReturn($collection);
     $this->transportBuilder->expects($this->once())->method('setTemplateData')->willReturnSelf();
     $collection->expects($this->atLeastOnce())->method('getItems')->willReturn([$item]);
     $item->expects($this->once())->method('getStoreId')->willReturn('store_id');
     $item->expects($this->once())->method('getSubscriberEmail')->willReturn('email');
     $item->expects($this->once())->method('getSubscriberFullName')->willReturn('full_name');
     $this->transportBuilder->expects($this->once())->method('setTemplateOptions')->willReturnSelf();
     $this->transportBuilder->expects($this->once())->method('setTemplateVars')->willReturnSelf();
     $this->transportBuilder->expects($this->once())->method('setFrom')->willReturnSelf();
     $this->transportBuilder->expects($this->once())->method('addTo')->willReturnSelf();
     $this->transportBuilder->expects($this->once())->method('getTransport')->willReturn($transport);
     $item->expects($this->once())->method('received')->with($this->queue)->willReturnSelf();
     $this->assertEquals($this->queue, $this->queue->sendPerSubscriber());
 }