Exemple #1
0
    /**
     * Check postAction method and assert that review model storeId equals null.
     */
    public function testPostAction()
    {
        $this->requestMock->expects($this->any())
            ->method('getParam')
            ->willReturnMap(
                [
                    ['product_id', false, 1],
                    ['ratings', [], ['1' => '1']]
                ]
            );
        $this->requestMock->expects($this->once())
            ->method('getPostValue')
            ->willReturn(['status_id' => 1]);
        $this->objectManagerMock->expects($this->any())
            ->method('get')
            ->with('Magento\Store\Model\StoreManagerInterface')
            ->willReturn($this->storeManagerMock);
        $this->reviewFactoryMock->expects($this->once())
            ->method('create')
            ->willReturn($this->reviewMock);
        $this->ratingFactoryMock->expects($this->once())
            ->method('create')
            ->willReturn($this->ratingMock);
        $this->storeManagerMock->expects($this->once())
            ->method('hasSingleStore')
            ->willReturn(true);
        $this->storeManagerMock->expects($this->once())
            ->method('getStore')
            ->willReturn($this->storeModelMock);
        $this->storeModelMock->expects($this->once())
            ->method('getId')
            ->willReturn(1);
        $this->reviewMock->expects($this->once())
            ->method('save')
            ->willReturn($this->reviewMock);
        $this->reviewMock->expects($this->once())
            ->method('getId')
            ->willReturn(1);
        $this->reviewMock->expects($this->once())
            ->method('aggregate')
            ->willReturn($this->reviewMock);
        $this->ratingMock->expects($this->once())
            ->method('setRatingId')
            ->willReturnSelf();
        $this->ratingMock->expects($this->once())
            ->method('setReviewId')
            ->willReturnSelf();
        $this->ratingMock->expects($this->once())
            ->method('addOptionVote')
            ->willReturnSelf();

        $this->assertSame($this->resultRedirectMock, $this->postController->executeInternal());
    }
 public function testToHtmlCoreRegistryRatingData()
 {
     $this->registry->expects($this->any())->method('registry')->will($this->returnValue($this->rating));
     $this->form->expects($this->at(7))->method('getElement')->will($this->returnValue($this->element));
     $this->form->expects($this->at(13))->method('getElement')->will($this->returnValue($this->element));
     $this->form->expects($this->at(16))->method('getElement')->will($this->returnValue($this->element));
     $this->form->expects($this->at(17))->method('getElement')->will($this->returnValue($this->element));
     $this->form->expects($this->any())->method('getElement')->will($this->returnValue(false));
     $this->session->expects($this->any())->method('getRatingData')->will($this->returnValue(false));
     $ratingCodes = ['rating_codes' => ['0' => 'rating_code']];
     $this->rating->expects($this->any())->method('getRatingCodes')->will($this->returnValue($ratingCodes));
     $this->block->toHtml();
 }