-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathMultilineTest.php
More file actions
42 lines (33 loc) · 1.23 KB
/
MultilineTest.php
File metadata and controls
42 lines (33 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
use WP_CLI\Tests\TestCase;
class MultilineTest extends TestCase {
protected static $test_config_path;
protected static $config_transformer;
public static function set_up_before_class() {
self::$test_config_path = __DIR__ . '/wp-config-test-multiline.php';
/* The // at the end of the first line causes parse_wp_config to
* have a space prefixing the second line, which causes the preg_replace
* in update to fail.
* Fixed in ad435a7
*/
file_put_contents(
self::$test_config_path,
<<<'EOF'
<?php
define('FIRST_CONSTANT', true); //
define('SECOND_CONSTANT', 'oldvalue');
EOF
);
self::$config_transformer = new WPConfigTransformer( self::$test_config_path );
}
public static function tear_down_after_class() {
unlink( self::$test_config_path );
}
public function testConfigValues() {
self::$config_transformer->update( 'constant', 'SECOND_CONSTANT', 'newvalue' );
require_once self::$test_config_path;
$this->assertTrue( defined( 'SECOND_CONSTANT' ), 'SECOND_CONSTANT not defined' );
$this->assertNotSame( 'oldvalue', constant( 'SECOND_CONSTANT' ), 'SECOND_CONSTANT is still "oldvalue"' );
$this->assertEquals( 'newvalue', constant( 'SECOND_CONSTANT' ), 'SECOND_CONSTANT is not "newvalue"' );
}
}