Skip to content

Commit 0000305

Browse files
pavelthqAlper Bulut
authored and
Alper Bulut
committed
VC-1853 fix yoast saving and fix phpunit tests
1 parent 395bc44 commit 0000305

17 files changed

+208
-288
lines changed

ci/phpunit-all-coverage.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
</php>
2121
<testsuites>
2222
<testsuite name="Whole project">
23-
<directory prefix="test-" suffix=".php">../tests/phpunit</directory>
23+
<directory suffix=".php">../tests/phpunit</directory>
2424
</testsuite>
2525
</testsuites>
2626
<logging/>

tests/phpunit/addons/DynamicFieldsAddonTest.php

+174
Large diffs are not rendered by default.

tests/phpunit/addons/test-dynamic-fields-addon.php

-88
This file was deleted.

tests/phpunit/helpers/HelperFrontendTest.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ public function testQueryResetInsideLoop()
264264
$originalId = $this->createPost($originalContent, 'post');
265265

266266
// override global query!
267-
global $wp_the_query, $wp_query;
267+
global $wp_the_query, $wp_query, $post;
268268
$generalQuery = new \WP_Query(
269269
[
270270
'post_type' => 'post',
@@ -273,6 +273,7 @@ public function testQueryResetInsideLoop()
273273
);
274274
$wp_the_query = $generalQuery;
275275
$wp_query = $generalQuery;
276+
$post = get_post($originalId);
276277

277278
add_shortcode(
278279
'test-query-reset',
@@ -300,7 +301,7 @@ function () {
300301
the_content();
301302
}
302303
$content = ob_get_clean();
303-
$this->assertEquals('<p>title:random title' . md5($originalContent) . ' first</p>', trim($content));
304+
$this->assertEquals('<p>title:random title' . rawurlencode($originalContent) . ' first</p>', trim($content));
304305

305306
wp_reset_query();
306307
}
@@ -314,7 +315,7 @@ protected function createPost($content, $postType = 'page')
314315
'post_type' => $postType,
315316
'post_content' => $content,
316317
'post_status' => 'publish',
317-
'post_title' => 'random title' . md5($content),
318+
'post_title' => 'random title' . rawurlencode($content),
318319
]
319320
);
320321
$this->assertTrue(is_numeric($postId));

tests/phpunit/helpers/HelpersLicenseTest.php

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ public function testIsActivated()
2626
$helper->setKey('foo-bar', $optionsHelper);
2727
$helper->setType('free', $optionsHelper);
2828

29-
$this->assertTrue($helper->isAnyActivated());
3029
$this->assertFalse($helper->isPremiumActivated());
3130

3231
//reset

tests/phpunit/modules/Account/TestAccountDeactivationController.php

-46
This file was deleted.

