|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace SilverShop\Tests\Model\Variation; |
|
4
|
|
|
|
|
5
|
|
|
use SilverShop\Model\Variation\AttributeType; |
|
6
|
|
|
use SilverShop\Model\Variation\Variation; |
|
7
|
|
|
use SilverShop\Page\Product; |
|
8
|
|
|
use SilverStripe\Dev\SapphireTest; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* Test product variation capabilities. |
|
12
|
|
|
* |
|
13
|
|
|
* @link ProductVariation |
|
14
|
|
|
* @link ProductVariationDecorator |
|
15
|
|
|
* @package shop |
|
16
|
|
|
* @subpackage tests |
|
17
|
|
|
*/ |
|
18
|
|
|
class VariationVersionTest extends SapphireTest |
|
19
|
|
|
{ |
|
20
|
|
|
public static $fixture_file = '../../Fixtures/variations.yml'; |
|
21
|
|
|
public static $disable_theme = true; |
|
22
|
|
|
protected static $use_draft_site = true; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @var Product |
|
26
|
|
|
*/ |
|
27
|
|
|
protected $mp3player; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @var Product |
|
31
|
|
|
*/ |
|
32
|
|
|
protected $ball; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @var Variation |
|
36
|
|
|
*/ |
|
37
|
|
|
protected $redlarge; |
|
38
|
|
|
|
|
39
|
|
|
public function setUp(): void |
|
40
|
|
|
{ |
|
41
|
|
|
parent::setUp(); |
|
42
|
|
|
$this->ball = $this->objFromFixture(Product::class, "ball"); |
|
|
|
|
|
|
43
|
|
|
$this->mp3player = $this->objFromFixture(Product::class, "mp3player"); |
|
|
|
|
|
|
44
|
|
|
$this->redlarge = $this->objFromFixture(Variation::class, "redlarge"); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
public function testVariationsPersistOnUnpublish() |
|
48
|
|
|
{ |
|
49
|
|
|
$color = $this->objFromFixture(AttributeType::class, "color"); |
|
50
|
|
|
$values = ['Black', 'Blue']; |
|
51
|
|
|
$this->mp3player->generateVariationsFromAttributes($color, $values); |
|
52
|
|
|
$this->mp3player->publishSingle(); |
|
53
|
|
|
|
|
54
|
|
|
$this->mp3player->publish('Stage', 'Stage'); |
|
55
|
|
|
|
|
56
|
|
|
$variations = $this->mp3player->Variations(); |
|
57
|
|
|
$this->assertEquals($variations->Count(), 2, "two variations created and persist after product unpublished"); |
|
58
|
|
|
} |
|
59
|
|
|
} |
|
60
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..