コード例 #1
0
 function testFind()
 {
     //Arrange
     $name = "Math";
     $id = 1;
     $test_department = new Department($name, $id);
     $test_department->save();
     $name2 = "Business";
     $id2 = 2;
     $test_department2 = new Department($name2, $id2);
     $test_department2->save();
     //Act
     $id = $test_department->getId();
     $result = Department::find($id);
     //Assert
     $this->assertEquals($test_department, $result);
 }
コード例 #2
0
 /**
  * Returns an array of Faculty objects for the given department.
  * @param Department $department
  * @return Array List of faculty for requested department.
  */
 public static function getFacultyByDepartmentAssoc(Department $department)
 {
     $sql = "SELECT intern_faculty.* FROM intern_faculty JOIN intern_faculty_department ON intern_faculty.id = intern_faculty_department.faculty_id WHERE intern_faculty_department.department_id = {$department->getId()} ORDER BY last_name ASC";
     $result = \PHPWS_DB::getAll($sql);
     return $result;
 }
コード例 #3
0
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      Department $value A Department object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(Department $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }
コード例 #4
0
 /**
  * Declares an association between this object and a Department object.
  *
  * @param      Department $v
  * @return     Employee The current object (for fluent API support)
  * @throws     PropelException
  */
 public function setDepartment(Department $v = null)
 {
     if ($v === null) {
         $this->setDepartmentId(NULL);
     } else {
         $this->setDepartmentId($v->getId());
     }
     $this->aDepartment = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the Department object, it will not be re-added.
     if ($v !== null) {
         $v->addEmployee($this);
     }
     return $this;
 }
コード例 #5
0
 function test_getCourses()
 {
     //Arrange
     $test_department = new Department("Biology", "346 Stupid Avenue");
     $test_department->save();
     $name = "History 0001";
     $code = "HS001";
     $test_course = new Course($name, $code, $test_department->getId());
     $test_course->save();
     $name2 = "Dogs 101";
     $code2 = "DW101";
     $test_course2 = new Course($name2, $code2, $test_department->getId());
     $test_course2->save();
     //Act
     $result = $test_department->getCourses();
     //Assert
     $this->assertEquals([$test_course, $test_course2], $result);
 }
コード例 #6
0
 function test_updateCompleted()
 {
     //Arrange
     $test_department = new Department("Biology", "346 Stupid Avenue");
     $test_department->save();
     $test_student = new Student("Shmuel Irving-Jones", "2015-08-25", $test_department->getId());
     $test_student->save();
     $test_course = new Course("High Times", "CHEM420", $test_department->getId());
     $test_course->save();
     $test_course2 = new Course("Gavanese Jamelan", "MUSC69", $test_department->getId());
     $test_course2->save();
     $test_student->addCourse($test_course);
     $test_student->addCourse($test_course2);
     //Act
     $test_student->updateCompleted($test_course->getId());
     //Assert
     $this->assertEquals(true, $test_student->getCompleted($test_course->getId()));
 }
コード例 #7
0
 function test_getStudents()
 {
     //Arrange
     $test_department = new Department("Biology", "346 Stupid Avenue");
     $test_department->save();
     $test_course = new Course("Fundamentals of Human Anatomy", "SEXY101", $test_department->getId());
     $test_course->save();
     $test_course2 = new Course("Organic Chemistry of Cannabinoids", "CHEM420", $test_department->getId());
     $test_course2->save();
     $test_student = new Student("Sarah", "2000-04-01", $test_department->getId());
     $test_student->save();
     $test_student2 = new Student("JC", "0000-12-25", $test_department->getId());
     $test_student2->save();
     //Act
     $test_course->addStudent($test_student);
     $test_course->addStudent($test_student2);
     $test_course2->addStudent($test_student);
     //Assert
     $this->assertEquals($test_course->getStudents(), [$test_student, $test_student2]);
 }