tests/phpunit/modules/Api/TestApiFactoryController.php tests/phpunit/modules/Api/ApiFactoryControllerTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
class TestApiFactoryController extends WP_UnitTestCase
3+
class ApiFactoryControllerTest extends WP_UnitTestCase
44
{
55
public function testRegister()
66
{

tests/phpunit/modules/Api/TestElementsApiController.php tests/phpunit/modules/Api/ElementsApiControllerTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
class TestElementsApiController extends WP_UnitTestCase
3+
class ElementsApiControllerTest extends WP_UnitTestCase
44
{
55
public function testElementsApi()
66
{

tests/phpunit/modules/Editors/TestPostUpdate.php tests/phpunit/modules/Editors/PostUpdateTest.php

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
class TestPostUpdate extends WP_UnitTestCase
3+
class PostUpdateTest extends WP_UnitTestCase
44
{
55
public function testGetUpdateablePost()
66
{
@@ -42,14 +42,13 @@ public function testRenderUpdateFe()
4242
// Previous test have Post Update action.
4343
$optionsHelper = vchelper('Options');
4444
$licenseHelper = vchelper('License');
45-
$licenseHelper->setType('free');
46-
$licenseHelper->setKey('test');
4745
$this->assertFalse($optionsHelper->get('bundleUpdateRequired'));
4846
$optionsHelper = vchelper('Options');
4947
$postId = $this->createPost('megaTest3');
5048
vchelper('PostType')->setupPost($postId);
5149
$optionsHelper->set('hubAction:updatePosts', [$postId]);
5250
$optionsHelper->set('bundleUpdateRequired', 1);
51+
$optionsHelper->set('agreeHubTerms', time());
5352
$actions = vcapp(\VisualComposer\Helpers\Hub\Update::class)->getRequiredActions();
5453
$this->assertNotEmpty($actions);
5554
$exceptionCalled = false;
@@ -71,7 +70,7 @@ public function testRenderUpdateFe()
7170
$this->assertEquals(1, count($matches[0]), 'Visual Composer Post Update');
7271
}
7372

74-
$this->assertTrue($exceptionCalled);
73+
$this->assertTrue($exceptionCalled, 'exception called successfully');
7574
$licenseHelper->setType('');
7675
$licenseHelper->setKey('');
7776
}
@@ -143,9 +142,6 @@ protected function checkFeEditorVariables($output)
143142
preg_match_all('/window\.vcvGettingStartedUrl/', $output, $matches);
144143
$this->assertEquals(1, count($matches[0]), 'vcvGettingStartedUrl');
145144

146-
preg_match_all('/window\.vcvIsAnyActivated/', $output, $matches);
147-
$this->assertEquals(1, count($matches[0]), 'vcvIsAnyActivated');
148-
149145
preg_match_all('/Object\.defineProperty\(window, \'VCV_LICENSE_KEY\', {/', $output, $matches);
150146
$this->assertEquals(1, count($matches[0]), 'VCV_LICENSE_KEY');
151147

tests/phpunit/modules/Editors/TestVariables.php tests/phpunit/modules/Editors/VariablesTest.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
class TestVariables extends WP_UnitTestCase
3+
class VariablesTest extends WP_UnitTestCase
44
{
55
public function testVariablesTypes()
66
{
@@ -38,7 +38,7 @@ public function testEnvVariables()
3838
$this->assertIsNumeric($keyEnv);
3939
$this->assertTrue(isset($variables[ $keyEnv ]));
4040
$this->assertTrue(isset($variables[ $keyEnv ]['value']));
41-
$this->assertContains('VCV_HUB_URL', $variables[ $keyEnv ]['value']);
41+
$this->arrayHasKey('VCV_HUB_URL', $variables[ $keyEnv ]['value']);
4242
$this->assertEquals(\VcvEnv::all(), $variables[ $keyEnv ]['value']);
4343
}
4444

@@ -159,7 +159,6 @@ public function testEditorVariables()
159159
$this->assertContains('vcvGoPremiumUrl', $variableKeys, 'vcvGoPremiumUrl');
160160
$this->assertContains('vcvGettingStartedUrl', $variableKeys, 'vcvGettingStartedUrl');
161161
$this->assertContains('vcvGutenbergEditorUrl', $variableKeys, 'vcvGutenbergEditorUrl');
162-
$this->assertContains('vcvIsAnyActivated', $variableKeys, 'vcvIsAnyActivated');
163162
}
164163

165164
public function testJsonVariables()

tests/phpunit/modules/Editors/_test-page-editable-controller.php

-92
This file was deleted.

tests/phpunit/modules/Elements/_test-ajax-shortcode.php

-16
This file was deleted.

tests/phpunit/modules/License/LicenseActivationTest.php

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ public function testLicenseActivation()
66
{
77
vchelper('Options')->setTransient('lastBundleUpdate', time());
88
$this->assertNotEmpty(vcvenv('VCV_ACTIVATE_LICENSE_URL'));
9-
$this->assertFalse(vchelper('License')->isAnyActivated());
109
$loggerHelper = vchelper('Logger');
1110
$loggerHelper->reset();
1211

0 commit comments

Comments
 (0)