Time example


  protected $time;

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();

    $this->requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->getMock();
    $this->time = new Time($this->requestStack);
  }

  /** * Tests the getRequestTime method. * * @covers ::getRequestTime */
  public function testGetRequestTime() {
    $expected = 12345678;

    $request = Request::createFromGlobals();
    
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;

class TimeValidatorTest extends ConstraintValidatorTestCase
{
    protected function createValidator(): TimeValidator
    {
        return new TimeValidator();
    }

    public function testNullIsValid()
    {
        $this->validator->validate(null, new Time());

        $this->assertNoViolation();
    }

    public function testDefaultWithSeconds()
    {
        $this->validator->validate('10:15:25', new Time());

        $this->assertNoViolation();
    }

    
Home | Imprint | This part of the site doesn't use cookies.