예제 #1
0
 function testInstall()
 {
     ActiveMongo::install();
     $index = Model1::getIndexes();
     $this->assertTrue(isset($index[1]['key']['b']));
     $this->assertTrue(isset($index[2]['key']['a']));
     $this->assertEquals($index[1]['key']['b'], 1);
     $this->assertEquals($index[2]['key']['a'], -1);
     $this->asserTEquals(count($index), 3);
     $index = Model2::getIndexes();
     $this->assertTrue(isset($index[1]['key']['M1']));
     $this->assertEquals($index[1]['key']['M1'], 1);
     $this->asserTEquals(count($index), 2);
 }
예제 #2
0
  | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT      |
  | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS   |
  | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE                     |
  +---------------------------------------------------------------------------------+
  | Authors: César Rodas <*****@*****.**>                                           |
  +---------------------------------------------------------------------------------+
*/
require "../../lib/ActiveMongo.php";
require "Post.php";
require "Author.php";
ActiveMongo::connect("activemongo_blog");
/* delete collections */
PostModel::drop();
AuthorModel::drop();
/* This should be done just once */
ActiveMongo::install();
/* Create a new author
 * The property country is not defined
 * as an AuthorModel property, but it will
 * be saved. 
 */
$author = new AuthorModel();
$author->username = "******";
$author->name = "Cesar Rodas";
$author->country = "PY";
$author->save();
/* Add one blog post */
$post = new PostModel();
$post->uri = "/hello-world";
$post->title = "Hello World";
$post->author = $author->getID();