How to use shouldHave method of or class

Best Prophecy code snippet using or.shouldHave

class.competency.inc

Source:class.competency.inc Github

copy

Full Screen

1<?php2useattrib("atktextattribute");3useattrib("atknumberattribute");4useattrib("atkdateattribute");5class competency extends atkNode6{7 function competency ()8 {9 $this->atkNode("competency",NF_EDITAFTERADD);10 $this->add(new atkAttribute("id", AF_PRIMARY | AF_HIDE | AF_AUTO_INCREMENT | AF_FORCE_LOAD));11 $this->add(new atkAttribute("name", AF_OBLIGATORY | AF_SEARCHABLE));12 $this->add(new atkTextAttribute("description"));13 $this->add(new atkManyToOneRelation("domain_id", "competency.competencydomain", AF_OBLIGATORY | AF_SEARCHABLE));14 $this->add(new atkOneToManyRelation("competencyniveau", "competency.competencyniveau", "competency_id",AF_CASCADE_DELETE));15 $this->setTable("competency");16 }17 function descriptor_def ()18 {19 return "[name]";20 }21 function recordActions($rec, &$actions, &$mraactions)22 {23 if(atkGetNode('competency.competences')->select(atkGetNode('competency.competences')->getTable().'.competency_id='.$rec["id"])->rowCount() > 0)24 {25 unset($actions["delete"]);26 }27 }28 /**29 * Makes sure that when our competency is deleted it will remove all connections in the other tables as well30 *31 * @param array $record the record to remove from the database32 */33 function preDelete($record)34 {35 atkGetNode('competency.competencyextra')->deleteDb(atkGetNode('competency.competencyextra')->getTable().'.competency_id=' . $record['id']);36 atkGetNode('competency.competencycomments')->deleteDb(atkGetNode('competency.competencycomments')->getTable().'.competency_id=' . $record['id']);37 atkGetNode('competency.competencyprofilecomp')->deleteDb( atkGetNode('competency.competencyprofilecomp')->getTable().'.competency_id=' . $record['id']);38 atkGetNode('competency.competenceplanning')->deleteDb(atkGetNode('competency.competenceplanning')->getTable().'.competency_id='. $record['id']);39 atkGetNode('competency.alwaysshow')->deleteDb(atkGetNode('competency.alwaysshow')->getTable().'.competency_id='. $record['id']);40 }41 /**42 * Generates the data we need to make a radar graph of competencty holes43 * This method generates the data on domain niveau44 *45 * @param array params This array needs to contain a value for ["profile"]46 * @param boolean $raw47 * @return array with data for the graph48 */49 function graph_competencyDomainHoles ($params, $raw = false)50 {51 $db = &atkGetDb();52 // first we select all persons that have this profile53 //prepare the query for getting the data\54 $query = &$db->createQuery();55 //we add the table competences56 $query->addTable("person");57 $query->addField("id");58 $query->addCondition("id IN (SELECT person_id FROM competency_profile_person where profile_id =" . $params["profile"] . ")");59 $persons = $db->getrows($query->buildSelect());60 $personsCount = count($persons);61 $levelQuery = &$db->createQuery();62 $levelQuery->addTable("competency_profile_person");63 $levelQuery->addJoin("person", "", "person.id = competency_profile_person.person_id", true);64 $levelQuery->addJoin("competency_competences", "", "person.id = competency_competences.person_id", true);65 $levelQuery->addJoin("competency_niveau", "", "competency_niveau.id = competency_competences.niveau_id", true);66 $levelQuery->addJoin("competency", "", "competency_competences.competency_id = competency.id", true);67 $levelQuery->addJoin("competency_domain", "", "competency_domain.id = competency.domain_id", true);68 $levelQuery->addField("competency_competences.competency_id as competency");69 $levelQuery->addField("max(competency_niveau.level) as level");70 $levelQuery->addField("competency_domain.name as dName");71 $levelQuery->addField("competency_domain.id as dId");72 $levelQuery->addCondition("competency_profile_person.profile_id =" . $params["profile"]);73 $levelQuery->addGroupBy("person.id");74 $levelQuery->addGroupBy("competency_competences.competency_id");75 $levels = $db->getrows($levelQuery->buildSelect());76 $counts = array();77 $csims = array();78 foreach ($levels as $comp)79 {80 //data for the urls81 if (isset($counts[$comp["dName"]]))82 {83 $counts[$comp["dName"]] += isset($comp["level"]) ? $comp["level"] : 1;84 } else85 {86 $counts[$comp["dName"]] = isset($comp["level"]) ? $comp["level"] : 1;87 }88 $csims[$comp["dName"]] = "javascript:top.frames['main'].changeUrl(" . $comp["dId"] . "," . $params["profile"] . ")";89 }90 $csimArray = array();91 foreach ($csims as $sim)92 {93 $csimArray[] = $sim;94 }95 $lQuery = &$db->createQuery();96 $lQuery->addTable("competency_profile_comp");97 $lQuery->addJoin("competency_niveau", "", "competency_niveau.id = competency_profile_comp.niveau_id", true);98 $lQuery->addJoin("competency", "", "competency_profile_comp.competency_id = competency.id", true);99 $lQuery->addJoin("competency_domain", "", "competency_domain.id = competency.domain_id", true);100 $lQuery->addField("max(level) as level");101 $lQuery->addField("competency_profile_comp.competency_id as competency");102 $lQuery->addField("competency_domain.name as dName");103 $lQuery->addField("competency_domain.id as dId");104 $lQuery->addCondition("competency_profile_comp.profile_id =" . $params["profile"]);105 $lQuery->addGroupBy("competency_profile_comp.competency_id");106 $leve = $db->getrows($lQuery->buildSelect());107 $coun = array();108 foreach ($leve as $com)109 {110 if (isset($coun[$com["dName"]]))111 {112 $coun[$com["dName"]] += isset($com["level"]) ? $com["level"] : 1;113 } else114 {115 $coun[$com["dName"]] = isset($com["level"]) ? $com["level"] : 1;116 }117 }118 $dataset = array();119 foreach ($coun as $itemKey => $item)120 {121 $average = (int)$item * $personsCount;122 if($average > 0)123 {124 $percentage = (100 / $average) * $counts[$itemKey];125 }126 else127 {128 $percentage = 0;129 }130 $dataset[$itemKey] = $percentage;131 }132 if ($raw)133 {134 return($dataset);135 }136 //we check how many graphs will be generated and how much data is in the last of them. if we have less then 3 points we will137 //take points from the second last and add them to the last so its till a good graph138 return array("name" => "competency voids" , "data" => array_slice($dataset,$params["offset"],$params["reach"],true) , "CSIM" => $csimArray );139 }140 /**141 * creates the graph for competency holes142 *143 * @param array $params this array needs to contain values for ["profile"] and ["domain"]144 * @param boolean $raw145 * @return array146 */147 function graph_competencyHoles ($params, $raw = false)148 {149 $domain = $params["domain"];150 $db = &atkGetDb();151 // first we select all persons that have this profile152 //prepare the query for getting the data\153 $query = &$db->createQuery();154 //we add the table competences155 $query->addTable("person");156 $query->addField("id");157 $query->addCondition("id IN (SELECT person_id FROM competency_profile_person where profile_id =" . $params["profile"] . ")");158 $persons = $db->getrows($query->buildSelect());159 $personsCount = count($persons);160 $levelQuery = &$db->createQuery();161 $levelQuery->addTable("competency_profile_person");162 $levelQuery->addJoin("person", "", "person.id = competency_profile_person.person_id", true);163 $levelQuery->addJoin("competency_competences", "", "person.id = competency_competences.person_id", true);164 $levelQuery->addJoin("competency_niveau", "", "competency_niveau.id = competency_competences.niveau_id", true);165 $levelQuery->addJoin("competency", "", "competency_competences.competency_id = competency.id", true);166 $levelQuery->addJoin("competency_domain", "", "competency_domain.id = competency.domain_id", true);167 $levelQuery->addField("competency_competences.competency_id as competency");168 $levelQuery->addField("max(competency_niveau.level) as level");169 $levelQuery->addField("competency.name as cName");170 $levelQuery->addCondition("competency_profile_person.profile_id =" . $params["profile"]);171 $levelQuery->addCondition("competency_domain.id = " . $domain);172 $levelQuery->addGroupBy("person.id");173 $levelQuery->addGroupBy("competency_competences.competency_id");174 $levels = $db->getrows($levelQuery->buildSelect());175 $counts = array();176 foreach ($levels as $comp)177 {178 if (isset($counts[$comp["cName"]]))179 {180 $counts[$comp["cName"]] += isset($comp["level"]) ? $comp["level"] : 1;181 } else182 {183 $counts[$comp["cName"]] = isset($comp["level"]) ? $comp["level"] : 1;184 }185 }186 // then we select the competences we need187 $lQuery = &$db->createQuery();188 $lQuery->addTable("competency_profile_comp");189 $lQuery->addJoin("competency_niveau", "", "competency_niveau.id = competency_profile_comp.niveau_id", true);190 $lQuery->addJoin("competency", "", "competency_profile_comp.competency_id = competency.id", true);191 $lQuery->addJoin("competency_domain", "", "competency_domain.id = competency.domain_id", true);192 $lQuery->addField("max(level) as level");193 $lQuery->addField("competency_profile_comp.competency_id as competency");194 $lQuery->addField("competency.name as cName");195 $lQuery->addCondition("competency_profile_comp.profile_id =" . $params["profile"]);196 $lQuery->addCondition("competency_domain.id = " . $domain);197 $lQuery->addGroupBy("competency_profile_comp.competency_id");198 $leve = $db->getrows($lQuery->buildSelect());199 $coun = array();200 foreach ($leve as $com)201 {202 if (isset($coun[$com["cName"]]))203 {204 $coun[$com["cName"]] += isset($com["level"]) ? $com["level"] : 1;205 } else206 {207 $coun[$com["cName"]] = isset($com["level"]) ? $com["level"] : 1;208 }209 }210 $dataset = array();211 foreach ($coun as $itemKey => $item)212 {213 $percentage = (100 / ($item * $personsCount)) * $counts[$itemKey];214 $dataset[$itemKey] = $percentage;215 }216 if ($raw)217 {218 return array("profile" => $levels , "competences" => $leve);219 }220 return array("name" => "competency voids" , "data" => $dataset);221 }222 /**223 * Generates the data to creat the graph for competency growth224 * This function generate steh data for 1 person225 *226 * @param array $params need sto contain values for ["startdate"],["enddate"],["domain"] and ["person"]227 * @param boolean $raw228 * @return array229 */230 function graph_growth ($params, $raw = false)231 {232 $startdate = $params["startdate"];233 $enddate = $params["enddate"];234 $domain = $params["domain"];235 $person = $params["person"];236 $profileData = $this->_getProfile($person, $domain);237 $startLevels = $this->_getStartLevelsPerson($person, $domain, $startdate);238 $endLevels = $this->_getEndLevelsPerson($person, $domain, $enddate);239 $dataset = array();240 foreach ($profileData as $dataKey => $data)241 {242 foreach ($data as $itemKey => $item)243 {244 //first we calculate the should have then we look if its - number if this is the case we know that the245 //person had more competences then he needed so we make it positive and put it in has more then we make shoudlhave 0246 //and we lessen normal with tha shouldhave247 $normal = $startLevels[$dataKey][$itemKey];248 $shouldhave = $item - $startLevels[$dataKey][$itemKey];249 if ($shouldhave < 0)250 {251 $hasMore = abs($shouldhave);252 $normal += $shouldhave;253 $shouldhave = 0;254 } else255 {256 $hasMoreE = 0;257 }258 //first we calculate the should have then we look if its - number if this is the case we know that the259 //person had more competences then he needed so we make it positive and put it in has more then we make shoudlhave 0260 $normalE = $endLevels[$dataKey][$itemKey];261 $shouldhaveE = ($item - $endLevels[$dataKey][$itemKey]);262 if ($shouldhaveE < 0)263 {264 $hasMoreE = abs($shouldhaveE);265 $normalE += $shouldhaveE;266 $shouldhaveE = 0;267 } else268 {269 $hasMoreE = 0;270 }271 //we take the end date because this one will neve have less then begindate272 unset($startLevels[$dataKey][$itemKey]);273 unset($endLevels[$dataKey][$itemKey]);274 //before we send teh date we will format the dates so they are in dtuch format275 $tempStart = strtotime($startdate);276 $startdate = date("d-m-Y",$tempStart);277 $tempEnd = strtotime($enddate);278 $enddate = date("d-m-Y",$tempEnd);279 $dataset[$itemKey] = array($startdate => array("normal" => $normal , "shouldhave" => $shouldhave , "hasmore" => $hasMore) , $enddate => array("normal" => $normalE , "shouldhave" => $shouldhaveE , "hasmore" => $hasMoreE));280 }281 }282 // we add the competences that arent in a profile but the person acquired them anyway283 foreach($endLevels as $edDkey=>$edD)284 {285 foreach($edD as $edCkey=>$edC)286 {287 $hasMoreE = ($edC);288 $dataset[$edCkey] = array($startdate => array("normal" => 0 , "shouldhave" => 0 , "hasmore" => isset($startLevels[$edDkey][$edCkey])!=0?($startLevels[$edDkey][$edCkey]):0) , $enddate => array("normal" => 0 , "shouldhave" => 0 , "hasmore" => $hasMoreE));289 }290 }291 return $dataset;292 }293 /**294 * This function generates the data we need for the creation of the growth graph for domain and/or team295 *296 * @param array $params needs to contain values for ["startdate"],["enddate"],["domain"] and ["team"] if ["team"] is 0 the data wil be generated for teh whoel company else for teh given team297 * @param boolean $raw298 * @return array299 */300 function graph_growthTeam ($params, $raw = false)301 {302 $domain = $params["domain"];303 $team = isset($params["team"]) ? $params["team"] : 0;304 $startdate = $params["startdate"];305 $enddate = $params["enddate"];306 $profile = $params["profile"];307 $profiles = $this->_getProfiles($domain, $team,$profile);308 $startLevels = $this->_getLevelsByDate($domain, $startdate, $team,$profile);309 $endLevels = $this->_getLevelsByDate($domain, $enddate, $team,$profile);310 $dataset = array();311 foreach ($profiles as $dataKey => $data)312 {313 foreach ($data as $itemKey => $item)314 {315 //first we calculate the should have then we look if its - number if this is the case we know that the316 //person had more competences then he needed so we make it positive and put it in has more then we make shoudlhave 0317 //and we lessen normal with tha shouldhave318 //because we can have diffent peopel in as well the profile as the competences we merge the arrays with people in them319 //because we use p + users nr as key we eliminate all double people so we can have a distinct count of how many have the competency320 // plus how many should have to (even if they dont have it yet)321 $join = array_merge($startLevels[$dataKey][$itemKey]["persons"],$item["persons"]);322 $nrOfPersons = count($join);323 $normal = $startLevels[$dataKey][$itemKey]["mx"] / $nrOfPersons;324 $shouldhave = ($item["mx"] / $item["pCount"]) - ($startLevels[$dataKey][$itemKey]["mx"] / $nrOfPersons);325 if ($shouldhave < 0)326 {327 $hasMore = abs($shouldhave);328 $normal += $shouldhave;329 $shouldhave = 0;330 } else331 {332 $hasMore = 0;333 }334 //first we calculate the should have then we look if its - number if this is the case we know that the335 //person had more competences then he needed so we make it positive and put it in has more then we make shoudlhave 0336 $joinE = array_merge($endLevels[$dataKey][$itemKey]["persons"], $item["persons"]);337 $nrOfPersonsE = count($joinE);338 $normalE = $endLevels[$dataKey][$itemKey]["mx"] / $nrOfPersonsE;339 $shouldhaveE = ($item["mx"] / $item["pCount"]) - ($endLevels[$dataKey][$itemKey]["mx"] / $nrOfPersonsE);340 if ($shouldhaveE < 0)341 {342 $hasMoreE = abs($shouldhaveE);343 $normalE += $shouldhaveE;344 $shouldhaveE = 0;345 } else346 {347 $hasMoreE = 0;348 }349 unset($startLevels[$dataKey][$itemKey]);350 unset($endLevels[$dataKey][$itemKey]);351 //before we send the date we will format the dates so they are in dutch format352 $tempStart = strtotime($startdate);353 $startdate = date("d-m-Y",$tempStart);354 $tempEnd = strtotime($enddate);355 $enddate = date("d-m-Y",$tempEnd);356 $dataset[$itemKey] = array($startdate => array("normal" => $normal , "shouldhave" => $shouldhave , "hasmore" => $hasMore) , $enddate => array("normal" => $normalE , "shouldhave" => $shouldhaveE , "hasmore" => $hasMoreE));357 }358 }359 //we can have competences that are not in a profile we will add then now.360 //because they are not in a profile we know that its not required so the required level is 0361 //we take the end date because this one will never have less then begindate362 foreach($endLevels as $edDkey=>$edD)363 {364 foreach($edD as $edCkey=>$edC)365 {366 $hasmore = (isset($startLevels[$edDkey][$edCkey]["mx"])!=0?($startLevels[$edDkey][$edCkey]["mx"]):0)/count($startLevels[$edDkey][$edCkey]["persons"]);367 $hasMoreE = ($edC["mx"]/count($edC["persons"]));368 $dataset[$edCkey] = array($startdate => array("normal" => 0 , "shouldhave" => 0 , "hasmore" => $hasmore ), $enddate => array("normal" => 0 , "shouldhave" => 0 , "hasmore" => $hasMoreE));369 }370 }371 return $dataset;372 }373 /**374 * gets the profile of the person specified for the specified domain375 *376 * @param int $person id of the person we want the profile for377 * @param int $domain if of the domain we want the profile for378 * @return array379 */380 private function _getProfile ($person, $domain)381 {382 $db = &atkGetDb();383 $query = &$db->createQuery();384 $query->addTable("competency_profile_person");385 $query->addJoin("competency_profile_comp", "", "competency_profile_comp.profile_id = competency_profile_person.profile_id", true);386 $query->addJoin("competency", "", "competency.id = competency_profile_comp.competency_id", true);387 $query->addJoin("competency_niveau", "", "competency_profile_comp.niveau_id = competency_niveau.id", true);388 $query->addJoin("competency_domain", "", " competency.domain_id = competency_domain.id");389 $query->addField("max(level) as mx");390 $query->addField("competency_profile_comp.competency_id");391 $query->addField("competency_domain.name as dName");392 $query->addField("competency.name as cName");393 $query->addGroupBy("competency_profile_comp.competency_id");394 $query->addCondition("person_id=" . $person);395 $query->addCondition("competency_domain.id =" . $domain);396 $counts = $db->getrows($query->buildSelect());397 $dataset = array();398 foreach ($counts as $count)399 {400 $dataset[$count["dName"]][$count["cName"]] = $count["mx"] > 0 ? $count["mx"] : 1;401 }402 return $dataset;403 }404 /**405 * This function gets all the profiles of the people in a team (or a whole company)406 * or gets the data for the profile specified407 *408 * @param int $team when 0 it wont look for a team but for the whole company409 * @param int $domain id of the domain we want to search on410 */411 private function _getProfiles ($domain, $team = 0,$profile = 0)412 {413 $db = &atkGetDb();414 $query = &$db->createQuery();415 $query->addTable("competency_profile_person");416 $query->addJoin("competency_profile_comp", "", "competency_profile_comp.profile_id = competency_profile_person.profile_id", true);417 $query->addJoin("competency", "", "competency.id = competency_profile_comp.competency_id", true);418 $query->addJoin("competency_niveau", "", "competency_profile_comp.niveau_id = competency_niveau.id", true);419 $query->addJoin("competency_domain", "", " competency.domain_id = competency_domain.id");420 $query->addField("max(level) as mx");421 $query->addField("count(distinct(competency_profile_person.person_id)) as pCount");422 $query->addField("competency_profile_comp.competency_id");423 $query->addField("competency_domain.name as dName");424 $query->addField("competency.name as cName");425 $query->addField("competency_profile_person.person_id as person");426 $query->addGroupBy("competency_profile_comp.profile_id");427 $query->addGroupBy("competency_profile_comp.competency_id");428 $query->addGroupBy("person_id");429 if ($team != 0)430 {431 $query->addCondition("person_id=" . $team . " OR person_id IN (SELECT id from person WHERE supervisor =" . $team . ")");432 }433 if ($profile !=0)434 {435 $query->addCondition("competency_profile_comp.profile_id ="." $profile");436 }437 $query->addCondition("competency_domain.id =" . $domain);438 $counts = $db->getrows($query->buildSelect());439 $dataset = array();440 foreach ($counts as $count)441 {442 $dataset[$count["dName"]][$count["cName"]]["mx"] += $count["mx"] > 0 ? ($count["mx"] * $count["pCount"]) : $count["pCount"];443 $dataset[$count["dName"]][$count["cName"]]["pCount"] += $count["pCount"] > 0 ? $count["pCount"] : 1;444 $dataset[$count["dName"]][$count["cName"]]["persons"]["p" . $count["person"]] = $count["person"];445 }446 return $dataset;447 }448 private function _getStartLevelsPerson ($person, $domain, $startdate)449 {450 $db = &atkGetDb();451 $query = &$db->createQuery();452 $query->addTable("competency_competences");453 $query->addJoin("competency", "", "competency.id = competency_competences.competency_id", true);454 $query->addJoin("competency_niveau", "", "competency_competences.niveau_id = competency_niveau.id", true);455 $query->addJoin("competency_domain", "", " competency.domain_id = competency_domain.id", true);456 $query->addCondition("person_id=" . $person);457 $query->addField("max(level) as mx");458 $query->addField("competency_domain.name as dName");459 $query->addField("competency.name as cName");460 $query->addCondition("competency_domain.id =" . $domain);461 $query->addCondition("competency_competences.added <= '" . $startdate . "'");462 $query->addGroupBy("competency_competences.competency_id");463 $counts = $db->getrows($query->buildSelect());464 foreach ($counts as $count)465 {466 $dataset[$count["dName"]][$count["cName"]] = $count["mx"] > 0 ? $count["mx"] : 1;467 }468 return $dataset;469 }470 private function _getEndLevelsPerson ($person, $domain, $enddate)471 {472 $db = &atkGetDb();473 $query = &$db->createQuery();474 $query->addTable("competency_competences");475 $query->addJoin("competency", "", "competency.id = competency_competences.competency_id", true);476 $query->addJoin("competency_niveau", "", "competency_competences.niveau_id = competency_niveau.id", true);477 $query->addJoin("competency_domain", "", " competency.domain_id = competency_domain.id", true);478 $query->addCondition("person_id=" . $person);479 $query->addField("max(level) as mx");480 $query->addField("competency_domain.name as dName");481 $query->addField("competency.name as cName");482 $query->addCondition("competency_domain.id =" . $domain);483 $query->addCondition("competency_competences.added <= '" . $enddate . "'");484 $query->addGroupBy("competency_competences.competency_id");485 $counts = $db->getrows($query->buildSelect());486 foreach ($counts as $count)487 {488 $dataset[$count["dName"]][$count["cName"]] = $count["mx"] > 0 ? $count["mx"] : 1;489 }490 return $dataset;491 }492 private function _getLevelsByDate ($domain, $date, $team = 0,$profile =0)493 {494 $db = &atkGetDb();495 $query = &$db->createQuery();496 $query->addTable("competency_competences");497 $query->addJoin("competency", "", "competency.id = competency_competences.competency_id", true);498 $query->addJoin("competency_niveau", "", "competency_competences.niveau_id = competency_niveau.id", true);499 $query->addJoin("competency_domain", "", " competency.domain_id = competency_domain.id");500 $query->addField("max(level) as mx");501 $query->addField("count(distinct(competency_competences.person_id)) as pCount");502 $query->addField("competency_domain.name as dName");503 $query->addField("competency.name as cName");504 $query->addField("competency_competences.person_id as person");505 $query->addGroupBy("competency_competences.competency_id");506 $query->addGroupBY("competency_competences.person_id");507 $query->addCondition("added <= '" . $date . "'");508 if ($team != 0)509 {510 $query->addCondition("person_id=" . $team . " OR person_id IN (SELECT id from person WHERE supervisor =" . $team . ")");511 }512 if ($profile != 0)513 {514 $query->addCondition("person_id IN (SELECT person_id FROM competency_profile_person WHERE profile_id =".$profile . ")");515 }516 $query->addCondition("competency_domain.id =" . $domain);517 $counts = $db->getrows($query->buildSelect());518 $dataset = array();519 foreach ($counts as $count)520 {521 $dataset[$count["dName"]][$count["cName"]]["mx"] += $count["mx"] > 0 ? ($count["mx"] * $count["pCount"]) : $count["pCount"];522 $dataset[$count["dName"]][$count["cName"]]["pCount"] += $count["pCount"] > 0 ? $count["pCount"] : 1;523 $dataset[$count["dName"]][$count["cName"]]["persons"]["p" . $count["person"]] = $count["person"];524 }525 return $dataset;526 }527}528?>...

Full Screen

Full Screen

MethodProphecy.php

Source:MethodProphecy.php Github

copy

Full Screen

...210 * @return $this211 *212 * @throws \Prophecy\Exception\InvalidArgumentException213 */214 public function shouldHave($prediction)215 {216 if (is_callable($prediction)) {217 $prediction = new Prediction\CallbackPrediction($prediction);218 }219 if (!$prediction instanceof Prediction\PredictionInterface) {220 throw new InvalidArgumentException(sprintf(221 'Expected callable or instance of PredictionInterface, but got %s.',222 gettype($prediction)223 ));224 }225 if (null === $this->promise) {226 $this->willReturn();227 }228 $calls = $this->getObjectProphecy()->findProphecyMethodCalls(229 $this->getMethodName(),230 $this->getArgumentsWildcard()231 );232 try {233 $prediction->check($calls, $this->getObjectProphecy(), $this);234 $this->checkedPredictions[] = $prediction;235 } catch (\Exception $e) {236 $this->checkedPredictions[] = $prediction;237 throw $e;238 }239 return $this;240 }241 /**242 * Checks call prediction.243 *244 * @see Prophecy\Prediction\CallPrediction245 *246 * @return $this247 */248 public function shouldHaveBeenCalled()249 {250 return $this->shouldHave(new Prediction\CallPrediction);251 }252 /**253 * Checks no calls prediction.254 *255 * @see Prophecy\Prediction\NoCallsPrediction256 *257 * @return $this258 */259 public function shouldNotHaveBeenCalled()260 {261 return $this->shouldHave(new Prediction\NoCallsPrediction);262 }263 /**264 * Checks no calls prediction.265 *266 * @see Prophecy\Prediction\NoCallsPrediction267 * @deprecated268 *269 * @return $this270 */271 public function shouldNotBeenCalled()272 {273 return $this->shouldNotHaveBeenCalled();274 }275 /**276 * Checks call times prediction.277 *278 * @see Prophecy\Prediction\CallTimesPrediction279 *280 * @param int $count281 *282 * @return $this283 */284 public function shouldHaveBeenCalledTimes($count)285 {286 return $this->shouldHave(new Prediction\CallTimesPrediction($count));287 }288 /**289 * Checks currently registered [with should(...)] prediction.290 */291 public function checkPrediction()292 {293 if (null === $this->prediction) {294 return;295 }296 $this->shouldHave($this->prediction);297 }298 /**299 * Returns currently registered promise.300 *301 * @return null|Promise\PromiseInterface302 */303 public function getPromise()304 {305 return $this->promise;306 }307 /**308 * Returns currently registered prediction.309 *310 * @return null|Prediction\PredictionInterface...

Full Screen

Full Screen

shouldHave

Using AI Code Generation

copy

Full Screen

1$or = new or();2$or->shouldHave(2);3$or = new or();4$or->shouldHave(3);5$or = new or();6$or->shouldHave(4);7$or = new or();8$or->shouldHave(5);9$or = new or();10$or->shouldHave(6);11$or = new or();12$or->shouldHave(7);13$or = new or();14$or->shouldHave(8);15$or = new or();16$or->shouldHave(9);17$or = new or();18$or->shouldHave(10);19$or = new or();20$or->shouldHave(11);21$or = new or();22$or->shouldHave(12);23$or = new or();24$or->shouldHave(13);25$or = new or();26$or->shouldHave(14);27$or = new or();28$or->shouldHave(15);29$or = new or();30$or->shouldHave(16);31$or = new or();32$or->shouldHave(17);

Full Screen

Full Screen

shouldHave

Using AI Code Generation

copy

Full Screen

1$or = new or();2$or->shouldHave(2, '2.php');3$or = new or();4$or->shouldHave(3, '3.php');5$or = new or();6$or->shouldHave(4, '4.php');7$or = new or();8$or->shouldHave(5, '5.php');9$or = new or();10$or->shouldHave(6, '6.php');11$or = new or();12$or->shouldHave(7, '7.php');13$or = new or();14$or->shouldHave(8, '8.php');15$or = new or();16$or->shouldHave(9, '9.php');17$or = new or();18$or->shouldHave(10, '10.php');19$or = new or();20$or->shouldHave(11, '11.php');21$or = new or();22$or->shouldHave(12, '12.php');23$or = new or();24$or->shouldHave(13, '13.php');25$or = new or();26$or->shouldHave(14, '14.php');27$or = new or();28$or->shouldHave(15, '15.php');

Full Screen

Full Screen

shouldHave

Using AI Code Generation

copy

Full Screen

1$or = new or();2$or->shouldHave(2)->of(1,2,3);3$or = new or();4$or->shouldHave(1)->of(1,2,3);5$or = new or();6$or->shouldHave(1)->of(1,2,3);7$or = new or();8$or->shouldHave(1)->of(1,2,3);9$or = new or();10$or->shouldHave(1)->of(1,2,3);11$or = new or();12$or->shouldHave(1)->of(1,2,3);13$or = new or();14$or->shouldHave(1)->of(1,2,3);15$or = new or();16$or->shouldHave(1)->of(1,2,3);17$or = new or();18$or->shouldHave(1)->of(1,2,3);19$or = new or();20$or->shouldHave(1)->of(1,2,3);21$or = new or();22$or->shouldHave(1)->of(1,2,3);23$or = new or();24$or->shouldHave(1)->of(1,2,3);25$or = new or();26$or->shouldHave(1)->of(1,

Full Screen

Full Screen

shouldHave

Using AI Code Generation

copy

Full Screen

1$or = new OrCondition();2$or->shouldHave('name', 'John');3$or->shouldHave('name', 'Doe');4$or->shouldHave('name', 'Jane');5$or->shouldHave('name', 'Doe');6$or->shouldHave('name', 'John');7$or->shouldHave('name', 'Doe');8$or->shouldHave('name', 'Jane');9$or->shouldHave('name', 'Doe');10$or->shouldHave('name', 'John');11$or->shouldHave('name', 'Doe');12$or->shouldHave('name', 'Jane');13$or->shouldHave('name', 'Doe');14$or->shouldHave('name', 'John');15$or->shouldHave('name', 'Doe');16$or->shouldHave('name', 'Jane');17$or->shouldHave('name', 'Doe');18$or->shouldHave('name', 'John');19$or->shouldHave('name', 'Doe');20$or->shouldHave('name', 'Jane');21$or->shouldHave('name', 'Doe');22$or->shouldHave('name', 'John');23$or->shouldHave('name', 'Doe');24$or->shouldHave('name', 'Jane');25$or->shouldHave('name', 'Doe');26$or->shouldHave('name', 'John');27$or->shouldHave('name', 'Doe');28$or->shouldHave('name', 'Jane');29$or->shouldHave('name', 'Doe');30$or->shouldHave('name', 'John');31$or->shouldHave('name', 'Doe');32$or->shouldHave('name', 'Jane');33$or->shouldHave('name', 'Doe');34$or->shouldHave('name', 'John');35$or->shouldHave('name', 'Doe');36$or->shouldHave('name', 'Jane');37$or->shouldHave('name', 'Doe');38$or->shouldHave('name', 'John');39$or->shouldHave('name', 'Doe');40$or->shouldHave('name', 'Jane');41$or->shouldHave('name', 'Doe');42$or->shouldHave('name', 'John');43$or->shouldHave('name', 'Doe');44$or->shouldHave('name',

Full Screen

Full Screen

shouldHave

Using AI Code Generation

copy

Full Screen

1$or = new or();2$or->shouldHave($this->stringStartsWith('foo'));3$or->shouldHave($this->stringEndsWith('bar'));4$or->shouldHave($this->stringContains('baz'));5$or->shouldHave($this->stringContains('qux'));6$or->shouldHave($this->stringContains('quux'));7$or->shouldHave($this->stringContains('quuz'));8$or->shouldHave($this->stringContains('corge'));9$or->shouldHave($this->stringContains('grault'));10$or->shouldHave($this->stringContains('garply'));11$or->shouldHave($this->stringContains('waldo'));12$or->shouldHave($this->stringContains('fred'));13$or->shouldHave($this->stringContains('plugh'));14$or->shouldHave($this->stringContains('xyzzy'));

Full Screen

Full Screen

shouldHave

Using AI Code Generation

copy

Full Screen

1$or = new Or();2$or->shouldHave(2);3{4 public function shouldHave($value)5 {6 echo $value;7 }8}9{10 public function shouldHave($value)11 {12 echo $value;13 }14}15{16 public function shouldHave($value)17 {18 echo $value;19 }20}21{22 public function shouldHave($value)23 {24 echo $value;25 }26}27{28 public function shouldHave($value)29 {30 echo $value;31 }32}33{34 public function shouldHave($value)35 {36 echo $value;37 }38}39{40 public function shouldHave($value)41 {42 echo $value;43 }44}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Prophecy automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Trigger shouldHave code on LambdaTest Cloud Grid

Execute automation tests with shouldHave on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful