generated from alleyinteractive/create-wordpress-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from alleyinteractive/cursor
- Loading branch information
Showing
11 changed files
with
250 additions
and
19 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
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,35 @@ | ||
<?php | ||
/** | ||
* With_Cursor interface file. | ||
* | ||
* @package feed-consumer | ||
*/ | ||
|
||
namespace Feed_Consumer\Contracts; | ||
|
||
/** | ||
* With Cursor Interface | ||
*/ | ||
interface With_Cursor { | ||
/** | ||
* Cursor meta key. | ||
* | ||
* @var string | ||
*/ | ||
public const CURSOR_META_KEY = 'feed_consumer_cursor'; | ||
|
||
/** | ||
* Retrieve the cursor. | ||
* | ||
* @return string|null | ||
*/ | ||
public function get_cursor(): ?string; | ||
|
||
/** | ||
* Set the cursor. | ||
* | ||
* @param string $cursor Cursor to set. | ||
* @return static | ||
*/ | ||
public function set_cursor( string $cursor ): static; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
/** | ||
* Cursor class file | ||
* | ||
* @package feed-consumer | ||
*/ | ||
|
||
namespace Feed_Consumer\Processor; | ||
|
||
/** | ||
* Processor Cursor Storage | ||
*/ | ||
trait Cursor { | ||
/** | ||
* Cursor storage. | ||
* | ||
* @var string|null | ||
*/ | ||
protected ?string $cursor = null; | ||
|
||
/** | ||
* Retrieve the cursor. | ||
* | ||
* @return string|null | ||
*/ | ||
public function get_cursor(): ?string { | ||
return $this->cursor; | ||
} | ||
|
||
/** | ||
* Set the cursor. | ||
* | ||
* @param string $cursor Cursor to set. | ||
* @return static | ||
*/ | ||
public function set_cursor( string $cursor ): static { | ||
$this->cursor = $cursor; | ||
|
||
return $this; | ||
} | ||
} |
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
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,40 @@ | ||
<?php | ||
|
||
namespace Feed_Consumer\Tests\Processor; | ||
|
||
use Feed_Consumer\Loader\Post_Loader; | ||
use Feed_Consumer\Processor\RSS_Processor; | ||
use Feed_Consumer\Runner; | ||
use Feed_Consumer\Settings; | ||
use Feed_Consumer\Tests\Test_Case; | ||
use Mantle\Testing\Concerns\Refresh_Database; | ||
use Mantle\Testing\Mock_Http_Response; | ||
|
||
/** | ||
* @group processor | ||
*/ | ||
class Cursor_Test extends Test_Case { | ||
public function get_default_cursor() { | ||
$processor = $this->make_processor(); | ||
|
||
$this->assertNull( $processor->get_cursor() ); | ||
} | ||
|
||
public function test_get_cursor() { | ||
$processor = $this->make_processor(); | ||
|
||
$processor->set_cursor( '123' ); | ||
|
||
$this->assertEquals( '123', $processor->get_cursor() ); | ||
} | ||
|
||
public function test_set_cursor() { | ||
$processor = $this->make_processor(); | ||
|
||
$this->assertNull( $processor->get_cursor() ); | ||
|
||
$processor->set_cursor( '123' ); | ||
|
||
$this->assertEquals( '123', $processor->get_cursor() ); | ||
} | ||
} |
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