From 4c3a5d8c34f6fa04d82f83cd1ebc0a8cde401805 Mon Sep 17 00:00:00 2001 From: prolic Date: Mon, 26 Nov 2018 04:36:06 +0800 Subject: [PATCH] Rename Method StreamMetadata::build => StreamMetadata::create resolves https://github.com/prooph/event-store-client/issues/47 --- src/StreamMetadata.php | 2 +- ...orward_with_soft_deleted_stream_should.php | 4 +- ...d_stream_events_with_unresolved_linkto.php | 2 +- tests/soft_delete.php | 6 +-- tests/subscribe_to_all_catching_up_should.php | 4 +- tests/subscribe_to_all_should.php | 2 +- .../when_having_max_count_set_for_stream.php | 10 ++-- ...n_having_truncatebefore_set_for_stream.php | 54 +++++++++---------- ...ith_stream_metadata_as_structured_info.php | 4 +- 9 files changed, 44 insertions(+), 44 deletions(-) diff --git a/src/StreamMetadata.php b/src/StreamMetadata.php index c9639b78..dfe31484 100644 --- a/src/StreamMetadata.php +++ b/src/StreamMetadata.php @@ -96,7 +96,7 @@ public function __construct( $this->customMetadata = $customMetadata; } - public static function build(): StreamMetadataBuilder + public static function create(): StreamMetadataBuilder { return new StreamMetadataBuilder(); } diff --git a/tests/read_all_events_forward_with_soft_deleted_stream_should.php b/tests/read_all_events_forward_with_soft_deleted_stream_should.php index 42c88797..3149db5b 100644 --- a/tests/read_all_events_forward_with_soft_deleted_stream_should.php +++ b/tests/read_all_events_forward_with_soft_deleted_stream_should.php @@ -40,7 +40,7 @@ private function cleanUp(): Generator yield $this->conn->setStreamMetadataAsync( '$all', ExpectedVersion::ANY, - StreamMetadata::build()->build(), + StreamMetadata::create()->build(), DefaultData::adminCredentials() ); @@ -52,7 +52,7 @@ protected function when(): Generator yield $this->conn->setStreamMetadataAsync( '$all', ExpectedVersion::ANY, - StreamMetadata::build()->setReadRoles(SystemRoles::ALL)->build(), + StreamMetadata::create()->setReadRoles(SystemRoles::ALL)->build(), DefaultData::adminCredentials() ); diff --git a/tests/read_stream_events_with_unresolved_linkto.php b/tests/read_stream_events_with_unresolved_linkto.php index 9ae3ad9a..040ba634 100644 --- a/tests/read_stream_events_with_unresolved_linkto.php +++ b/tests/read_stream_events_with_unresolved_linkto.php @@ -41,7 +41,7 @@ protected function when(): Generator yield $this->conn->setStreamMetadataAsync( '$all', ExpectedVersion::ANY, - StreamMetadata::build()->setReadRoles(SystemRoles::ALL)->build(), + StreamMetadata::create()->setReadRoles(SystemRoles::ALL)->build(), DefaultData::adminCredentials() ); diff --git a/tests/soft_delete.php b/tests/soft_delete.php index c32d831d..a75644c6 100644 --- a/tests/soft_delete.php +++ b/tests/soft_delete.php @@ -342,7 +342,7 @@ public function soft_deleted_stream_when_recreated_preserves_metadata_except_tru $result = yield $this->conn->setStreamMetadataAsync( $stream, ExpectedVersion::NO_STREAM, - StreamMetadata::build() + StreamMetadata::create() ->setTruncateBefore(\PHP_INT_MAX) ->setMaxCount(100) ->setDeleteRoles('some-role') @@ -599,7 +599,7 @@ public function setting_json_metadata_on_empty_soft_deleted_stream_recreates_str $result = yield $this->conn->setStreamMetadataAsync( $stream, 0, - StreamMetadata::build() + StreamMetadata::create() ->setTruncateBefore(\PHP_INT_MAX) ->setMaxCount(100) ->setDeleteRoles('some-role') @@ -662,7 +662,7 @@ public function setting_json_metadata_on_nonempty_soft_deleted_stream_recreates_ $result = yield $this->conn->setStreamMetadataAsync( $stream, 0, - StreamMetadata::build() + StreamMetadata::create() ->setTruncateBefore(\PHP_INT_MAX) ->setMaxCount(100) ->setDeleteRoles('some-role') diff --git a/tests/subscribe_to_all_catching_up_should.php b/tests/subscribe_to_all_catching_up_should.php index f99d1892..5d451a0c 100644 --- a/tests/subscribe_to_all_catching_up_should.php +++ b/tests/subscribe_to_all_catching_up_should.php @@ -63,7 +63,7 @@ private function execute(callable $function): void yield $this->conn->setStreamMetadataAsync( '$all', ExpectedVersion::ANY, - StreamMetadata::build()->setReadRoles(SystemRoles::ALL)->build(), + StreamMetadata::create()->setReadRoles(SystemRoles::ALL)->build(), new UserCredentials(SystemUsers::ADMIN, SystemUsers::DEFAULT_ADMIN_PASSWORD) ); @@ -72,7 +72,7 @@ private function execute(callable $function): void yield $this->conn->setStreamMetadataAsync( '$all', ExpectedVersion::ANY, - StreamMetadata::build()->build(), + StreamMetadata::create()->build(), new UserCredentials(SystemUsers::ADMIN, SystemUsers::DEFAULT_ADMIN_PASSWORD) ); diff --git a/tests/subscribe_to_all_should.php b/tests/subscribe_to_all_should.php index 43d2ee51..b05b5dce 100644 --- a/tests/subscribe_to_all_should.php +++ b/tests/subscribe_to_all_should.php @@ -49,7 +49,7 @@ private function execute(callable $function): void yield $connection->setStreamMetadataAsync( '$all', ExpectedVersion::ANY, - StreamMetadata::build()->setReadRoles(SystemRoles::ALL)->build(), + StreamMetadata::create()->setReadRoles(SystemRoles::ALL)->build(), new UserCredentials(SystemUsers::ADMIN, SystemUsers::DEFAULT_ADMIN_PASSWORD) ); diff --git a/tests/when_having_max_count_set_for_stream.php b/tests/when_having_max_count_set_for_stream.php index ca11779b..e18a01b0 100644 --- a/tests/when_having_max_count_set_for_stream.php +++ b/tests/when_having_max_count_set_for_stream.php @@ -47,7 +47,7 @@ private function execute(callable $function): void yield $this->conn->setStreamMetadataAsync( $this->stream, ExpectedVersion::ANY, - StreamMetadata::build()->setMaxCount(3)->build(), + StreamMetadata::create()->setMaxCount(3)->build(), DefaultData::adminCredentials() ); @@ -153,7 +153,7 @@ public function after_setting_less_strict_max_count_read_stream_forward_reads_mo yield $this->conn->setStreamMetadataAsync( $this->stream, ExpectedVersion::ANY, - StreamMetadata::build()->setMaxCount(4)->build(), + StreamMetadata::create()->setMaxCount(4)->build(), DefaultData::adminCredentials() ); @@ -207,7 +207,7 @@ public function after_setting_more_strict_max_count_read_stream_forward_reads_le yield $this->conn->setStreamMetadataAsync( $this->stream, ExpectedVersion::ANY, - StreamMetadata::build()->setMaxCount(2)->build(), + StreamMetadata::create()->setMaxCount(2)->build(), DefaultData::adminCredentials() ); @@ -261,7 +261,7 @@ public function after_setting_less_strict_max_count_read_stream_backward_reads_m yield $this->conn->setStreamMetadataAsync( $this->stream, ExpectedVersion::ANY, - StreamMetadata::build()->setMaxCount(4)->build(), + StreamMetadata::create()->setMaxCount(4)->build(), DefaultData::adminCredentials() ); @@ -315,7 +315,7 @@ public function after_setting_more_strict_max_count_read_stream_backward_reads_l yield $this->conn->setStreamMetadataAsync( $this->stream, ExpectedVersion::ANY, - StreamMetadata::build()->setMaxCount(2)->build(), + StreamMetadata::create()->setMaxCount(2)->build(), DefaultData::adminCredentials() ); diff --git a/tests/when_having_truncatebefore_set_for_stream.php b/tests/when_having_truncatebefore_set_for_stream.php index 55c4efba..0bc2df52 100644 --- a/tests/when_having_truncatebefore_set_for_stream.php +++ b/tests/when_having_truncatebefore_set_for_stream.php @@ -89,7 +89,7 @@ public function read_event_respects_truncatebefore(): void yield $this->setStreamMetadata( $stream, ExpectedVersion::EMPTY_STREAM, - StreamMetadata::build()->setTruncateBefore(2) + StreamMetadata::create()->setTruncateBefore(2) ); $res = yield $this->readEvent($stream, 1); @@ -116,7 +116,7 @@ public function read_stream_forward_respects_truncatebefore(): void yield $this->setStreamMetadata( $stream, ExpectedVersion::EMPTY_STREAM, - StreamMetadata::build()->setTruncateBefore(2) + StreamMetadata::create()->setTruncateBefore(2) ); $res = yield $this->conn->readStreamEventsForwardAsync($stream, 0, 100, false, DefaultData::adminCredentials()); @@ -141,7 +141,7 @@ public function read_stream_backward_respects_truncatebefore(): void yield $this->setStreamMetadata( $stream, ExpectedVersion::EMPTY_STREAM, - StreamMetadata::build()->setTruncateBefore(2) + StreamMetadata::create()->setTruncateBefore(2) ); $res = yield $this->conn->readStreamEventsBackwardAsync($stream, -1, 100, false, DefaultData::adminCredentials()); @@ -166,7 +166,7 @@ public function after_setting_less_strict_truncatebefore_read_event_reads_more_e yield $this->setStreamMetadata( $stream, ExpectedVersion::EMPTY_STREAM, - StreamMetadata::build()->setTruncateBefore(2) + StreamMetadata::create()->setTruncateBefore(2) ); $res = yield $this->readEvent($stream, 1); @@ -181,7 +181,7 @@ public function after_setting_less_strict_truncatebefore_read_event_reads_more_e yield $this->setStreamMetadata( $stream, 0, - StreamMetadata::build()->setTruncateBefore(1) + StreamMetadata::create()->setTruncateBefore(1) ); $res = yield $this->readEvent($stream, 0); @@ -208,7 +208,7 @@ public function after_setting_more_strict_truncatebefore_read_event_reads_less_e yield $this->setStreamMetadata( $stream, ExpectedVersion::EMPTY_STREAM, - StreamMetadata::build()->setTruncateBefore(2) + StreamMetadata::create()->setTruncateBefore(2) ); $res = yield $this->readEvent($stream, 1); @@ -223,7 +223,7 @@ public function after_setting_more_strict_truncatebefore_read_event_reads_less_e yield $this->setStreamMetadata( $stream, 0, - StreamMetadata::build()->setTruncateBefore(3) + StreamMetadata::create()->setTruncateBefore(3) ); $res = yield $this->readEvent($stream, 2); @@ -250,7 +250,7 @@ public function less_strict_max_count_doesnt_change_anything_for_event_read(): v yield $this->setStreamMetadata( $stream, ExpectedVersion::EMPTY_STREAM, - StreamMetadata::build()->setTruncateBefore(2) + StreamMetadata::create()->setTruncateBefore(2) ); $res = yield $this->readEvent($stream, 1); @@ -265,7 +265,7 @@ public function less_strict_max_count_doesnt_change_anything_for_event_read(): v yield $this->setStreamMetadata( $stream, 0, - StreamMetadata::build()->setTruncateBefore(2)->setMaxCount(4) + StreamMetadata::create()->setTruncateBefore(2)->setMaxCount(4) ); $res = yield $this->readEvent($stream, 1); @@ -292,7 +292,7 @@ public function more_strict_max_count_gives_less_events_for_event_read(): void yield $this->setStreamMetadata( $stream, ExpectedVersion::EMPTY_STREAM, - StreamMetadata::build()->setTruncateBefore(2) + StreamMetadata::create()->setTruncateBefore(2) ); $res = yield $this->readEvent($stream, 1); @@ -307,7 +307,7 @@ public function more_strict_max_count_gives_less_events_for_event_read(): void yield $this->setStreamMetadata( $stream, 0, - StreamMetadata::build()->setTruncateBefore(2)->setMaxCount(2) + StreamMetadata::create()->setTruncateBefore(2)->setMaxCount(2) ); $res = yield $this->readEvent($stream, 2); @@ -334,7 +334,7 @@ public function after_setting_less_strict_truncatebefore_read_stream_forward_rea yield $this->setStreamMetadata( $stream, ExpectedVersion::EMPTY_STREAM, - StreamMetadata::build()->setTruncateBefore(2) + StreamMetadata::create()->setTruncateBefore(2) ); $res = yield $this->conn->readStreamEventsForwardAsync($stream, 0, 100, false, DefaultData::adminCredentials()); @@ -347,7 +347,7 @@ public function after_setting_less_strict_truncatebefore_read_stream_forward_rea yield $this->setStreamMetadata( $stream, 0, - StreamMetadata::build()->setTruncateBefore(1) + StreamMetadata::create()->setTruncateBefore(1) ); $res = yield $this->conn->readStreamEventsForwardAsync($stream, 0, 100, false, DefaultData::adminCredentials()); @@ -372,7 +372,7 @@ public function after_setting_more_strict_truncatebefore_read_stream_forward_rea yield $this->setStreamMetadata( $stream, ExpectedVersion::EMPTY_STREAM, - StreamMetadata::build()->setTruncateBefore(2) + StreamMetadata::create()->setTruncateBefore(2) ); $res = yield $this->conn->readStreamEventsForwardAsync($stream, 0, 100, false, DefaultData::adminCredentials()); @@ -385,7 +385,7 @@ public function after_setting_more_strict_truncatebefore_read_stream_forward_rea yield $this->setStreamMetadata( $stream, 0, - StreamMetadata::build()->setTruncateBefore(3) + StreamMetadata::create()->setTruncateBefore(3) ); $res = yield $this->conn->readStreamEventsForwardAsync($stream, 0, 100, false, DefaultData::adminCredentials()); @@ -410,7 +410,7 @@ public function less_strict_max_count_doesnt_change_anything_for_stream_forward_ yield $this->setStreamMetadata( $stream, ExpectedVersion::EMPTY_STREAM, - StreamMetadata::build()->setTruncateBefore(2) + StreamMetadata::create()->setTruncateBefore(2) ); $res = yield $this->conn->readStreamEventsForwardAsync($stream, 0, 100, false, DefaultData::adminCredentials()); @@ -423,7 +423,7 @@ public function less_strict_max_count_doesnt_change_anything_for_stream_forward_ yield $this->setStreamMetadata( $stream, 0, - StreamMetadata::build()->setTruncateBefore(2)->setMaxCount(4) + StreamMetadata::create()->setTruncateBefore(2)->setMaxCount(4) ); $res = yield $this->conn->readStreamEventsForwardAsync($stream, 0, 100, false, DefaultData::adminCredentials()); @@ -448,7 +448,7 @@ public function more_strict_max_count_gives_less_events_for_stream_forward_read( yield $this->setStreamMetadata( $stream, ExpectedVersion::EMPTY_STREAM, - StreamMetadata::build()->setTruncateBefore(2) + StreamMetadata::create()->setTruncateBefore(2) ); $res = yield $this->conn->readStreamEventsForwardAsync($stream, 0, 100, false, DefaultData::adminCredentials()); @@ -461,7 +461,7 @@ public function more_strict_max_count_gives_less_events_for_stream_forward_read( yield $this->setStreamMetadata( $stream, 0, - StreamMetadata::build()->setTruncateBefore(2)->setMaxCount(2) + StreamMetadata::create()->setTruncateBefore(2)->setMaxCount(2) ); $res = yield $this->conn->readStreamEventsForwardAsync($stream, 0, 100, false, DefaultData::adminCredentials()); @@ -486,7 +486,7 @@ public function after_setting_less_strict_truncatebefore_read_stream_backward_re yield $this->setStreamMetadata( $stream, ExpectedVersion::EMPTY_STREAM, - StreamMetadata::build()->setTruncateBefore(2) + StreamMetadata::create()->setTruncateBefore(2) ); $res = yield $this->conn->readStreamEventsBackwardAsync($stream, -1, 100, false, DefaultData::adminCredentials()); @@ -499,7 +499,7 @@ public function after_setting_less_strict_truncatebefore_read_stream_backward_re yield $this->setStreamMetadata( $stream, 0, - StreamMetadata::build()->setTruncateBefore(1) + StreamMetadata::create()->setTruncateBefore(1) ); $res = yield $this->conn->readStreamEventsBackwardAsync($stream, -1, 100, false, DefaultData::adminCredentials()); @@ -524,7 +524,7 @@ public function after_setting_more_strict_truncatebefore_read_stream_backward_re yield $this->setStreamMetadata( $stream, ExpectedVersion::EMPTY_STREAM, - StreamMetadata::build()->setTruncateBefore(2) + StreamMetadata::create()->setTruncateBefore(2) ); $res = yield $this->conn->readStreamEventsBackwardAsync($stream, -1, 100, false, DefaultData::adminCredentials()); @@ -537,7 +537,7 @@ public function after_setting_more_strict_truncatebefore_read_stream_backward_re yield $this->setStreamMetadata( $stream, 0, - StreamMetadata::build()->setTruncateBefore(3) + StreamMetadata::create()->setTruncateBefore(3) ); $res = yield $this->conn->readStreamEventsBackwardAsync($stream, -1, 100, false, DefaultData::adminCredentials()); @@ -562,7 +562,7 @@ public function less_strict_max_count_doesnt_change_anything_for_stream_backward yield $this->setStreamMetadata( $stream, ExpectedVersion::EMPTY_STREAM, - StreamMetadata::build()->setTruncateBefore(2) + StreamMetadata::create()->setTruncateBefore(2) ); $res = yield $this->conn->readStreamEventsBackwardAsync($stream, -1, 100, false, DefaultData::adminCredentials()); @@ -575,7 +575,7 @@ public function less_strict_max_count_doesnt_change_anything_for_stream_backward yield $this->setStreamMetadata( $stream, 0, - StreamMetadata::build()->setTruncateBefore(2)->setMaxCount(4) + StreamMetadata::create()->setTruncateBefore(2)->setMaxCount(4) ); $res = yield $this->conn->readStreamEventsBackwardAsync($stream, -1, 100, false, DefaultData::adminCredentials()); @@ -600,7 +600,7 @@ public function more_strict_max_count_gives_less_events_for_stream_backward_read yield $this->setStreamMetadata( $stream, ExpectedVersion::EMPTY_STREAM, - StreamMetadata::build()->setTruncateBefore(2) + StreamMetadata::create()->setTruncateBefore(2) ); $res = yield $this->conn->readStreamEventsBackwardAsync($stream, -1, 100, false, DefaultData::adminCredentials()); @@ -613,7 +613,7 @@ public function more_strict_max_count_gives_less_events_for_stream_backward_read yield $this->setStreamMetadata( $stream, 0, - StreamMetadata::build()->setTruncateBefore(2)->setMaxCount(2) + StreamMetadata::create()->setTruncateBefore(2)->setMaxCount(2) ); $res = yield $this->conn->readStreamEventsBackwardAsync($stream, -1, 100, false, DefaultData::adminCredentials()); diff --git a/tests/when_working_with_stream_metadata_as_structured_info.php b/tests/when_working_with_stream_metadata_as_structured_info.php index b3eef247..3f8d37fe 100644 --- a/tests/when_working_with_stream_metadata_as_structured_info.php +++ b/tests/when_working_with_stream_metadata_as_structured_info.php @@ -377,7 +377,7 @@ public function setting_correctly_formatted_metadata_as_raw_allows_to_read_it_as public function setting_structured_metadata_with_custom_properties_returns_them_untouched(): void { $this->execute(function () { - $metadata = StreamMetadata::build() + $metadata = StreamMetadata::create() ->setMaxCount(17) ->setMaxAge(123321) ->setTruncateBefore(23) @@ -439,7 +439,7 @@ public function setting_structured_metadata_with_custom_properties_returns_them_ public function setting_structured_metadata_with_multiple_roles_can_be_read_back(): void { $this->execute(function () { - $metadata = StreamMetadata::build() + $metadata = StreamMetadata::create() ->setReadRoles('r1', 'r2', 'r3') ->setWriteRoles('w1', 'w2') ->setDeleteRoles('d1', 'd2', 'd3', 'd4')