/home/kueuepay/www/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Array/IsArrayContainingKeyTest.php
<?php
namespace Hamcrest\Arrays;

use Hamcrest\AbstractMatcherTest;

class IsArrayContainingKeyTest extends AbstractMatcherTest
{

    protected function createMatcher()
    {
        return IsArrayContainingKey::hasKeyInArray('irrelevant');
    }

    public function testMatchesSingleElementArrayContainingKey()
    {
        $array = array('a'=>1);

        $this->assertMatches(hasKey('a'), $array, 'Matches single key');
    }

    public function testMatchesArrayContainingKey()
    {
        $array = array('a'=>1, 'b'=>2, 'c'=>3);

        $this->assertMatches(hasKey('a'), $array, 'Matches a');
        $this->assertMatches(hasKey('c'), $array, 'Matches c');
    }

    public function testMatchesArrayContainingKeyWithIntegerKeys()
    {
        $array = array(1=>'A', 2=>'B');

        assertThat($array, hasKey(1));
    }

    public function testMatchesArrayContainingKeyWithNumberKeys()
    {
        $array = array(1=>'A', 2=>'B');

        assertThat($array, hasKey(1));

        // very ugly version!
        assertThat($array, IsArrayContainingKey::hasKeyInArray(2));
    }

    public function testHasReadableDescription()
    {
        $this->assertDescription('array with key "a"', hasKey('a'));
    }

    public function testDoesNotMatchEmptyArray()
    {
        $this->assertMismatchDescription('array was []', hasKey('Foo'), array());
    }

    public function testDoesNotMatchArrayMissingKey()
    {
        $array = array('a'=>1, 'b'=>2, 'c'=>3);

        $this->assertMismatchDescription('array was ["a" => <1>, "b" => <2>, "c" => <3>]', hasKey('d'), $array);
    }
}
Web Journal
top

Discover the Latest in Digital Payments and NFC Technology

Dive into our blog to explore the cutting-edge trends in digital payments and NFC technology. Stay updated on the innovations that are revolutionizing transactions, boosting security, and making payments quicker and more convenient. Learn how these advancements are shaping the future of financial interactions and driving the global transition towards a cashless world.

The Rise of Contactless Payments:...

In recent years, contactless payments have surged in popularity, driven...

Enhancing Payment Security: The Role...

As digital transactions proliferate, ensuring robust payment security is more critical than ever. Two foundational...

The Future of Digital Wallets:...

Digital wallets have fundamentally transformed how we manage money, offering a streamlined, secure, and highly...