Fixed tests adding wp_normalize_path() mocks.

This commit is contained in:
Andrey Savchenko committed 2018-03-19 22:44:36 +02:00
1 parent 1f85d65b9b
commit 5ee99cddd4
3 files changed
+22 -1

No files matched your search

+7
View File
@@ -2,6 +2,7 @@
namespace Rarst\Laps\Tests;
use Brain\Monkey\Functions;
use Pimple\ServiceProviderInterface;
use Rarst\Laps\Provider\Bootable_Provider_Interface;
@@ -24,6 +25,12 @@ class PluginTest extends LapsTestCase {
->method( 'boot' )
->with( $container );
if ( ! defined( 'ABSPATH' ) ) {
define( 'ABSPATH', '/wp' );
define( 'WP_CONTENT_DIR', '/wp-content/' );
}
Functions\expect( 'wp_normalize_path' )->zeroOrMoreTimes()->andReturnFirstArg();
$container->run();
}
}
+7
View File
@@ -2,6 +2,7 @@
namespace Rarst\Laps\Tests\Provider;
use Brain\Monkey\Functions;
use Pimple\Exception\FrozenServiceException;
use Rarst\Laps\Plugin;
use Rarst\Laps\Provider\Record_Provider;
@@ -24,6 +25,12 @@ class RecordTest extends LapsTestCase {
$this->assertNotSame( $stopwatch_a, $stopwatch_b );
if ( ! defined( 'ABSPATH' ) ) {
define( 'ABSPATH', '/wp' );
define( 'WP_CONTENT_DIR', '/wp-content/' );
}
Functions\expect( 'wp_normalize_path' )->zeroOrMoreTimes()->andReturnFirstArg();
$this->assertArrayHasKey( 'records', $container );
$container->extend( 'collectors', function () {} );
+8 -1
View File
@@ -2,6 +2,7 @@
namespace Rarst\Laps\Tests\Record;
use Brain\Monkey\Functions;
use Rarst\Laps\Record\Record;
use Rarst\Laps\Record\Sql_Record_Collector;
use Rarst\Laps\Tests\LapsTestCase;
@@ -15,6 +16,12 @@ class SqlTest extends LapsTestCase {
define( 'SAVEQUERIES', true );
if ( ! defined( 'ABSPATH' ) ) {
define( 'ABSPATH', '/wp' );
define( 'WP_CONTENT_DIR', '/wp-content/' );
}
Functions\expect( 'wp_normalize_path' )->zeroOrMoreTimes()->andReturnFirstArg();
$collector = new Sql_Record_Collector();
$this->assertTrue( has_filter( 'query', [ $collector, 'query' ] ) );
@@ -27,7 +34,7 @@ class SqlTest extends LapsTestCase {
$wpdb = new \stdClass();
$duration = 100;
$wpdb->queries[] = [ $query, $duration ];
$wpdb->queries[] = [ $query, $duration, 'foo(), bar()' ];
$records = $collector->get_records();