Пример #1
0
 /**
  * @group DDC-168
  */
 public function testJoinedSubclassPersisterRequiresSpecificOrderOfMetadataReflFieldsArray()
 {
     //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger);
     $spouse = new CompanyEmployee();
     $spouse->setName("Blub");
     $spouse->setDepartment("Accounting");
     $spouse->setSalary(500);
     $employee = new CompanyEmployee();
     $employee->setName("Foo");
     $employee->setDepartment("bar");
     $employee->setSalary(1000);
     $employee->setSpouse($spouse);
     $this->_em->persist($spouse);
     $this->_em->persist($employee);
     $this->_em->flush();
     $this->_em->clear();
     $q = $this->_em->createQuery("SELECT e FROM Doctrine\\Tests\\Models\\Company\\CompanyEmployee e WHERE e.name = ?1");
     $q->setParameter(1, "Foo");
     $theEmployee = $q->getSingleResult();
     $this->assertEquals("bar", $theEmployee->getDepartment());
     $this->assertEquals("Foo", $theEmployee->getName());
     $this->assertEquals(1000, $theEmployee->getSalary());
     $this->assertInstanceOf('Doctrine\\Tests\\Models\\Company\\CompanyEmployee', $theEmployee);
     $this->assertInstanceOf('Doctrine\\Tests\\Models\\Company\\CompanyEmployee', $theEmployee->getSpouse());
 }
 public function generateFixture()
 {
     $car = new CompanyCar('Caramba');
     $manager1 = new CompanyManager();
     $manager1->setName('Roman B.');
     $manager1->setTitle('Foo');
     $manager1->setDepartment('IT');
     $manager1->setSalary(100000);
     $manager1->setCar($car);
     $person2 = new CompanyEmployee();
     $person2->setName('Benjamin E.');
     $person2->setDepartment('IT');
     $person2->setSalary(200000);
     $person3 = new CompanyEmployee();
     $person3->setName('Guilherme B.');
     $person3->setDepartment('IT2');
     $person3->setSalary(400000);
     $person4 = new CompanyEmployee();
     $person4->setName('Jonathan W.');
     $person4->setDepartment('IT2');
     $person4->setSalary(800000);
     $person2->setSpouse($person3);
     $manager1->addFriend($person4);
     $person2->addFriend($person3);
     $person2->addFriend($person4);
     $person3->addFriend($person4);
     $this->_em->persist($car);
     $this->_em->persist($manager1);
     $this->_em->persist($person2);
     $this->_em->persist($person3);
     $this->_em->persist($person4);
     $this->_em->flush();
     $this->_em->clear();
 }