lithium\tests\cases\data\collection\MultiKeyRecordSetTest::testOffsetExists PHP Метод

testOffsetExists() публичный Метод

public testOffsetExists ( )
    public function testOffsetExists()
    {
        $this->assertFalse($this->_recordSet->offsetExists(0));
        $this->assertTrue($this->_recordSet->offsetExists(1));
        $this->assertTrue($this->_recordSet->offsetExists(2));
        $this->assertTrue($this->_recordSet->offsetExists(3));
        $this->assertTrue($this->_recordSet->offsetExists(4));
        $this->assertArrayHasKey(3, $this->_recordSet);
        $this->assertFalse($this->_objectRecordSet->offsetExists(0));
        $this->assertTrue($this->_objectRecordSet->offsetExists(1));
        $this->assertTrue($this->_objectRecordSet->offsetExists(2));
        $this->assertTrue($this->_objectRecordSet->offsetExists(3));
        $this->assertTrue($this->_objectRecordSet->offsetExists(4));
        $this->assertArrayHasKey(3, $this->_objectRecordSet);
        $data = array(array('client_id' => 1, 'invoice_id' => 4, 'title' => 'Payment1'), array('client_id' => 2, 'invoice_id' => 5, 'title' => 'Payment2'), array('client_id' => 3, 'invoice_id' => 6, 'title' => 'Payment3'));
        $payments = new MockMultiKeyRecordSet(array('data' => $data, 'model' => $this->_model2));
        $this->assertArrayHasKey(array('client_id' => 1, 'invoice_id' => 4), $payments);
        $this->assertArrayHasKey(array('invoice_id' => 4, 'client_id' => 1), $payments);
        $this->assertArrayNotHasKey(0, $payments);
        $this->assertArrayNotHasKey(true, $payments);
        $this->assertArrayNotHasKey(false, $payments);
        $this->assertArrayNotHasKey(null, $payments);
        $this->assertArrayNotHasKey('string', $payments);
        $records = new MockMultiKeyRecordSet();
        $records[0] = array('title' => 'Record0');
        $records[1] = array('title' => 'Record1');
        $this->assertArrayHasKey(true, $records);
        $this->assertArrayHasKey(null, $records);
        $this->assertArrayHasKey(false, $records);
        $this->assertArrayHasKey(array(), $records);
        $this->assertArrayHasKey(0, $records);
        $this->assertArrayHasKey('0', $records);
        $this->assertArrayHasKey(1, $records);
        $this->assertArrayHasKey('1', $records);
        $this->assertArrayNotHasKey(2, $records);
    }