/**
     * @param bool $isValidSame
     * @param bool $isValid
     * @param array $expected
     * @dataProvider constructorDataProvider
     */
    public function testConstructor($isValidSame, $isValid, $expected)
    {
        $validatorMock = $this->getMockBuilder('Magento\Framework\Validator\ValidatorInterface')
            ->disableOriginalConstructor()
            ->getMock();
        if ($isValidSame) {
            $validatorMock->expects($this->any())
                ->method('isValid')
                ->willReturn($isValid);
        } else {
            for ($x = 0; $x<6; $x++) {
                if ($x % 2 == 0) {
                    $validatorMock->expects($this->at($x))
                        ->method('isValid')
                        ->willReturn(false);
                } else {
                    $validatorMock->expects($this->at($x))
                        ->method('isValid')
                        ->willReturn(true);
                }
            }
        }

        $this->getModel($validatorMock);

        $this->assertEquals($expected, $this->config->getOptions());
    }
예제 #2
0
 /**
  * @param \Magento\Framework\ValidatorFactory $validatorFactory
  * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
  * @param \Magento\Framework\Stdlib\StringUtils $stringHelper
  * @param \Magento\Framework\App\RequestInterface $request
  * @param Filesystem $filesystem
  * @param DeploymentConfig $deploymentConfig
  * @param string $scopeType
  * @param \Magento\Backend\App\BackendAppList $backendAppList
  * @param FrontNameResolver $frontNameResolver
  * @param \Magento\Backend\Model\UrlFactory $backendUrlFactory
  * @param string $lifetimePath
  * @param string $sessionName
  * @SuppressWarnings(PHPMD.ExcessiveParameterList)
  */
 public function __construct(
     \Magento\Framework\ValidatorFactory $validatorFactory,
     \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
     \Magento\Framework\Stdlib\StringUtils $stringHelper,
     \Magento\Framework\App\RequestInterface $request,
     Filesystem $filesystem,
     DeploymentConfig $deploymentConfig,
     $scopeType,
     \Magento\Backend\App\BackendAppList $backendAppList,
     FrontNameResolver $frontNameResolver,
     \Magento\Backend\Model\UrlFactory $backendUrlFactory,
     $lifetimePath = self::XML_PATH_COOKIE_LIFETIME,
     $sessionName = self::SESSION_NAME_ADMIN
 ) {
     parent::__construct(
         $validatorFactory,
         $scopeConfig,
         $stringHelper,
         $request,
         $filesystem,
         $deploymentConfig,
         $scopeType,
         $lifetimePath
     );
     $this->_frontNameResolver = $frontNameResolver;
     $this->backendAppList = $backendAppList;
     $this->backendUrlFactory = $backendUrlFactory;
     $adminPath = $this->extractAdminPath();
     $this->setCookiePath($adminPath);
     $this->setName($sessionName);
 }
예제 #3
0
 /**
  * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
  * @param \Magento\Framework\Stdlib\String $stringHelper
  * @param \Magento\Framework\App\RequestInterface $request
  * @param \Magento\Framework\App\State $appState
  * @param \Magento\Framework\App\Filesystem $filesystem
  * @param string $scopeType
  * @param FrontNameResolver $frontNameResolver
  * @param string $saveMethod
  * @param null|string $savePath
  * @param null|string $cacheLimiter
  * @param string $lifetimePath
  * @SuppressWarnings(PHPMD.ExcessiveParameterList)
  */
 public function __construct(\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\Stdlib\String $stringHelper, \Magento\Framework\App\RequestInterface $request, \Magento\Framework\App\State $appState, \Magento\Framework\App\Filesystem $filesystem, $scopeType, FrontNameResolver $frontNameResolver, $saveMethod = \Magento\Framework\Session\SaveHandlerInterface::DEFAULT_HANDLER, $savePath = null, $cacheLimiter = null, $lifetimePath = self::XML_PATH_COOKIE_LIFETIME)
 {
     parent::__construct($scopeConfig, $stringHelper, $request, $appState, $filesystem, $scopeType, $saveMethod, $savePath, $cacheLimiter, $lifetimePath);
     $this->frontNameResolver = $frontNameResolver;
     $baseUrl = $this->_httpRequest->getBaseUrl();
     $adminPath = $this->extractAdminPath($baseUrl);
     $this->setCookiePath($adminPath);
 }
예제 #4
0
 /**
  * @dataProvider savePathDataProvider
  */
 public function testConstructorSavePath($existing, $given, $expected)
 {
     $sessionSavePath = ini_get('session.save_path');
     if ($expected === 'default') {
         $expected = $this->defaultSavePath . '/';
     }
     $setup = ini_set('session.save_path', $existing);
     if ($setup === false) {
         $this->markTestSkipped('Cannot set session.save_path with ini_set');
     }
     $this->deploymentConfigMock->expects($this->at(0))->method('get')->with(Config::PARAM_SESSION_SAVE_PATH)->will($this->returnValue($given));
     $this->_model = $this->_objectManager->create('Magento\\Framework\\Session\\Config', ['deploymentConfig' => $this->deploymentConfigMock]);
     $this->assertEquals($expected, $this->_model->getOption('save_path'));
     if ($sessionSavePath != ini_get('session.save_path')) {
         ini_set('session.save_path', $sessionSavePath);
     }
 }
예제 #5
0
파일: Data.php 프로젝트: koliaGI/magento2
 /**
  * @return string
  */
 public function getDomain()
 {
     return $this->config->getValidDomain();
 }
예제 #6
0
 public function testSetSavePath()
 {
     $this->config->setSavePath('some_save_path');
     $this->assertEquals($this->config->getOption('save_path'), 'some_save_path');
 }
예제 #7
0
 /**
  * @magentoAppIsolation enabled
  */
 public function testGetSessionSaveMethod()
 {
     $this->assertEquals('files', $this->_model->getSaveHandler());
 }