feat: give projects a repository, package and status
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2 files changed
+188
-21
No files matched your search
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
/**
|
||||
* Tests for project term metadata.
|
||||
*
|
||||
* @package CHRNX
|
||||
*/
|
||||
|
||||
/**
|
||||
* Verify the project term meta contract.
|
||||
*/
|
||||
class ProjectMetaTest extends WP_UnitTestCase {
|
||||
/**
|
||||
* Register taxonomies and meta before each test.
|
||||
*/
|
||||
public function set_up() {
|
||||
parent::set_up();
|
||||
do_action( 'init' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure every project meta key is registered for the taxonomy.
|
||||
*/
|
||||
public function test_project_meta_keys_are_registered() {
|
||||
$registered = get_registered_meta_keys( 'term', 'chrnx_project' );
|
||||
|
||||
foreach ( array_keys( chrnx_get_project_meta_definitions() ) as $meta_key ) {
|
||||
$this->assertArrayHasKey( $meta_key, $registered );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure a plain http repository URL is rejected.
|
||||
*/
|
||||
public function test_project_links_reject_insecure_urls() {
|
||||
$term_id = self::factory()->term->create( array( 'taxonomy' => 'chrnx_project' ) );
|
||||
update_term_meta( $term_id, 'chrnx_project_repo', 'http://example.com/repo' );
|
||||
|
||||
$this->assertArrayNotHasKey( 'repo', chrnx_get_project_links( $term_id ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure stored https links come back keyed by their slot.
|
||||
*/
|
||||
public function test_project_links_return_stored_https_urls() {
|
||||
$term_id = self::factory()->term->create( array( 'taxonomy' => 'chrnx_project' ) );
|
||||
update_term_meta( $term_id, 'chrnx_project_repo', 'https://github.com/Expressive-Tea/green-tea' );
|
||||
update_term_meta( $term_id, 'chrnx_project_package', 'https://www.npmjs.com/package/@green-tea/core' );
|
||||
|
||||
$links = chrnx_get_project_links( $term_id );
|
||||
|
||||
$this->assertSame( 'https://github.com/Expressive-Tea/green-tea', $links['repo'] );
|
||||
$this->assertSame( 'https://www.npmjs.com/package/@green-tea/core', $links['package'] );
|
||||
$this->assertArrayNotHasKey( 'site', $links );
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user