newCorrection(); $this->assertIsAtolable($correction); } /** * Тестирует установку валидного кассира * * @return void * @covers \AtolOnline\Entities\Correction::setCashier * @covers \AtolOnline\Entities\Correction::getCashier * @covers \AtolOnline\Entities\Correction::jsonSerialize * @throws EmptyCorrectionNumberException * @throws InvalidCorrectionDateException * @throws InvalidEntityInCollectionException * @throws InvalidEnumValueException * @throws NegativePaymentSumException * @throws TooHighPaymentSumException * @throws TooLongCashierException */ public function testCashier(): void { $correction = $this->newCorrection()->setCashier(Helpers::randomStr()); $this->assertArrayHasKey('cashier', $correction->jsonSerialize()); $this->assertEquals($correction->getCashier(), $correction->jsonSerialize()['cashier']); } /** * Тестирует обнуление кассира * * @param mixed $param * @return void * @dataProvider providerNullableStrings * @covers \AtolOnline\Entities\Correction::setCashier * @covers \AtolOnline\Entities\Correction::getCashier * @throws EmptyCorrectionNumberException * @throws InvalidCorrectionDateException * @throws InvalidEntityInCollectionException * @throws InvalidEnumValueException * @throws NegativePaymentSumException * @throws TooHighPaymentSumException * @throws TooLongCashierException */ public function testNullableCashier(mixed $param): void { $this->assertNull($this->newCorrection()->setCashier($param)->getCashier()); } /** * Тестирует выброс исключения при установке слишком длинного кассира (лол) * * @return void * @covers \AtolOnline\Entities\Correction::setCashier * @covers \AtolOnline\Exceptions\TooLongCashierException * @throws EmptyCorrectionNumberException * @throws InvalidCorrectionDateException * @throws InvalidEntityInCollectionException * @throws InvalidEnumValueException * @throws NegativePaymentSumException * @throws TooHighPaymentSumException * @throws TooLongCashierException */ public function testTooLongCashierException(): void { $this->expectException(TooLongCashierException::class); $this->newCorrection()->setCashier(Helpers::randomStr(Constraints::MAX_LENGTH_CASHIER_NAME + 1)); } /** * Возвращает валидный тестовый объект чека * * @return Correction * @throws InvalidEntityInCollectionException * @throws InvalidEnumValueException * @throws NegativePaymentSumException * @throws TooHighPaymentSumException * @throws EmptyCorrectionNumberException * @throws InvalidCorrectionDateException */ protected function newCorrection(): Correction { return new Correction( new Company('company@example.com', SnoTypes::OSN, '1234567890', 'https://example.com'), new CorrectionInfo(CorrectionTypes::SELF, '01.01.2021', Helpers::randomStr()), new Payments($this->generatePaymentObjects(2)), new Vats($this->generateVatObjects(2)), ); } }