/**
     * @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());
    }
 public function testGetOptions()
 {
     $appStateProperty = new \ReflectionProperty('Magento\\Framework\\Session\\Config', 'options');
     $appStateProperty->setAccessible(true);
     $original = $appStateProperty->getValue($this->config);
     $valueForTest = array('test' => 'test2');
     $appStateProperty->setValue($this->config, $valueForTest);
     $this->assertEquals($valueForTest, $this->config->getOptions());
     $this->assertEquals($valueForTest, $this->config->toArray());
     $appStateProperty->setValue($this->config, $original);
     $this->assertEquals($original, $this->config->getOptions());
     $this->assertEquals($original, $this->config->toArray());
 }
Beispiel #3
0
 public function testSetOptionsInvalidValue()
 {
     $preValue = $this->_model->getOptions();
     $this->_model->setOptions('');
     $this->assertEquals($preValue, $this->_model->getOptions());
 }