Example #1
0
 protected function _testIssue11042()
 {
     $robot = RelationsRobots::findFirst();
     $this->assertNotEquals($robot, false);
     $this->assertEquals($robot->getDirtyState(), $robot::DIRTY_STATE_PERSISTENT);
     $robotsParts = $robot->getRelationsRobotsParts();
     $this->assertEquals($robot->getDirtyState(), $robot::DIRTY_STATE_PERSISTENT);
     $robot = RelationsRobots::findFirst();
     $this->assertNotEquals($robot, false);
     $robotsParts = $robot->relationsRobotsParts;
     $this->assertEquals($robot->getDirtyState(), $robot::DIRTY_STATE_PERSISTENT);
 }
Example #2
0
 protected function _testIssue2244($di)
 {
     $options = array('order' => '', 'conditions' => '');
     $robot = RelationsRobots::findFirst();
     $this->assertNotEquals($robot, false);
     $robotsParts = $robot->getRelationsRobotsParts($options);
     $this->assertEquals(get_class($robotsParts), 'Phalcon\\Mvc\\Model\\Resultset\\Simple');
     $this->assertEquals(count($robotsParts), 3);
 }
 public function _executeTestsNormal($di)
 {
     $manager = $di->getShared('modelsManager');
     $success = $manager->existsBelongsTo('RelationsRobotsParts', 'RelationsRobots');
     $this->assertTrue($success);
     $success = $manager->existsBelongsTo('RelationsRobotsParts', 'RelationsParts');
     $this->assertTrue($success);
     $success = $manager->existsHasMany('RelationsRobots', 'RelationsRobotsParts');
     $this->assertTrue($success);
     $success = $manager->existsHasMany('RelationsParts', 'RelationsRobotsParts');
     $this->assertTrue($success);
     $success = $manager->existsHasManyToMany('RelationsRobots', 'RelationsParts');
     $this->assertTrue($success);
     $robot = RelationsRobots::findFirst();
     $this->assertNotEquals($robot, false);
     $robotsParts = $robot->getRelationsRobotsParts();
     $this->assertEquals(get_class($robotsParts), 'Phalcon\\Mvc\\Model\\Resultset\\Simple');
     $this->assertEquals(count($robotsParts), 3);
     $parts = $robot->getRelationsParts();
     $this->assertEquals(get_class($parts), 'Phalcon\\Mvc\\Model\\Resultset\\Simple');
     $this->assertEquals(count($parts), 3);
     /** Passing parameters to magic methods **/
     $robotsParts = $robot->getRelationsRobotsParts("parts_id = 1");
     $this->assertEquals(get_class($robotsParts), 'Phalcon\\Mvc\\Model\\Resultset\\Simple');
     $this->assertEquals(count($robotsParts), 1);
     /** Passing parameters to magic methods **/
     $parts = $robot->getRelationsParts("RelationsParts.id = 1");
     $this->assertEquals(get_class($parts), 'Phalcon\\Mvc\\Model\\Resultset\\Simple');
     $this->assertEquals(count($parts), 1);
     $robotsParts = $robot->getRelationsRobotsParts(array("parts_id > :parts_id:", "bind" => array("parts_id" => 1)));
     $this->assertEquals(get_class($robotsParts), 'Phalcon\\Mvc\\Model\\Resultset\\Simple');
     $this->assertEquals(count($robotsParts), 2);
     $this->assertEquals($robotsParts->getFirst()->parts_id, 2);
     $parts = $robot->getRelationsParts(array("RelationsParts.id > :id:", "bind" => array("id" => 1)));
     $this->assertEquals(get_class($parts), 'Phalcon\\Mvc\\Model\\Resultset\\Simple');
     $this->assertEquals(count($parts), 2);
     $this->assertEquals($parts->getFirst()->id, 2);
     $robotsParts = $robot->getRelationsRobotsParts(array("parts_id > :parts_id:", "bind" => array("parts_id" => 1), "order" => "parts_id DESC"));
     $this->assertEquals(get_class($robotsParts), 'Phalcon\\Mvc\\Model\\Resultset\\Simple');
     $this->assertEquals(count($robotsParts), 2);
     $this->assertEquals($robotsParts->getFirst()->parts_id, 3);
     /** Magic counting */
     $number = $robot->countRelationsRobotsParts();
     $this->assertEquals($number, 3);
     $part = RelationsParts::findFirst();
     $this->assertNotEquals($part, false);
     $robotsParts = $part->getRelationsRobotsParts();
     $this->assertEquals(get_class($robotsParts), 'Phalcon\\Mvc\\Model\\Resultset\\Simple');
     $this->assertEquals(count($robotsParts), 1);
     $number = $part->countRelationsRobotsParts();
     $this->assertEquals($number, 1);
     $robotPart = RelationsRobotsParts::findFirst();
     $this->assertNotEquals($robotPart, false);
     $robot = $robotPart->getRelationsRobots();
     $this->assertEquals(get_class($robot), 'RelationsRobots');
     $part = $robotPart->getRelationsParts();
     $this->assertEquals(get_class($part), 'RelationsParts');
     /** Relations in namespaced models */
     $robot = Some\Robots::findFirst();
     $this->assertNotEquals($robot, false);
     $robotsParts = $robot->getRobotsParts();
     $this->assertEquals(get_class($robotsParts), 'Phalcon\\Mvc\\Model\\Resultset\\Simple');
     $this->assertEquals(count($robotsParts), 3);
     $robotsParts = $robot->getRobotsParts("parts_id = 1");
     $this->assertEquals(get_class($robotsParts), 'Phalcon\\Mvc\\Model\\Resultset\\Simple');
     $this->assertEquals(count($robotsParts), 1);
     $robotsParts = $robot->getRobotsParts(array("parts_id > :parts_id:", "bind" => array("parts_id" => 1), "order" => "parts_id DESC"));
     $this->assertEquals(get_class($robotsParts), 'Phalcon\\Mvc\\Model\\Resultset\\Simple');
     $this->assertEquals(count($robotsParts), 2);
     $this->assertEquals($robotsParts->getFirst()->parts_id, 3);
 }