Can';t在集成测试中保存Magento2产品
我正在为一个名为的项目进行集成测试 我正在使用最新版本的Magento CE 它需要以编程方式设置一些fixture产品,但是Magento似乎没有将产品保存到数据库中 我有一个密码,密码摘录如下:Can';t在集成测试中保存Magento2产品,magento2,Magento2,我正在为一个名为的项目进行集成测试 我正在使用最新版本的Magento CE 它需要以编程方式设置一些fixture产品,但是Magento似乎没有将产品保存到数据库中 我有一个密码,密码摘录如下: // given a yaml file $yamlParser = new Parser(); $testCatalogPriceRules = $yamlParser->parse(file_get_contents($this->testCatalogPr
// given a yaml file
$yamlParser = new Parser();
$testCatalogPriceRules = $yamlParser->parse(file_get_contents($this->testCatalogPriceRulesYamlPath), true);
// and a sample product
/** @var \Magento\Catalog\Model\Product */
$productModel = Bootstrap::getObjectManager()
->get('\Magento\Catalog\Model\Product');
$productModel->setName("Cool 123");
$productModel->setAttributeSetId(1);
$productModel->setShortDescription("Cool 123");
$productModel->setWebsiteIds(array(1));
$productModel->setVisibility(4);
$productModel->setDescription("Cool 123");
$productModel->setSku("SKU");
$productModel->save();
// and a customer group
// when we run the AdminRoles component
$this->catalogPriceRulesComponent->processData($testCatalogPriceRules);
// then it should enter new catalog price rules into the database
问题是,这就是我运行测试的原因吗
/var/www/magento2/dev/tests/integration$ ../../../vendor/bin/phpunit --testsuite "magento2-configurator" --filter="testShouldCreateNewCatalogPriceRulesFromYamlFile"
并使用mysqldump检查数据库,似乎没有输入任何内容
ubuntu@ubuntu-xenial:/var/www/magento2/var/log$ mysqldump -u root -p magento_integration_tests | grep -i "Cool" -C5
mysqldump: [Warning] Using a password on the command line interface can be insecure.
-- Dumping data for table `url_rewrite`
--
LOCK TABLES `url_rewrite` WRITE;
/*!40000 ALTER TABLE `url_rewrite` DISABLE KEYS */;
INSERT INTO `url_rewrite` VALUES (1,'cms-page',1,'no-route','cms/page/view/page_id/1',0,1,NULL,1,NULL),(2,'cms-page',2,'home','cms/page/view/page_id/2',0,1,NULL,1,NULL),(3,'cms-page',3,'enable-cookies','cms/page/view/page_id/3',0,1,NULL,1,NULL),(4,'cms-page',4,'privacy-policy-cookie-restriction-mode','cms/page/view/page_id/4',0,1,NULL,1,NULL),(5,'product',1,'cool-123.html','catalog/product/view/id/1',0,1,NULL,1,NULL);
/*!40000 ALTER TABLE `url_rewrite` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `variable`
转储它返回的内容$this->catalogPriceRulesComponent->processData($testCatalogPriceRules)$productModel->save()$productModel->save()->getId()返回1。我必须安装xdebug,因为有一些循环引用阻止了print\r和friends的工作。