HEX
Server: LiteSpeed
System: Linux server334.web-hosting.com 4.18.0-553.124.4.lve.el8.x86_64 #1 SMP Fri May 15 13:02:13 UTC 2026 x86_64
User: richfield (1256)
PHP: 8.2.31
Disabled: NONE
Upload Files
File: /home/richfield/www/rich/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Type/IsScalarTest.php
<?php
namespace Hamcrest\Type;

class IsScalarTest extends \Hamcrest\AbstractMatcherTest
{

    protected function createMatcher()
    {
        return \Hamcrest\Type\IsScalar::scalarValue();
    }

    public function testEvaluatesToTrueIfArgumentMatchesType()
    {
        assertThat(true, scalarValue());
        assertThat(5, scalarValue());
        assertThat(5.3, scalarValue());
        assertThat('5', scalarValue());
    }

    public function testEvaluatesToFalseIfArgumentDoesntMatchType()
    {
        assertThat(null, not(scalarValue()));
        assertThat(array(), not(scalarValue()));
        assertThat(array(5), not(scalarValue()));
        assertThat(tmpfile(), not(scalarValue()));
        assertThat(new \stdClass(), not(scalarValue()));
    }

    public function testHasAReadableDescription()
    {
        $this->assertDescription('a scalar', scalarValue());
    }

    public function testDecribesActualTypeInMismatchMessage()
    {
        $this->assertMismatchDescription('was null', scalarValue(), null);
        $this->assertMismatchDescription('was an array ["foo"]', scalarValue(), array('foo'));
    }
}