Skip to content

Commit

Permalink
Add tests for Elementor + WPML issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
kagg-design committed Sep 7, 2021
1 parent 4ffafe6 commit 5291197
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions tests/phpunit/tests/class-test-main.php
Expand Up @@ -1183,6 +1183,7 @@ public function test_wpml_locale_filter() {
* @param string $expected Expected.
*
* @dataProvider dp_test_wpml_locale_filter
* @throws ReflectionException ReflectionException.
*/
public function test_get_wpml_locale( $locale, $language_code, $expected ) {
$languages = [
Expand Down Expand Up @@ -1241,11 +1242,15 @@ public function test_get_wpml_locale( $locale, $language_code, $expected ) {
];

WP_Mock::userFunction( 'wpml_get_current_language' )->times( 1 )->with()->andReturn( $language_code );
WP_Mock::onFilter( 'wpml_active_languages' )->with( null )->reply( $languages );
WP_Mock::onFilter( 'wpml_active_languages' )->with( [] )->reply( $languages );

$subject = Mockery::mock( Main::class )->makePartial();

self::assertNull( $this->get_protected_property( $subject, 'wpml_languages' ) );

self::assertSame( $expected, $subject->get_wpml_locale( $locale ) );

self::assertSame( $languages, $this->get_protected_property( $subject, 'wpml_languages' ) );
}

/**
Expand Down Expand Up @@ -1325,9 +1330,8 @@ public function test_wpml_language_has_switched( $language_code, $expected ) {
],
];

WP_Mock::onFilter( 'wpml_active_languages' )->with( null )->reply( $languages );

$subject = Mockery::mock( Main::class )->makePartial();
$this->set_protected_property( $subject, 'wpml_languages', $languages );

$subject->wpml_language_has_switched( $language_code, 'some cookie', 'en_US' );
self::assertSame( $expected, $this->get_protected_property( $subject, 'wpml_locale' ) );
Expand Down

0 comments on commit 5291197

Please sign in to comment.