Example #1
0
 public function testCanFindByNotValue()
 {
     $child = new Child();
     $query = new \morph\Query();
     $query->property('Name')->notEqualTo('a_musing_moose');
     $results = $child->findByQuery($query);
     $this->assertEquals(3, $results->totalCount());
 }
Example #2
0
    public function testSort()
    {
        $query = new \morph\Query();
        $query->property('id')
            ->equals(12)
            ->property('added')
            ->sort(\morph\Enum::DIRECTION_DESC);

        $this->assertArrayNotHasKey('added', $query->getRawQuery());
    }
Example #3
0
    /**
     * Loads the stored references
     * @return void
     */
    private function loadFromReferences()
    {
        $ids = array();
        $collection = null;
        if (count($this->references) > 0) {
            foreach ($this->references as $reference){
                $ids[] = $reference['$id'];
            }

            $query = new \morph\Query();
            $query->property('_id')->in($ids);

            $object = new $this->type;

            $collection = \morph\Storage::instance()
                    ->findByQuery($object, $query)
                    ->toCollection(); //@todo this could get nasty with large collections!
            
        }
        
        $this->value =  new \morph\property\StatefulCollection($this, $collection);
        $this->loaded = true;
    }