| @@ 350-375 (lines=26) @@ | ||
| 347 | /** |
|
| 348 | * Test _mv method |
|
| 349 | */ |
|
| 350 | public function testMvToDir() |
|
| 351 | { |
|
| 352 | $srcFile = 'EbayEnterprise/Feed/ItemMaster/inbound/Sample1.xml'; |
|
| 353 | $targetFile = 'EbayEnterprise/Feed/ItemMaster/archive/Sample1.xml'; |
|
| 354 | $fileMock = $this->getMock('Varien_Io_File', array('mv')); |
|
| 355 | $fileMock->expects($this->once()) |
|
| 356 | ->method('mv') |
|
| 357 | ->with( |
|
| 358 | $this->equalTo($srcFile), |
|
| 359 | $this->equalTo($targetFile) |
|
| 360 | ) |
|
| 361 | ->will($this->returnValue(true)); |
|
| 362 | ||
| 363 | $feedModelMock = $this->getModelMockBuilder('ebayenterprise_catalog/feed_core') |
|
| 364 | ->disableOriginalConstructor() |
|
| 365 | ->setMethods(array('getFsTool')) |
|
| 366 | ->getMock(); |
|
| 367 | $feedModelMock->expects($this->once()) |
|
| 368 | ->method('getFsTool') |
|
| 369 | ->will($this->returnValue($fileMock)); |
|
| 370 | ||
| 371 | $this->assertSame( |
|
| 372 | $feedModelMock, |
|
| 373 | EcomDev_Utils_Reflection::invokeRestrictedMethod($feedModelMock, '_mv', array($srcFile, $targetFile)) |
|
| 374 | ); |
|
| 375 | } |
|
| 376 | /** |
|
| 377 | * If moving a file fails, an exception should be thrown |
|
| 378 | */ |
|
| @@ 379-402 (lines=24) @@ | ||
| 376 | /** |
|
| 377 | * If moving a file fails, an exception should be thrown |
|
| 378 | */ |
|
| 379 | public function testMvFail() |
|
| 380 | { |
|
| 381 | $srcFile = 'EbayEnterprise/Feed/ItemMaster/inbound/Sample1.xml'; |
|
| 382 | $targetFile = 'EbayEnterprise/Feed/ItemMaster/archive/Sample1.xml'; |
|
| 383 | $fileMock = $this->getMock('Varien_Io_File', array('mv')); |
|
| 384 | $fileMock->expects($this->once()) |
|
| 385 | ->method('mv') |
|
| 386 | ->with( |
|
| 387 | $this->equalTo($srcFile), |
|
| 388 | $this->equalTo($targetFile) |
|
| 389 | ) |
|
| 390 | ->will($this->returnValue(false)); |
|
| 391 | ||
| 392 | $feedModelMock = $this->getModelMockBuilder('ebayenterprise_catalog/feed_core') |
|
| 393 | ->disableOriginalConstructor() |
|
| 394 | ->setMethods(array('getFsTool')) |
|
| 395 | ->getMock(); |
|
| 396 | $feedModelMock->expects($this->once()) |
|
| 397 | ->method('getFsTool') |
|
| 398 | ->will($this->returnValue($fileMock)); |
|
| 399 | ||
| 400 | $this->setExpectedException('EbayEnterprise_Catalog_Exception_Feed_File', "Could not move {$srcFile} to {$targetFile}"); |
|
| 401 | EcomDev_Utils_Reflection::invokeRestrictedMethod($feedModelMock, '_mv', array($srcFile, $targetFile)); |
|
| 402 | } |
|
| 403 | /** |
|
| 404 | * Should call _mv with the local directory as the target directory. |
|
| 405 | */ |
|
| @@ 726-752 (lines=27) @@ | ||
| 723 | * @param string |
|
| 724 | * @dataProvider providerCanShowOrderCancelForm |
|
| 725 | */ |
|
| 726 | public function testCanShowOrderCancelForm($isPost, $hasReason, $result) |
|
| 727 | { |
|
| 728 | /** @var EbayEnterprise_Order_Helper_Data */ |
|
| 729 | $orderHelper = $this->getHelperMock('ebayenterprise_order/data', ['hasOrderCancelReason']); |
|
| 730 | $orderHelper->expects($this->once()) |
|
| 731 | ->method('hasOrderCancelReason') |
|
| 732 | ->will($this->returnValue($hasReason)); |
|
| 733 | ||
| 734 | /** @var Mock_Zend_Controller_Request_Abstract */ |
|
| 735 | $request = $this->getMockForAbstractClass('Zend_Controller_Request_Abstract'); |
|
| 736 | /** @var Mock_Zend_Controller_Response_Abstract */ |
|
| 737 | $response = $this->getMockForAbstractClass('Zend_Controller_Response_Abstract'); |
|
| 738 | ||
| 739 | /** @var Mock_EbayEnterprise_Order_OrderController */ |
|
| 740 | $controller = $this->getMockBuilder('EbayEnterprise_Order_OrderController') |
|
| 741 | ->setMethods(['_isOrderCancelPostAction']) |
|
| 742 | ->setConstructorArgs([$request, $response]) |
|
| 743 | ->getMock(); |
|
| 744 | $controller->expects($this->once()) |
|
| 745 | ->method('_isOrderCancelPostAction') |
|
| 746 | ->will($this->returnValue($isPost)); |
|
| 747 | ||
| 748 | // Replacing the protected class property EbayEnterprise_Order_OrderController::$_orderHelper with a mock. |
|
| 749 | EcomDev_Utils_Reflection::setRestrictedPropertyValue($controller, '_orderHelper', $orderHelper); |
|
| 750 | ||
| 751 | $this->assertSame($result, EcomDev_Utils_Reflection::invokeRestrictedMethod($controller, '_canShowOrderCancelForm', [])); |
|
| 752 | } |
|
| 753 | ||
| 754 | /** |
|
| 755 | * @return array |
|