<?php

namespace nur\data\types;

use nur\b\ValueException;
use nur\t\TestCase;
use stdClass;

class ContentTypeTest extends TestCase {
  function testWith() {
    $type = new ContentType();
    self::assertSame(false, $type->with(false));
    self::assertSame(null, $type->with(null));
    self::assertSame("", $type->with(""));
    self::assertSame(" ", $type->with(" "));
    self::assertSame( " abc ", $type->with(" abc "));
    self::assertSame("abc", $type->with("abc"));
    self::assertSame(-1, $type->with(-1));
    self::assertSame(0, $type->with(0));
    self::assertSame(1, $type->with(1));
    self::assertSame(1.2, $type->with(1.2));
    self::assertSame(true, $type->with(true));
    self::assertSame([], $type->with([]));
    self::assertSame([1], $type->with([1]));
    self::assertSame(["abc"], $type->with(["abc"]));
    self::assertException(ValueException::class, [$type, "with"], new stdClass());
    self::assertException(ValueException::class, [$type, "with"], [new stdClass()]);
  }
}
