MockDocumentPost.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /**
  3. * Lithium: the most rad php framework
  4. *
  5. * @copyright Copyright 2013, Union of RAD (http://union-of-rad.org)
  6. * @license http://opensource.org/licenses/bsd-license.php The BSD License
  7. */
  8. namespace lithium\tests\mocks\data\model;
  9. use lithium\data\entity\Document;
  10. use lithium\data\collection\DocumentSet;
  11. class MockDocumentPost extends \lithium\tests\mocks\data\MockBase {
  12. protected $_meta = array('connection' => false, 'initialized' => true, 'key' => '_id');
  13. protected static $_connection;
  14. public static function __init() {}
  15. public static function schema($field = null) {
  16. $schema = parent::schema();
  17. $schema->append(array(
  18. '_id' => array('type' => 'id'),
  19. 'foo' => array('type' => 'object'),
  20. 'foo.bar' => array('type' => 'int')
  21. ));
  22. return $schema;
  23. }
  24. public function ret($record, $param1 = null, $param2 = null) {
  25. if ($param2) {
  26. return $param2;
  27. }
  28. if ($param1) {
  29. return $param1;
  30. }
  31. return null;
  32. }
  33. public function medicin($record) {
  34. return 'lithium';
  35. }
  36. public static function find($type = 'all', array $options = array()) {
  37. switch ($type) {
  38. case 'first':
  39. return new Document(array(
  40. 'data' => array('_id' => 2, 'name' => 'Two', 'content' => 'Lorem ipsum two'),
  41. 'model' => __CLASS__
  42. ));
  43. break;
  44. case 'all':
  45. default:
  46. return new DocumentSet(array(
  47. 'data' => array(
  48. array('_id' => 1, 'name' => 'One', 'content' => 'Lorem ipsum one'),
  49. array('_id' => 2, 'name' => 'Two', 'content' => 'Lorem ipsum two'),
  50. array('_id' => 3, 'name' => 'Three', 'content' => 'Lorem ipsum three')
  51. ),
  52. 'model' => __CLASS__
  53. ));
  54. break;
  55. }
  56. }
  57. }
  58. ?>