make([]); $this->assertSame(ApplyStatus::COMPLETED, $result->applyStatus()); $this->assertSame(0, $result->successCount()); $this->assertSame(0, $result->failureCount()); } public function test_all_succeeded_yields_completed(): void { $result = $this->make([$this->success('a'), $this->success('b')]); $this->assertSame(ApplyStatus::COMPLETED, $result->applyStatus()); $this->assertSame(2, $result->successCount()); $this->assertSame(0, $result->failureCount()); $this->assertSame([], $result->failures()); } public function test_all_failed_yields_failed(): void { $result = $this->make([$this->failure('a'), $this->failure('b')]); $this->assertSame(ApplyStatus::FAILED, $result->applyStatus()); $this->assertSame(0, $result->successCount()); $this->assertSame(2, $result->failureCount()); $this->assertCount(2, $result->failures()); } public function test_mixed_yields_partial(): void { $result = $this->make([ $this->success('a'), $this->failure('b'), $this->success('c'), ]); $this->assertSame(ApplyStatus::PARTIAL, $result->applyStatus()); $this->assertSame(2, $result->successCount()); $this->assertSame(1, $result->failureCount()); $this->assertCount(1, $result->failures()); $this->assertSame('b', $result->failures()[0]->bindingId); } /** * @param list $applications */ private function make(array $applications): BindingPassResult { return new BindingPassResult( formSubmissionId: 'fs-1', provisionedSubjectType: 'person', provisionedSubjectId: 'p-1', applications: $applications, ); } private function success(string $bindingId): BindingApplicationResult { return BindingApplicationResult::succeeded( bindingId: $bindingId, targetEntity: 'person', targetAttribute: 'email', oldValue: null, newValue: 'x@y.z', ); } private function failure(string $bindingId): BindingApplicationResult { return BindingApplicationResult::failed( bindingId: $bindingId, targetEntity: 'person', targetAttribute: 'email', e: new RuntimeException('boom'), ); } }