diff --git a/composer.lock b/composer.lock index 5e2c65b45..03b357a70 100644 --- a/composer.lock +++ b/composer.lock @@ -203,16 +203,16 @@ }, { "name": "composer/ca-bundle", - "version": "1.2.8", + "version": "1.2.9", "source": { "type": "git", "url": "https://github.com/composer/ca-bundle.git", - "reference": "8a7ecad675253e4654ea05505233285377405215" + "reference": "78a0e288fdcebf92aa2318a8d3656168da6ac1a5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/ca-bundle/zipball/8a7ecad675253e4654ea05505233285377405215", - "reference": "8a7ecad675253e4654ea05505233285377405215", + "url": "https://api.github.com/repos/composer/ca-bundle/zipball/78a0e288fdcebf92aa2318a8d3656168da6ac1a5", + "reference": "78a0e288fdcebf92aa2318a8d3656168da6ac1a5", "shasum": "" }, "require": { @@ -221,14 +221,15 @@ "php": "^5.3.2 || ^7.0 || ^8.0" }, "require-dev": { - "phpunit/phpunit": "^4.8.35 || ^5.7 || 6.5 - 8", + "phpstan/phpstan": "^0.12.55", "psr/log": "^1.0", + "symfony/phpunit-bridge": "^4.2 || ^5", "symfony/process": "^2.5 || ^3.0 || ^4.0 || ^5.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.x-dev" + "dev-main": "1.x-dev" } }, "autoload": { @@ -258,7 +259,7 @@ "support": { "irc": "irc://irc.freenode.org/composer", "issues": "https://github.com/composer/ca-bundle/issues", - "source": "https://github.com/composer/ca-bundle/tree/1.2.8" + "source": "https://github.com/composer/ca-bundle/tree/1.2.9" }, "funding": [ { @@ -274,7 +275,7 @@ "type": "tidelift" } ], - "time": "2020-08-23T12:54:47+00:00" + "time": "2021-01-12T12:10:35+00:00" }, { "name": "composer/composer", @@ -1296,16 +1297,16 @@ }, { "name": "mck89/peast", - "version": "v1.11.0", + "version": "v1.12.0", "source": { "type": "git", "url": "https://github.com/mck89/peast.git", - "reference": "2a2bc6826114c46ff0bc1359208b7083a17f7a99" + "reference": "833be7a294627a8c5b1c482cbf489f73bf9b8086" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/mck89/peast/zipball/2a2bc6826114c46ff0bc1359208b7083a17f7a99", - "reference": "2a2bc6826114c46ff0bc1359208b7083a17f7a99", + "url": "https://api.github.com/repos/mck89/peast/zipball/833be7a294627a8c5b1c482cbf489f73bf9b8086", + "reference": "833be7a294627a8c5b1c482cbf489f73bf9b8086", "shasum": "" }, "require": { @@ -1317,7 +1318,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.11.0-dev" + "dev-master": "1.12.0-dev" } }, "autoload": { @@ -1339,9 +1340,9 @@ "description": "Peast is PHP library that generates AST for JavaScript code", "support": { "issues": "https://github.com/mck89/peast/issues", - "source": "https://github.com/mck89/peast/tree/v1.11.0" + "source": "https://github.com/mck89/peast/tree/v1.12.0" }, - "time": "2020-10-09T15:12:13+00:00" + "time": "2021-01-08T15:16:19+00:00" }, { "name": "mustache/mustache", diff --git a/tests/tests/connectors/test-class-connector-editor.php b/tests/tests/connectors/test-class-connector-editor.php new file mode 100644 index 000000000..d2a7a18fb --- /dev/null +++ b/tests/tests/connectors/test-class-connector-editor.php @@ -0,0 +1,88 @@ +plugin->connectors->unload_connectors(); + + $this->mock = $this->getMockBuilder( Connector_Editor::class ) + ->setMethods( array( 'log' ) ) + ->getMock(); + + $this->mock->register(); + } + + public function tearDown() { + parent::tearDown(); + } + + public function test_log_changes() { + $theme = wp_get_theme( 'twentytwenty' ); + $plugin = get_plugins()['hello.php']; + + $this->mock->expects( $this->exactly( 2 ) ) + ->method( 'log' ) + ->withConsecutive( + array( + $this->equalTo( + _x( + '"%1$s" in "%2$s" updated', + '1: File name, 2: Theme/plugin name', + 'stream' + ) + ), + $this->equalTo( + array( + 'file' => 'style.css', + 'theme_name' => $theme->get( 'Name' ), + 'theme_slug' => 'twentytwenty', + 'file_path' => $theme->get_files( 'css' )['style.css'], + ) + ), + $this->equalTo( null ), + $this->equalTo( 'themes' ), + $this->equalTo( 'updated' ), + ), + array( + $this->equalTo( + _x( + '"%1$s" in "%2$s" updated', + '1: File name, 2: Theme/plugin name', + 'stream' + ) + ), + $this->equalTo( + array( + 'file' => 'hello.php', + 'plugin_name' => $plugin['Name'], + 'plugin_slug' => 'hello.php', + 'file_path' => WP_PLUGIN_DIR . '/hello.php', + ) + ), + $this->equalTo( null ), + $this->equalTo( 'plugins' ), + $this->equalTo( 'updated' ), + ) + ); + + // Update theme file. + $_SERVER['REQUEST_METHOD'] = 'POST'; + $_POST['action'] = 'update'; + $_POST['theme'] = 'twentytwenty'; + do_action( 'load-theme-editor.php' ); + + \file_put_contents( $theme->get_files( 'css' )['style.css'], "\r\n", FILE_APPEND ); + apply_filters( 'wp_redirect', 'theme-editor.php' ); + + // Update plugin file + $_POST['plugin'] = 'hello.php'; + $_POST['file'] = 'hello.php'; + unset( $_POST['theme'] ); + do_action( 'load-plugin-editor.php' ); + + \file_put_contents( WP_PLUGIN_DIR . '/hello.php', "\r\n", FILE_APPEND ); + apply_filters( 'wp_redirect', 'plugin-editor.php' ); + } +}