-
Notifications
You must be signed in to change notification settings - Fork 270
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for terms meta and new unit tests
- Loading branch information
Showing
18 changed files
with
1,762 additions
and
837 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,17 @@ | ||
<?xml version="1.0"?> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="bootstrap.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd" cacheDirectory=".phpunit.cache"> | ||
<testsuites> | ||
<testsuite name="Application Test Suite"> | ||
<file>tests/WPWXRReaderTests.php</file> | ||
<file>tests/WPRewriteUrlsTests.php</file> | ||
<file>tests/WPURLInTextProcessorTests.php</file> | ||
<file>tests/WPBlockMarkupProcessorTests.php</file> | ||
<file>tests/WPBlockMarkupUrlProcessorTests.php</file> | ||
<file>tests/URLParserWHATWGComplianceTests.php</file> | ||
<file>tests/WPXMLProcessorTests.php</file> | ||
<file>tests/UrldecodeNTests.php</file> | ||
<file>tests/WPStreamImporterTests.php</file> | ||
</testsuite> | ||
</testsuites> | ||
<testsuites> | ||
<testsuite name="Application Test Suite"> | ||
<file>tests/WPEntityImporterTests.php</file> | ||
<file>tests/URLParserWHATWGComplianceTests.php</file> | ||
<file>tests/UrldecodeNTests.php</file> | ||
<file>tests/WPBlockMarkupProcessorTests.php</file> | ||
<file>tests/WPBlockMarkupUrlProcessorTests.php</file> | ||
<file>tests/WPRewriteUrlsTests.php</file> | ||
<file>tests/WPStreamImporterTests.php</file> | ||
<file>tests/WPURLInTextProcessorTests.php</file> | ||
<file>tests/WPWXRReaderTests.php</file> | ||
<file>tests/WPXMLProcessorTests.php</file> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
packages/playground/data-liberation/tests/PlaygroundTestCase.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* Base class for Playground tests. | ||
*/ | ||
abstract class PlaygroundTestCase extends TestCase { | ||
|
||
protected function setUp(): void { | ||
parent::setUp(); | ||
|
||
if ( ! isset( $_SERVER['SERVER_SOFTWARE'] ) || $_SERVER['SERVER_SOFTWARE'] !== 'PHP.wasm' ) { | ||
$this->markTestSkipped( 'Test only runs in Playground' ); | ||
} | ||
} | ||
|
||
/** | ||
* Deletes all data from the database. Copy of _delete_all_data() from WordPress core. | ||
* | ||
* @see https://github.com/WordPress/wordpress-develop/blob/trunk/tests/phpunit/includes/functions.php | ||
*/ | ||
protected function delete_all_data() { | ||
global $wpdb; | ||
|
||
foreach ( array( | ||
$wpdb->posts, | ||
$wpdb->postmeta, | ||
$wpdb->comments, | ||
$wpdb->commentmeta, | ||
$wpdb->term_relationships, | ||
$wpdb->termmeta, | ||
) as $table ) { | ||
// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared | ||
$wpdb->query( "DELETE FROM {$table}" ); | ||
} | ||
|
||
foreach ( array( | ||
$wpdb->terms, | ||
$wpdb->term_taxonomy, | ||
) as $table ) { | ||
// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared | ||
$wpdb->query( "DELETE FROM {$table} WHERE term_id != 1" ); | ||
} | ||
|
||
$wpdb->query( "UPDATE {$wpdb->term_taxonomy} SET count = 0" ); | ||
|
||
$wpdb->query( "DELETE FROM {$wpdb->users} WHERE ID != 1" ); | ||
$wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE user_id != 1" ); | ||
} | ||
} |
Oops, something went wrong.