HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux ubuntu-8gb-hel1-1 6.8.0-55-generic #57-Ubuntu SMP PREEMPT_DYNAMIC Wed Feb 12 23:42:21 UTC 2025 x86_64
User: www-data (33)
PHP: 8.1.32
Disabled: NONE
Upload Files
File: /var/www/agighana.org_backup/IsTypeOfTest.php
<?php
namespace Hamcrest\Core;

class IsTypeOfTest extends \Hamcrest\AbstractMatcherTest
{

    protected function createMatcher()
    {
        return \Hamcrest\Core\IsTypeOf::typeOf('integer');
    }

    public function testEvaluatesToTrueIfArgumentMatchesType()
    {
        assertThat(array('5', 5), typeOf('array'));
        assertThat(false, typeOf('boolean'));
        assertThat(5, typeOf('integer'));
        assertThat(5.2, typeOf('double'));
        assertThat(null, typeOf('null'));
        assertThat(tmpfile(), typeOf('resource'));
        assertThat('a string', typeOf('string'));
    }

    public function testEvaluatesToFalseIfArgumentDoesntMatchType()
    {
        assertThat(false, not(typeOf('array')));
        assertThat(array('5', 5), not(typeOf('boolean')));
        assertThat(5.2, not(typeOf('integer')));
        assertThat(5, not(typeOf('double')));
        assertThat(false, not(typeOf('null')));
        assertThat('a string', not(typeOf('resource')));
        assertThat(tmpfile(), not(typeOf('string')));
    }

    public function testHasAReadableDescription()
    {
        $this->assertDescription('a double', typeOf('double'));
        $this->assertDescription('an integer', typeOf('integer'));
    }

    public function testDecribesActualTypeInMismatchMessage()
    {
        $this->assertMismatchDescription('was null', typeOf('boolean'), null);
        $this->assertMismatchDescription('was an integer <5>', typeOf('float'), 5);
    }
}