|
5 | 5 | use PHPUnit\Framework\TestCase; |
6 | 6 | use Smartling\Extensions\Acf\AcfDynamicSupport; |
7 | 7 | use Smartling\Extensions\Acf\AcfTypeDetector; |
8 | | -use Smartling\Helpers\ArrayHelper; |
9 | 8 | use Smartling\Helpers\Cache; |
10 | 9 | use Smartling\Helpers\ContentHelper; |
11 | | -use Smartling\Helpers\MetaFieldProcessor\BulkProcessors\MediaBasedProcessor; |
12 | 10 | use Smartling\Helpers\SiteHelper; |
13 | 11 | use Smartling\Helpers\WordpressFunctionProxyHelper; |
14 | | -use Smartling\Helpers\WpObjectCache; |
15 | 12 | use Smartling\Processors\ContentEntitiesIOFactory; |
16 | | -use Smartling\Settings\SettingsManager; |
17 | | -use Smartling\Submissions\SubmissionManager; |
18 | 13 | use Smartling\Tests\Mocks\WordpressFunctionsMockHelper; |
19 | 14 |
|
20 | 15 | class AcfTypeDetectorTest extends TestCase |
21 | 16 | { |
22 | | - private $acfStores; |
23 | 17 | protected function setUp(): void |
24 | 18 | { |
25 | | - global $acf_stores; |
26 | | - $this->acfStores = $acf_stores; |
27 | 19 | WordpressFunctionsMockHelper::injectFunctionsMocks(); |
28 | 20 | } |
29 | 21 |
|
30 | | - protected function tearDown(): void |
31 | | - { |
32 | | - global $acf_stores; |
33 | | - $acf_stores = $this->acfStores; |
34 | | - } |
35 | | - |
36 | 22 | /** |
37 | 23 | * @dataProvider providerGetProcessorByMetaFields |
38 | 24 | */ |
@@ -74,56 +60,4 @@ private function providerGetProcessorByMetaFields() |
74 | 60 | ]; |
75 | 61 | } |
76 | 62 |
|
77 | | - public function testGetProcessorForGutenberg() |
78 | | - { |
79 | | - global $acf_stores; |
80 | | - if (!class_exists('ACF_Data')) { |
81 | | - $this->markTestSkipped('No ACF data found. This is ok when running tests with no ACF plugin or no wordpress loaded. The test will work when running as part of integration suite.'); |
82 | | - } |
83 | | - $groups = $this->createPartialMock('ACF_Data', ['get_data']); |
84 | | - $groups->method('get_data')->willReturn([]); |
85 | | - $fields = $this->createPartialMock('ACF_Data', ['get_data']); |
86 | | - $fields->method('get_data')->willReturn([ |
87 | | - 'field_5eb1344b55a84' => [ |
88 | | - 'global_type' => 'field', |
89 | | - 'type' => 'image', |
90 | | - 'name' => 'media', |
91 | | - 'key' => 'field_5eb1344b55a84', |
92 | | - 'parent' => '', |
93 | | - ] |
94 | | - ]); |
95 | | - $acf_stores = [ |
96 | | - 'local-groups' => $groups, |
97 | | - 'local-fields' => $fields, |
98 | | - ]; |
99 | | - |
100 | | - $settingsManager = $this->getMockBuilder(SettingsManager::class)->disableOriginalConstructor()->getMock(); |
101 | | - $settingsManager->method('getActiveProfiles')->willReturn([]); |
102 | | - $siteHelper = $this->createMock(SiteHelper::class); |
103 | | - $siteHelper->method('listBlogs')->willReturn([]); |
104 | | - |
105 | | - $ads = new AcfDynamicSupport( |
106 | | - new ArrayHelper(), |
107 | | - $settingsManager, |
108 | | - $siteHelper, |
109 | | - $this->createMock(SubmissionManager::class), |
110 | | - new WordpressFunctionProxyHelper(), |
111 | | - ); |
112 | | - $ads->run(); |
113 | | - |
114 | | - $fields = json_decode('{"entity\/post_content\/acf\/testimonial\/data\/media":"297",' . |
115 | | - '"entity\/post_content\/acf\/testimonial\/data\/_media":"field_5eb1344b55a84"}', true); |
116 | | - self::assertInstanceOf( |
117 | | - MediaBasedProcessor::class, |
118 | | - (new AcfTypeDetector( |
119 | | - $ads, |
120 | | - new WpObjectCache(), |
121 | | - new ContentHelper( |
122 | | - $this->createMock(ContentEntitiesIOFactory::class), |
123 | | - $siteHelper, |
124 | | - new WordpressFunctionProxyHelper(), |
125 | | - ) |
126 | | - ))->getProcessorForGutenberg(array_keys($fields)[0], $fields) |
127 | | - ); |
128 | | - } |
129 | 63 | } |
0 commit comments