Ejemplo n.º 1
0
 public function testSetName()
 {
     // new entity
     $semester = new Semester();
     // Use the setName method
     $semester->setName("VÅR2015");
     // Assert the result
     $this->assertEquals("VÅR2015", $semester->getName());
 }
 public function testSetSemester()
 {
     // new assistantHistory entity
     $assistantHistory = new AssistantHistory();
     // new semester entity
     $semester = new Semester();
     // Set some random datat to the entity
     $semester->setName("Huehue");
     // Set the entity to assistantHistory
     $assistantHistory->setSemester($semester);
     // Assert the result
     $this->assertEquals($semester->getName(), $assistantHistory->getSemester()->getName());
 }
Ejemplo n.º 3
0
 public function load(ObjectManager $manager)
 {
     $semester1 = new Semester();
     $semester1->setName('NTNU Vår 2015');
     $semester1->setDepartment($this->getReference('dep-1'));
     $semester1->setAdmissionStartDate(new \DateTime('2015-01-01'));
     $semester1->setAdmissionEndDate(new \DateTime('2015-05-30'));
     $semester1->setSemesterStartDate(new \DateTime('2015-01-01'));
     $semester1->setSemesterEndDate(new \DateTime('2015-06-30'));
     $manager->persist($semester1);
     $semester2 = new Semester();
     $semester2->setName('HiST Vår 2015');
     $semester2->setDepartment($this->getReference('dep-2'));
     $semester2->setAdmissionStartDate(new \DateTime('2015-01-01'));
     $semester2->setAdmissionEndDate(new \DateTime('2015-05-30'));
     $semester2->setSemesterStartDate(new \DateTime('2015-01-01'));
     $semester2->setSemesterEndDate(new \DateTime('2015-06-30'));
     $manager->persist($semester2);
     $semester3 = new Semester();
     $semester3->setName('NMBU Vår 2015');
     $semester3->setDepartment($this->getReference('dep-3'));
     $semester3->setAdmissionStartDate(new \DateTime('2015-01-01'));
     $semester3->setAdmissionEndDate(new \DateTime('2015-05-30'));
     $semester3->setSemesterStartDate(new \DateTime('2015-01-01'));
     $semester3->setSemesterEndDate(new \DateTime('2015-06-30'));
     $manager->persist($semester3);
     $semester4 = new Semester();
     $semester4->setName('UiO Vår 2015');
     $semester4->setDepartment($this->getReference('dep-4'));
     $semester4->setAdmissionStartDate(new \DateTime('2015-01-01'));
     $semester4->setAdmissionEndDate(new \DateTime('2015-05-30'));
     $semester4->setSemesterStartDate(new \DateTime('2015-01-01'));
     $semester4->setSemesterEndDate(new \DateTime('2015-06-30'));
     $manager->persist($semester4);
     $manager->flush();
     $this->addReference('semester-1', $semester1);
     $this->addReference('semester-2', $semester2);
     $this->addReference('semester-3', $semester3);
     $this->addReference('semester-4', $semester4);
 }
Ejemplo n.º 4
0
 public static function getAll()
 {
     $con = Connection::getConnectionObject()->getConnection();
     // Check connection
     if (mysqli_connect_errno()) {
         echo "Failed to connect to MySQL: " . mysqli_connect_error();
     }
     $semesters = array();
     //Make an empty array
     $stmt = $con->prepare('SELECT id,name FROM semester');
     $stmt->execute();
     $stmt->bind_result($id, $name);
     while ($stmt->fetch()) {
         $semester = new Semester();
         $semester->id = $id;
         $semester->setName($name);
         array_push($semesters, $semester);
         //Push one by one
     }
     $stmt->close();
     return $semesters;
 }
Ejemplo n.º 5
0
 public function testRemoveSemester()
 {
     // new entity
     $department = new Department();
     $semester1 = new Semester();
     $semester1->setName("Semester1");
     $semester2 = new Semester();
     $semester2->setName("Semester2");
     $semester3 = new Semester();
     $semester3->setName("Semester3");
     // Use the addSemester method
     $department->addSemester($semester1);
     $department->addSemester($semester2);
     $department->addSemester($semester3);
     // Remove $semester1 from department
     $department->removeSemester($semester1);
     // Semesters are stored in an array
     $semesters = $department->getSemesters();
     // Loop through the array
     foreach ($semesters as $semester) {
         // Assert the result
         $this->assertNotEquals($semester1, $semester);
     }
 }