|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare( strict_types = 1 ); |
|
4
|
|
|
|
|
5
|
|
|
namespace WMDE\BannerServer\Tests\Fixtures; |
|
6
|
|
|
|
|
7
|
|
|
use WMDE\BannerServer\Entity\BannerSelection\Campaign; |
|
8
|
|
|
use WMDE\BannerServer\Entity\BannerSelection\CampaignCollection; |
|
9
|
|
|
use WMDE\BannerServer\Utils\SystemRandomIntegerGenerator; |
|
10
|
|
|
|
|
11
|
|
|
class CampaignFixture { |
|
12
|
|
|
|
|
13
|
|
|
public const TEST_CATEGORY = 'test_category'; |
|
14
|
|
|
|
|
15
|
|
|
public static function getTestCampaignStartDate(): \DateTime { |
|
16
|
|
|
return new \DateTime( '2000-01-01 00:00:00' ); |
|
17
|
|
|
} |
|
18
|
|
|
|
|
19
|
|
|
public static function getTestCampaignEndDate(): \DateTime { |
|
20
|
|
|
return new \DateTime( '2099-12-31 23:59:59' ); |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
public static function getTrueRandomTestCampaign( int $displayPercentage = 100 ): Campaign { |
|
24
|
|
|
return new Campaign( |
|
25
|
|
|
'C18_WMDE_Test', |
|
26
|
|
|
self::getTestCampaignStartDate(), |
|
27
|
|
|
self::getTestCampaignEndDate(), |
|
28
|
|
|
$displayPercentage, |
|
29
|
|
|
self::TEST_CATEGORY, |
|
30
|
|
|
new SystemRandomIntegerGenerator(), |
|
31
|
|
|
null, |
|
32
|
|
|
null, |
|
33
|
|
|
BucketFixture::getTestBucket() |
|
34
|
|
|
); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
public static function getTrueRandomTestCampaignCollection( int $displayPercentage = 100 ): CampaignCollection { |
|
38
|
|
|
return new CampaignCollection( |
|
39
|
|
|
self::getTrueRandomTestCampaign( $displayPercentage ) |
|
40
|
|
|
); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
public static function getMaxViewportWidthCampaign( int $maxWidthDesktop, ?string $bannerIdentifier = null ): Campaign { |
|
44
|
|
|
return new Campaign( |
|
45
|
|
|
'C18_WMDE_Test', |
|
46
|
|
|
self::getTestCampaignStartDate(), |
|
47
|
|
|
self::getTestCampaignEndDate(), |
|
48
|
|
|
100, |
|
49
|
|
|
self::TEST_CATEGORY, |
|
50
|
|
|
new SystemRandomIntegerGenerator(), |
|
51
|
|
|
null, |
|
52
|
|
|
$maxWidthDesktop, |
|
53
|
|
|
BucketFixture::getTestBucket( $bannerIdentifier ) |
|
54
|
|
|
); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
public static function getMinViewportWidthCampaign( int $minWidth, ?string $bannerIdentifier = null ): Campaign { |
|
58
|
|
|
return new Campaign( |
|
59
|
|
|
'C18_WMDE_Test', |
|
60
|
|
|
self::getTestCampaignStartDate(), |
|
61
|
|
|
self::getTestCampaignEndDate(), |
|
62
|
|
|
100, |
|
63
|
|
|
self::TEST_CATEGORY, |
|
64
|
|
|
new SystemRandomIntegerGenerator(), |
|
65
|
|
|
$minWidth, |
|
66
|
|
|
null, |
|
67
|
|
|
BucketFixture::getTestBucket( $bannerIdentifier ) |
|
68
|
|
|
); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
public static function getFixedViewportWidthCampaignCollection( int $maxViewportWidth ): CampaignCollection { |
|
72
|
|
|
return new CampaignCollection( |
|
73
|
|
|
self::getMaxViewportWidthCampaign( $maxViewportWidth ) |
|
74
|
|
|
); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
public static function getMixedFixedViewportWidthCampaignCollection( int $minViewportWidth, int $maxViewportWidth, string $minIdentifier, string $maxIdentifier ): CampaignCollection { |
|
78
|
|
|
return new CampaignCollection( |
|
79
|
|
|
self::getMinViewportWidthCampaign( $minViewportWidth, $minIdentifier ), |
|
80
|
|
|
self::getMaxViewportWidthCampaign( $maxViewportWidth, $maxIdentifier ) |
|
81
|
|
|
); |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
|