expectException(ValidationException::class); ShortUrlMeta::createFromRawData($data); } public function provideInvalidData(): iterable { yield [[ ShortUrlMetaInputFilter::VALID_SINCE => '', ShortUrlMetaInputFilter::VALID_UNTIL => '', ShortUrlMetaInputFilter::CUSTOM_SLUG => 'foobar', ShortUrlMetaInputFilter::MAX_VISITS => 'invalid', ]]; yield [[ ShortUrlMetaInputFilter::VALID_SINCE => '2017', ShortUrlMetaInputFilter::MAX_VISITS => 5, ]]; yield [[ ShortUrlMetaInputFilter::VALID_SINCE => new stdClass(), ShortUrlMetaInputFilter::VALID_UNTIL => 'foo', ]]; yield [[ ShortUrlMetaInputFilter::VALID_UNTIL => 500, ]]; yield [[ ShortUrlMetaInputFilter::MAX_VISITS => new stdClass(), ShortUrlMetaInputFilter::DOMAIN => 4, ]]; } /** @test */ public function properlyCreatedInstanceReturnsValues(): void { $meta = ShortUrlMeta::createFromParams(Chronos::parse('2015-01-01')->toAtomString(), null, 'foobar'); $this->assertTrue($meta->hasValidSince()); $this->assertEquals(Chronos::parse('2015-01-01'), $meta->getValidSince()); $this->assertFalse($meta->hasValidUntil()); $this->assertNull($meta->getValidUntil()); $this->assertTrue($meta->hasCustomSlug()); $this->assertEquals('foobar', $meta->getCustomSlug()); $this->assertFalse($meta->hasMaxVisits()); $this->assertNull($meta->getMaxVisits()); } }