Elgg\Database\RelationshipsTest::testGetEntitiesFromRelationshipFilterByTimeCreatedLowerAndUpper PHP Метод

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

Check that you can get entities by filtering them on relationship time created lower and upper
    public function testGetEntitiesFromRelationshipFilterByTimeCreatedLowerAndUpper()
    {
        // get a timestamp before creating the relationship
        $ts_lower = time() - 1;
        add_entity_relationship($this->guids[0], 'testGetEntitiesFromRelationship', $this->guids[1]);
        // get a timestamp after creating the relationship
        $ts_upper = time() + 1;
        // check that if relationship time created is between lower and upper you get the just created entity
        $options = array('relationship' => 'testGetEntitiesFromRelationship', 'relationship_guid' => $this->guids[0], 'relationship_created_time_lower' => $ts_lower, 'relationship_created_time_upper' => $ts_upper);
        $es = elgg_get_entities_from_relationship($options);
        $this->assertTrue(is_array($es));
        $this->assertIdentical(count($es), 1);
        foreach ($es as $e) {
            $this->assertEqual($this->guids[1], $e->guid);
        }
        // check that if  ts_lower > ts_upper you get no entities
        $options = array('relationship' => 'testGetEntitiesFromRelationship', 'relationship_guid' => $this->guids[0], 'relationship_created_time_lower' => $ts_upper, 'relationship_created_time_upper' => $ts_lower);
        $es = elgg_get_entities_from_relationship($options);
        $this->assertTrue(is_array($es));
        $this->assertIdentical(count($es), 0);
    }