Eccube\Tests\Web\Admin\Product\ProductControllerTest::testNewWithPostTaxRate PHP Method

testNewWithPostTaxRate() public method

public testNewWithPostTaxRate ( $taxRate, $expected )
$taxRate
$expected
    public function testNewWithPostTaxRate($taxRate, $expected)
    {
        // Give
        $BaseInfo = $this->app['eccube.repository.base_info']->get();
        $BaseInfo->setOptionProductTaxRule(Constant::ENABLED);
        $formData = $this->createFormData();
        $formData['class']['tax_rate'] = $taxRate;
        // When
        $this->client->request('POST', $this->app->url('admin_product_product_new'), array('admin_product' => $formData));
        // Then
        $this->assertTrue($this->client->getResponse()->isRedirection());
        $arrTmp = explode('/', $this->client->getResponse()->getTargetUrl());
        $productId = $arrTmp[count($arrTmp) - 2];
        $Product = $this->app['eccube.repository.product']->find($productId);
        $this->expected = $expected;
        $Taxrule = $this->app['eccube.repository.tax_rule']->findOneBy(array('Product' => $Product));
        $taxRate = is_null($taxRate) ? null : $Taxrule->getTaxRate();
        $this->actual = $taxRate;
        $this->assertTrue($this->actual === $this->expected);
    }