2020-04-05 10:36:45 +03:00
|
|
|
<?php
|
2022-01-10 12:53:00 +03:00
|
|
|
/**
|
|
|
|
* PHP version 5.6
|
|
|
|
*
|
|
|
|
* Class WC_Retailcrm_Icml_Test - Testing WC_Retailcrm_Icml.
|
|
|
|
*
|
|
|
|
* @category Integration
|
|
|
|
* @author RetailCRM <integration@retailcrm.ru>
|
|
|
|
* @license http://retailcrm.ru Proprietary
|
|
|
|
* @link http://retailcrm.ru
|
|
|
|
* @see http://help.retailcrm.ru
|
|
|
|
*/
|
2020-04-05 10:36:45 +03:00
|
|
|
class WC_Retailcrm_Icml_Test extends WC_Retailcrm_Test_Case_Helper
|
|
|
|
{
|
|
|
|
public function setUp()
|
|
|
|
{
|
2022-05-26 11:58:54 +03:00
|
|
|
WC_Helper_Product::create_simple_product();
|
|
|
|
WC_Helper_Product::create_variation_product();
|
2020-04-05 10:36:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testGenerate()
|
|
|
|
{
|
|
|
|
$icml = new WC_Retailcrm_Icml();
|
|
|
|
|
2022-05-26 11:58:54 +03:00
|
|
|
$icml->generate();
|
2021-06-30 13:06:18 +03:00
|
|
|
$this->assertFileExists(ABSPATH . 'simla.xml');
|
2022-05-26 11:58:54 +03:00
|
|
|
|
2021-06-30 13:06:18 +03:00
|
|
|
$xml = simplexml_load_file(ABSPATH . 'simla.xml');
|
2020-04-05 10:36:45 +03:00
|
|
|
|
2022-05-26 11:58:54 +03:00
|
|
|
$this->assertNotEmpty($xml);
|
|
|
|
|
|
|
|
$xmlArray = json_decode(json_encode($xml), true);
|
|
|
|
|
|
|
|
$this->assertNotEmpty($xmlArray['shop']['categories']['category']);
|
|
|
|
$this->assertCount(2, $xmlArray['shop']['categories']['category']);
|
|
|
|
$this->assertNotEmpty($xmlArray['shop']['offers']['offer']);
|
|
|
|
$this->assertCount(7, $xmlArray['shop']['offers']['offer']);
|
|
|
|
$this->assertNotEmpty($xmlArray['shop']['offers']['offer'][0]);
|
|
|
|
$this->assertNotEmpty($xmlArray['shop']['offers']['offer'][1]);
|
2020-04-05 10:36:45 +03:00
|
|
|
|
2022-05-26 11:58:54 +03:00
|
|
|
foreach ($xmlArray['shop']['offers']['offer'] as $product) {
|
|
|
|
$this->assertNotEmpty($product['name']);
|
|
|
|
$this->assertNotEmpty($product['productName']);
|
|
|
|
$this->assertNotEmpty($product['price']);
|
|
|
|
$this->assertNotEmpty($product['url']);
|
|
|
|
$this->assertNotEmpty($product['param']);
|
|
|
|
$this->assertNotEmpty($product['vatRate']);
|
|
|
|
$this->assertEquals('none', $product['vatRate']);
|
|
|
|
$this->assertContains('Dummy', $product['productName']);
|
2020-04-05 10:36:45 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|