-
Notifications
You must be signed in to change notification settings - Fork 1
Settings UI for the long-form composition strategy #42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
pfefferle
merged 2 commits into
add/long-form-teaser-thread
from
add/long-form-composition-setting
Apr 29, 2026
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,4 @@ | ||
| Significance: minor | ||
| Type: added | ||
|
|
||
| Choose how long-form posts publish to Bluesky from the ATmosphere settings page — link card (default), a single post combining body text with the permalink, or a two-post teaser thread. |
This file contains hidden or 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 hidden or 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
108 changes: 108 additions & 0 deletions
108
tests/phpunit/tests/class-test-long-form-composition-setting.php
This file contains hidden or 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,108 @@ | ||
| <?php | ||
| /** | ||
| * Tests for the long-form composition setting. | ||
| * | ||
| * Covers the sanitize callback and the option-driven seed filter. | ||
| * | ||
| * @package Atmosphere | ||
| * @group atmosphere | ||
| * @group settings | ||
| */ | ||
|
|
||
| namespace Atmosphere\Tests; | ||
|
|
||
| use WP_UnitTestCase; | ||
| use Atmosphere\Atmosphere; | ||
| use Atmosphere\WP_Admin\Admin; | ||
|
|
||
| /** | ||
| * Long-form composition setting tests. | ||
| */ | ||
| class Test_Long_Form_Composition_Setting extends WP_UnitTestCase { | ||
|
|
||
| /** | ||
| * Re-register the seed filter and clear option/transient state. | ||
| * | ||
| * Other test classes call `remove_all_filters( 'atmosphere_long_form_composition' )` | ||
| * in their `tear_down`, which would strip the production seed registered once on | ||
| * `plugins_loaded`. Re-add it here so each test in this class starts with the | ||
| * expected filter wiring regardless of execution order. | ||
| */ | ||
| public function set_up(): void { | ||
| parent::set_up(); | ||
|
|
||
| \remove_all_filters( 'atmosphere_long_form_composition' ); | ||
| \add_filter( 'atmosphere_long_form_composition', array( Atmosphere::class, 'seed_long_form_composition' ), 1 ); | ||
| \delete_transient( 'atmosphere_invalid_long_form_composition_logged' ); | ||
| } | ||
|
|
||
| /** | ||
| * Reset state between tests. | ||
| */ | ||
| public function tear_down(): void { | ||
| \delete_option( 'atmosphere_long_form_composition' ); | ||
| \delete_transient( 'atmosphere_invalid_long_form_composition_logged' ); | ||
| \remove_all_filters( 'atmosphere_long_form_composition' ); | ||
|
|
||
| parent::tear_down(); | ||
| } | ||
|
|
||
| /** | ||
| * Sanitize callback accepts each known strategy. | ||
| */ | ||
| public function test_sanitize_accepts_known_values() { | ||
| $this->assertSame( 'link-card', Admin::sanitize_long_form_composition( 'link-card' ) ); | ||
| $this->assertSame( 'truncate-link', Admin::sanitize_long_form_composition( 'truncate-link' ) ); | ||
| $this->assertSame( 'teaser-thread', Admin::sanitize_long_form_composition( 'teaser-thread' ) ); | ||
| } | ||
|
|
||
| /** | ||
| * Sanitize callback falls back to the default for unknown / non-string input. | ||
| */ | ||
| public function test_sanitize_rejects_unknown_values() { | ||
| $this->assertSame( 'link-card', Admin::sanitize_long_form_composition( 'something-else' ) ); | ||
| $this->assertSame( 'link-card', Admin::sanitize_long_form_composition( '' ) ); | ||
| $this->assertSame( 'link-card', Admin::sanitize_long_form_composition( null ) ); | ||
| $this->assertSame( 'link-card', Admin::sanitize_long_form_composition( array( 'teaser-thread' ) ) ); | ||
| } | ||
|
|
||
| /** | ||
| * The option seeds the `atmosphere_long_form_composition` filter. | ||
| */ | ||
| public function test_option_seeds_filter() { | ||
| \update_option( 'atmosphere_long_form_composition', 'teaser-thread' ); | ||
|
|
||
| $result = \apply_filters( 'atmosphere_long_form_composition', 'link-card', null ); | ||
|
|
||
| $this->assertSame( 'teaser-thread', $result ); | ||
| } | ||
|
|
||
| /** | ||
| * Downstream filters at the default priority override the option. | ||
| */ | ||
| public function test_downstream_filter_overrides_option() { | ||
| \update_option( 'atmosphere_long_form_composition', 'teaser-thread' ); | ||
|
|
||
| \add_filter( | ||
| 'atmosphere_long_form_composition', | ||
| static function (): string { | ||
| return 'truncate-link'; | ||
| } | ||
| ); | ||
|
|
||
| $result = \apply_filters( 'atmosphere_long_form_composition', 'link-card', null ); | ||
|
|
||
| $this->assertSame( 'truncate-link', $result ); | ||
| } | ||
|
|
||
| /** | ||
| * Unknown stored values are ignored; the default flows through. | ||
| */ | ||
| public function test_corrupt_option_falls_through_to_default() { | ||
| \update_option( 'atmosphere_long_form_composition', 'bogus-strategy' ); | ||
|
|
||
| $result = \apply_filters( 'atmosphere_long_form_composition', 'link-card', null ); | ||
|
|
||
| $this->assertSame( 'link-card', $result ); | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.