lithium\tests\mocks\data\model\MockDocumentPost::find PHP Method

find() public static method

public static find ( $type = 'all', array $options = [] )
$options array
    public static function find($type = 'all', array $options = array())
    {
        switch ($type) {
            case 'first':
                return new Document(array('data' => array('_id' => 2, 'name' => 'Two', 'content' => 'Lorem ipsum two'), 'model' => __CLASS__));
                break;
            case 'all':
            default:
                return new DocumentSet(array('data' => array(array('_id' => 1, 'name' => 'One', 'content' => 'Lorem ipsum one'), array('_id' => 2, 'name' => 'Two', 'content' => 'Lorem ipsum two'), array('_id' => 3, 'name' => 'Three', 'content' => 'Lorem ipsum three')), 'model' => __CLASS__));
                break;
        }
    }

Usage Example

Beispiel #1
0
 public function testGetFields()
 {
     $document = MockDocumentPost::find('first');
     $expected = 2;
     $result = $document->id;
     $this->assertEqual($expected, $result);
     $expected = 'Two';
     $result = $document->name;
     $this->assertEqual($expected, $result);
     $expected = 'Lorem ipsum two';
     $result = $document->content;
     $this->assertEqual($expected, $result);
 }