<?php

namespace CatLab\RESTResource\Tests;

use CatLab\Charon\Transformers\ScalarTransformer;
use CatLab\Requirements\Enums\PropertyType;
use PHPUnit_Framework_TestCase;

/**
 * Class ScalarTransformerTest
 * @package CatLab\RESTResource\Tests
 */
class ScalarTransformerTest extends PHPUnit_Framework_TestCase
{
    /**
     *
     * @throws \CatLab\Charon\Exceptions\InvalidScalarException
     */
    public function testBooleanTransformer()
    {
        $transformer = new ScalarTransformer(PropertyType::BOOL);

        $this->assertNull($transformer->toParameterValue(null));

        $this->assertFalse($transformer->toParameterValue(0));
        $this->assertFalse($transformer->toParameterValue('0'));
        $this->assertFalse($transformer->toParameterValue('false'));
        $this->assertFalse($transformer->toParameterValue('FALSE'));

        $this->assertTrue($transformer->toParameterValue('true'));
        $this->assertTrue($transformer->toParameterValue('TRUE'));
        $this->assertTrue($transformer->toParameterValue(1));
        $this->assertTrue($transformer->toParameterValue('1'));
    }
}
Allow literal string "false" in scalar transformer.
Allow literal string "false" in scalar transformer.
