stream(json_encode(['confirmed' => true, 'email' => 'synthetic@example.test', 'password' => $secret, 'confirmation' => $secret])); try { $values = ProtectedProvisioningInput::read($stream, 'synthetic@example.test'); } finally { fclose($stream); } $this->assertTrue($values[0] === $secret && $values[1] === $secret); } public function test_unconfirmed_or_wrong_recipient_is_refused_without_revealing_payload(): void { $secret = bin2hex(random_bytes(12)); foreach ([['confirmed' => false, 'email' => 'synthetic@example.test'], ['confirmed' => true, 'email' => 'another@example.test']] as $case) { $stream = $this->stream(json_encode($case + ['password' => $secret, 'confirmation' => $secret])); try { ProtectedProvisioningInput::read($stream, 'synthetic@example.test'); $this->fail('Unconfirmed input accepted.'); } catch (RuntimeException $exception) { $this->assertStringNotContainsString($secret, $exception->getMessage()); } finally { fclose($stream); } } } public function test_malformed_payload_is_refused_without_including_its_contents(): void { $stream = $this->stream('{private-invalid-payload'); try { $this->expectException(RuntimeException::class); $this->expectExceptionMessage('Entrada protegida inválida ou não confirmada. Nada alterado.'); ProtectedProvisioningInput::read($stream, 'synthetic@example.test'); } finally { fclose($stream); } } }