@@ -21,7 +21,7 @@ class ContentTypeUsageReportProviderTest extends \PHPUnit\Framework\TestCase
21
21
* @magentoDataFixture Magento/CmsPageBuilderAnalytics/_files/pages.php
22
22
* @dataProvider reportDataProvider
23
23
*/
24
- public function testGetReport ($ expectedReportData )
24
+ public function testGetReport ($ expectedReportData, $ ignoredContentTypes )
25
25
{
26
26
/* @var $resourceConnection ResourceConnection */
27
27
$ resourceConnection = Bootstrap::getObjectManager ()->get (ResourceConnection::class)
@@ -39,7 +39,25 @@ public function testGetReport($expectedReportData)
39
39
);
40
40
$ reportData = $ contentTypeUsageReportProvider ->getReport ('pagebuilder_page_test ' );
41
41
42
- $ this ->assertEquals (sort ($ expectedReportData [0 ][0 ]), sort (iterator_to_array ($ reportData ->getInnerIterator ()[0 ][0 ])));
42
+ foreach ($ reportData ->getInnerIterator () as $ reportItem ) {
43
+ // Ignore the header within the report
44
+ if ($ reportItem [0 ] === 'Content Type ' ) {
45
+ continue ;
46
+ }
47
+
48
+ // Skip over any ignored content types
49
+ if (in_array ($ reportItem [0 ], $ ignoredContentTypes )) {
50
+ continue ;
51
+ }
52
+
53
+ // Verify we have expected report data for the content type
54
+ if (!isset ($ expectedReportData [$ reportItem [0 ]])) {
55
+ $ this ->fail ('There is no report data for ' . $ reportItem [0 ] . '. ' );
56
+ }
57
+
58
+ // Verify the count values match the expected report data
59
+ $ this ->assertEquals ($ expectedReportData [$ reportItem [0 ]], $ reportItem [1 ]);
60
+ }
43
61
}
44
62
45
63
/**
@@ -50,86 +68,29 @@ public function reportDataProvider(): array
50
68
return [
51
69
[
52
70
[
53
- [
54
- 'Content Type ' ,
55
- 'Count '
56
- ],
57
- [
58
- 'button-item ' ,
59
- 6
60
- ],
61
- [
62
- 'slide ' ,
63
- 12
64
- ],
65
- [
66
- 'text ' ,
67
- 1
68
- ],
69
- [
70
- 'image ' ,
71
- 2
72
- ],
73
- [
74
- 'block ' ,
75
- 1
76
- ],
77
- [
78
- 'row ' ,
79
- 7
80
- ],
81
- [
82
- 'column-group ' ,
83
- 5
84
- ],
85
- [
86
- 'column ' ,
87
- 12
88
- ],
89
- [
90
- 'video ' ,
91
- 2
92
- ],
93
- [
94
- 'heading ' ,
95
- 3
96
- ],
97
- [
98
- 'tabs ' ,
99
- 1
100
- ],
101
- [
102
- 'products ' ,
103
- 0
104
- ],
105
- [
106
- 'tab-item ' ,
107
- 2
108
- ],
109
- [
110
- 'banner ' ,
111
- 4
112
- ],
113
- [
114
- 'buttons ' ,
115
- 2
116
- ],
117
- [
118
- 'slider ' ,
119
- 3
120
- ],
121
- [
122
- 'divider ' ,
123
- 5
124
- ],
125
- [
126
- 'map ' ,
127
- 2
128
- ],
129
- [
130
- 'html ' ,
131
- 2
132
- ]
71
+ 'button-item ' => 6 ,
72
+ 'slide ' => 12 ,
73
+ 'text ' => 1 ,
74
+ 'image ' => 2 ,
75
+ 'block ' => 1 ,
76
+ 'row ' => 7 ,
77
+ 'column-group ' => 5 ,
78
+ 'column ' => 12 ,
79
+ 'video ' => 2 ,
80
+ 'heading ' => 3 ,
81
+ 'tabs ' => 1 ,
82
+ 'products ' => 0 ,
83
+ 'tab-item ' => 2 ,
84
+ 'banner ' => 4 ,
85
+ 'buttons ' => 2 ,
86
+ 'slider ' => 3 ,
87
+ 'divider ' => 5 ,
88
+ 'map ' => 2 ,
89
+ 'html ' => 2
90
+ ],
91
+ // Ignored content types
92
+ [
93
+ 'dynamic_block '
133
94
]
134
95
]
135
96
];
0 commit comments