/** * Test loading a Yaml file */ public function testSupportsWithYamlFile() { $this->yamlLoader->expects($this->once())->method('isFile')->willReturn(true); $this->yamlLoader->expects($this->once())->method('validateExtension')->willReturn(true); $yamlFile = Fixtures::getSampleYamlFile(); $this->assertTrue($this->yamlLoader->supports($yamlFile)); }
/** * @covers \Magento\Theme\Model\Config\Customization::isThemeAssignedToStore */ public function testIsThemeAssignedToDefaultStore() { $this->storeManager->expects($this->once())->method('getStores')->willReturn([$this->getStore()]); $this->designPackage->expects($this->once())->method('getConfigurationDesignTheme')->willReturn($this->getAssignedTheme()->getId()); $this->themeProviderMock->expects($this->once())->method('getThemeCustomizations')->with(Area::AREA_FRONTEND)->willReturn([$this->getAssignedTheme(), $this->getUnassignedTheme()]); $themeAssigned = $this->model->isThemeAssignedToStore($this->getAssignedTheme()); $this->assertEquals(true, $themeAssigned); }
public function testAddSinglePath() { $this->mockFilesystem->expects($this->once())->method('exists')->with($this->equalTo('PATH/NAME.EXT'))->willReturn(true); $this->fileFinder->addFileExtensions('EXT'); $this->fileFinder->addPaths('PATH'); $expected = 'PATH/NAME.EXT'; $actual = $this->fileFinder->find('NAME'); $this->assertSame($expected, $actual); }
/** * @test */ public function an_prepended_file_extension_will_be_searched_first() { $this->mockFilesystem->expects($this->at(0))->method('exists')->with($this->equalTo('PATH/NAME.EXT2'))->will($this->returnValue(false)); $this->mockFilesystem->expects($this->at(1))->method('exists')->with($this->equalTo('PATH/NAME.EXT1'))->will($this->returnValue(true)); $this->nsFileFinder->addPaths('PATH'); $this->nsFileFinder->addFileExtensions('EXT1'); $this->nsFileFinder->addFileExtensions('EXT2', true); // Prepend! $actual = $this->nsFileFinder->find('NAME'); $expected = 'PATH/NAME.EXT1'; $this->assertSame($expected, $actual); }
/** * @test */ public function handleRequestUpdatedMobileDetectorUserAgent() { $this->mobileDetector->expects($this->once())->method('setUserAgent')->with($this->equalTo('agent')); $event = $this->createGetResponseEvent('some content'); $event->getRequest()->headers->set('user-agent', 'agent'); $listener = new RequestListener($this->serviceContainer, $this->config); $listener->handleRequest($event); }
/** * @covers \Magento\Theme\Model\Config\Customization::isThemeAssignedToStore */ public function testIsThemeAssignedToDefaultStore() { $this->_storeManager->expects($this->once())->method('getStores')->will($this->returnValue(array($this->_getStore()))); $this->_designPackage->expects($this->once())->method('getConfigurationDesignTheme')->will($this->returnValue($this->_getAssignedTheme()->getId())); $this->themeProviderMock->expects($this->once())->method('getThemeCustomizations')->with(\Magento\Framework\App\Area::AREA_FRONTEND)->will($this->returnValue(array($this->_getAssignedTheme(), $this->_getUnassignedTheme()))); $themeAssigned = $this->_model->isThemeAssignedToStore($this->_getAssignedTheme()); $this->assertEquals(true, $themeAssigned); }
/** * @expectedException \SlevomatZboziApi\Response\ResponseErrorException * @expectedExceptionMessage Slevomat API invalid response: invalid JSON data. */ public function testResponseErrorExceptionIsThrownForResponseWithInvalidJsonData() { $this->loggerMock->expects(self::once())->method('log'); $this->httpClientMock->method('createRequest')->willReturn(new \GuzzleHttp\Message\Request('POST', 'someUrl')); $this->httpClientMock->method('send')->willReturn($this->createFutureResponse(200, '{"someData":xxx}')); $requestMaker = $this->createRequestMaker(); $requestMaker->sendPostRequest('somerUrl'); }
public function testVisitMetadataNotCurrentUser() { $this->securityFacade->expects($this->once())->method('getLoggedUser')->will($this->returnValue(null)); $config = $this->getMockBuilder('Oro\\Bundle\\DataGridBundle\\Datagrid\\Common\\DatagridConfiguration')->disableOriginalConstructor()->getMock(); $data = MetadataObject::createNamed('test-grid', []); $result = $this->extension->visitMetadata($config, $data); $this->assertEquals(null, $result); }
public function testForecastOfOpportunitiesValuesWithBusinessUnits() { $user = new User(); $user->setId(1); $businessUnit = new BusinessUnit(); $businessUnit->addUser($user); $options = ['owners' => [], 'businessUnits' => [$businessUnit]]; $widgetOptions = new WidgetOptionBag($options); $this->opportunityRepository->expects($this->any())->method('getForecastOfOpporunitiesData')->with([$user->getId()], null, $this->aclHelper)->will($this->returnValue(['inProgressCount' => 5, 'budgetAmount' => 1000, 'weightedForecast' => 500])); $this->businessUnitRepository->expects($this->any())->method('findById')->will($this->returnValue([$businessUnit])); $result = $this->provider->getForecastOfOpportunitiesValues($widgetOptions, 'getInProgressValues', 'integer', false); $this->assertEquals(['value' => 5], $result); $result = $this->provider->getForecastOfOpportunitiesValues($widgetOptions, 'getTotalForecastValues', 'currency', false); $this->assertEquals(['value' => 1000], $result); $result = $this->provider->getForecastOfOpportunitiesValues($widgetOptions, 'getWeightedForecastValues', 'currency', false); $this->assertEquals(['value' => 500], $result); }
/** * Test isJson method with invalid JSON string. * Valid scenario is tested by the method above */ public function testSupportsWithNonJsonString() { $this->jsonLoader->expects($this->once())->method('isFile')->willReturn(false); $someString = Fixtures::getSampleString(); $this->assertFalse($this->jsonLoader->supports($someString)); }