<?php
namespace nur\b\date;

use nur\t\TestCase;

class TrangeTest extends TestCase {
  function testBefore() {
    $h0 = new Time(0);
    $h12 = new Time(12*60*60);
    $h18 = new Time(18*60*60);
    $h24 = new Time(24*60*60);
    
    $p1 = new Trange($h0, $h12);
    self::assertFalse($p1->before($h0));
    self::assertTrue($p1->before($h12));
    self::assertTrue($p1->before($h18));
    self::assertTrue($p1->before($h24));
    
    $p2 = new Trange($h0, $h18);
    self::assertFalse($p2->before($h0));
    self::assertFalse($p2->before($h12));
    self::assertTrue($p2->before($h18));
    self::assertTrue($p2->before($h24));
    
    $p3 = new Trange($h12, $h18);
    self::assertFalse($p3->before($h0));
    self::assertFalse($p3->before($h12));
    self::assertTrue($p3->before($h18));
    self::assertTrue($p3->before($h24));
    
    $p4 = new Trange($h12, $h24);
    self::assertFalse($p4->before($h0));
    self::assertFalse($p4->before($h12));
    self::assertFalse($p4->before($h18));
    self::assertTrue($p4->before($h24));
    
    $p5 = new Trange($h18, $h24);
    self::assertFalse($p5->before($h0));
    self::assertFalse($p5->before($h12));
    self::assertFalse($p5->before($h18));
    self::assertTrue($p5->before($h24));
  }

  function testContains() {
    $h0 = new Time(0);
    $h12 = new Time(12*60*60);
    $h18 = new Time(18*60*60);
    $h24 = new Time(24*60*60);

    $p1 = new Trange($h0, $h18);
    self::assertTrue($p1->contains($h0));
    self::assertTrue($p1->contains($h12));
    self::assertFalse($p1->contains($h18));
    self::assertFalse($p1->contains($h24));

    $p2 = new Trange($h12, $h24);
    self::assertFalse($p2->contains($h0));
    self::assertTrue($p2->contains($h12));
    self::assertTrue($p2->contains($h18));
    self::assertFalse($p2->contains($h24));
  }

  function testAfter() {
    $h0 = new Time(0);
    $h12 = new Time(12*60*60);
    $h18 = new Time(18*60*60);
    $h24 = new Time(24*60*60);

    $p1 = new Trange($h0, $h12);
    self::assertFalse($p1->after($h0));
    self::assertFalse($p1->after($h12));
    self::assertFalse($p1->after($h18));
    self::assertFalse($p1->after($h24));

    $p2 = new Trange($h0, $h18);
    self::assertFalse($p2->after($h0));
    self::assertFalse($p2->after($h12));
    self::assertFalse($p2->after($h18));
    self::assertFalse($p2->after($h24));

    $p3 = new Trange($h12, $h18);
    self::assertTrue($p3->after($h0));
    self::assertFalse($p3->after($h12));
    self::assertFalse($p3->after($h18));
    self::assertFalse($p3->after($h24));
    
    $p4 = new Trange($h12, $h24);
    self::assertTrue($p4->after($h0));
    self::assertFalse($p4->after($h12));
    self::assertFalse($p4->after($h18));
    self::assertFalse($p4->after($h24));
    
    $p5 = new Trange($h18, $h24);
    self::assertTrue($p5->after($h0));
    self::assertTrue($p5->after($h12));
    self::assertFalse($p5->after($h18));
    self::assertFalse($p5->after($h24));
  }
}