How to use testEnd method of token class

Best Atoum code snippet using token.testEnd

index.php

Source:index.php Github

copy

Full Screen

1<?php2/**3 * Escribe en un fichero cuando se retorno de la pagina de actividad4 * tu --> Token de usuario5 * ia --> Id de actividad6 * cf --> Codigo de retorno de OK7 */8include "../test/test_ionic/www/php/loggin_basedatos.php";9include "../test/test_ionic/www/php/funcion.php";10// Compruebo que viene desde betaciticens11//if (isset($_SERVER['HTTP_REFERER'])) {12 // Compruebo que los parametros existen13 if (isset($_GET["tu"]) && isset($_GET["ia"]) && isset($_GET["cf"])) {14 $conn = conectar();15 $token_url = strip_tags($_GET["tu"]);16 $url_ref = strip_tags($_GET["ia"]);17 $cod = strip_tags($_GET["cf"]);18 $usuario = comprobarUsuarioTokenUrl($conn, $token_url);19 if ($usuario["error"] == false) {20 $realizada = comprueba_realizada($conn, $usuario["id_usuairo"], $url_ref);21 if ($realizada == true) {22 $respuesta = almacenar_datos_sql($conn, $usuario["id_usuairo"], $url_ref, $cod);23 if ($respuesta == true) {24 $puntos = obtener_sumar_puntos($conn, $usuario["id_usuairo"], $url_ref);25 // Sumo los puntos al que invito al usuario26 $puntos_remitente = obtener_sumar_puntos_remitente($conn, $usuario["id_usuairo"], $url_ref);27 header("Location: ../?page=btz_realizadas");28 }29 else {30 error_log_func("ER-04");31 }32 }33 else {34 // Ha realizado la tarea, no sumo nada y no apunto nada.35 header("Location: ../?page=btz_realizadas");36 }37 }38 else {39 error_log_func("ER-02");40 }41 }42 else {43 error_log_func("ER-01");44 }45//}46//else {47// echo "No";48 //gohome();49//}50/**51 * Obtengo los puntos de la prueba saco el porcentaje para el remitente y se los sumo52 * @param $conn53 * @param $id_usuario54 * @param $url_ref55 */56function obtener_sumar_puntos_remitente($conn, $id_usuario, $url_ref) {57 $return = array();58 // Busco si este usuario ha sido recomendado59 $select_remitente = $conn->prepare("SELECT * FROM btz_invitaciones WHERE id_invitado = :id_invitado");60 if ($select_remitente->execute(array(":id_invitado" => $id_usuario))) {61 $select_remitente = $select_remitente->fetchAll();62 $id_remitente = $select_remitente[0]["id_remitente"];63 $select_puntos = $conn->prepare("SELECT soustitre FROM spip_articles WHERE id_article = :id_article");64 if ($select_puntos->execute(array(":id_article" => $url_ref))) {65 $select_puntos = $select_puntos->fetchAll();66 // Obtengo los puntos del articulo67 $puntos_articulo = $select_puntos[0]["soustitre"];68 // 20% para el remitente69 $puntos_a_remitente = intval($puntos_articulo * 20 / 100);70 // Seleciono los puntos del remitente71 $select_puntos_actuales = obtener_datos_usuario($conn, $id_remitente);72 // Sumos los puntos73 $puntos_remitente = $select_puntos_actuales["datos"][0]["puntos"] + $puntos_a_remitente;74 // Inserto los puntos en la base de datos75 $insert = $conn->prepare("UPDATE registroreto SET puntos = :puntos WHERE id_usuario = :id_usuario");76 if ($insert->execute(array(":puntos" => $puntos_remitente, ":id_usuario" => $id_remitente))) {77 return true;78 }79 }80 else {81 return false;82 }83 }84 else {85 return false;86 }87}88/**89 * Obtengo los puntos y se los añado al usuario90 * @param $conn91 * @param $token_url92 * @param $url_ref93 */94function obtener_sumar_puntos($conn, $id_usuario, $url_ref) {95 $return = array();96 $select_puntos = $conn->prepare("SELECT soustitre FROM spip_articles WHERE id_article = :id_article");97 if ($select_puntos->execute(array(":id_article" => $url_ref))) {98 $select_puntos = $select_puntos->fetchAll();99 // Obtengo los puntos del articulo100 $puntos_articulo = $select_puntos[0]["soustitre"];101 // Obtengo los datos del usuario102 $select_puntos_actuales = obtener_datos_usuario($conn, $id_usuario);103 // Obtengo los puntos del usuario104 $puntos_usuario = $select_puntos_actuales["datos"][0]["puntos"];105 // Sumo ambos106 $puntos_totales = $puntos_articulo + $puntos_usuario;107 // Inserto los puntos en la tabla108 $insert = $conn->prepare("UPDATE registroreto SET puntos = :puntos WHERE id_usuario = :id_usuario");109 if ($insert->execute(array(":puntos" => $puntos_totales, ":id_usuario" => $id_usuario))) {110 return true;111 }112 else {113 return false;114 }115 }116 else {117 return false;118 }119}120/**121 * COmprueba si ya ha realizado esta tarea122 * @param $conn123 * @param $id_usuario124 * @param $url_ref125 * @return bool126 * false => Ya ha realizado la tarea127 * true => No la ha realizado128 *129 */130function comprueba_realizada($conn, $id_usuario, $url_ref) {131 $retun = array();132 $select = $conn->prepare("SELECT * FROM btz_testend WHERE id_usuario = :id_usuario and id_actividad = :id_actividad");133 if ($select->execute(array(":id_usuario" => $id_usuario, ":id_actividad" => $url_ref))) {134 if ($select->rowCount() > 0) {135 return false;136 }137 else {138 return true;139 }140 }141 else {142 return false;143 }144}145/**146 * Almacena los datos147 * @param $token_url148 * @param $url_ref149 * @param $cod150 */151function almacenar_datos($conn, $token_url, $url_ref, $cod) {152 // Nombre del fichero153 $fichero = 'btz-testend.txt';154 // Escribe el contenido del fichero155 if (isset($_SERVER['HTTP_REFERER'])) {156 $donde = $_SERVER['HTTP_REFERER'];157 }158 else {159 $donde = "null";160 }161 $contenido = "|BTZ-testend";162 $contenido .= "|" . date("Y-m-d H:i:s") . "";163 $contenido .= "|" . $_SERVER['REMOTE_ADDR'] . "";164 $contenido .= "|" . $donde . "";165 $contenido .= "|" . $token_url . "";166 $contenido .= "|" . $url_ref . "";167 $contenido .= "|" . $cod . "|";168 // Escribe el contenido al fichero169 $ok = file_put_contents($fichero, $contenido . "\n", FILE_APPEND | LOCK_EX);170 // Retorno lo que pasa171 return $ok;172}173/**174 * Almaceno los datos recibidos en el servidor175 * @param $conn176 * @param $token_url177 * @param $url_ref178 * @param $cod179 */180function almacenar_datos_sql($conn, $id_usuario, $url_ref, $cod) {181 if (isset($_SERVER['HTTP_REFERER'])) {182 $donde = $_SERVER['HTTP_REFERER'];183 }184 else {185 $donde = "null";186 }187 $values = array(188 ":fecha" => date("Y-m-d H:i:s"),189 ":ip" => $_SERVER['REMOTE_ADDR'],190 ":donde" => $donde,191 ":id_usuario" => $id_usuario,192 ":id_actividad" => $url_ref,193 ":codigo" => $cod,194 );195 $insert = $conn->prepare("INSERT into btz_testend (fecha, ip, donde, id_usuario, id_actividad, codigo) VALUES (:fecha, :ip, :donde, :id_usuario, :id_actividad, :codigo)");196 if ($insert->execute($values)) {197 if ($insert->rowCount()>0) {198 return true;199 }200 else {201 return false;202 }203 }204 else {205 return false;206 }207}208/**209 *210 */211function error_log_func($error) {212 $fichero = 'btz-error.txt';213 $contenido = "BTZ-testend|";214 $contenido .= $error;215 $contenido .= "|" . date("Y-m-d H:i:s") . "";216 $contenido .= "|" . $_SERVER['REMOTE_ADDR'] . "";217 $result = file_put_contents($fichero, $contenido . "\n", FILE_APPEND | LOCK_EX);218 echo $error;219 die();220}...

Full Screen

Full Screen

SessionTest.php

Source:SessionTest.php Github

copy

Full Screen

...34 /**35 * @group fast36 * @depends testGetSet37 */38 public function testEnd() {39 Session::set('test', 'value');40 Session::end();41 $this->assertSame('value', Session::get('test'));42 }43 /**44 * @group fast45 * @depends testGetSet46 */47 public function testCSRF() {48 $this->assertNotNull($token = Session::get('CSRF'), 'Should always have a CSRF token');49 Session::end();50 $this->assertEquals($token, Session::get('CSRF'),51 'Restarting session should maintain the token.');52 try {53 Session::set('CSRF', 2);54 $this->fail('Should not be able to override CSRF value');55 } catch(\InvalidArgumentException $e) {56 }57 }58 /**59 * @group fast60 * @depends testEnd61 */62 public function testRemove() {63 Session::set('test', 'value');64 Session::set('o', 'b');65 Session::end();66 $this->assertSame('value', Session::get('test'));67 $this->assertSame('b', Session::get('o'));68 Session::clear('o');69 Session::clear('test');70 Session::end();71 $this->assertFalse(Session::exists('test'));72 $this->assertFalse(Session::exists('o'));73 }74 /**...

Full Screen

Full Screen

index_2.php

Source:index_2.php Github

copy

Full Screen

1<?2// Compruebo que viene desde betaciticens3//if (isset($_SERVER['HTTP_REFERER'])) {4 // Compruebo que los parametros existen5 if (isset($_GET["tu"]) && isset($_GET["ia"]) && isset($_GET["cf"])) {6 $token_url = strip_tags($_GET["tu"]);7 $url_ref = strip_tags($_GET["ia"]);8 $cod = strip_tags($_GET["cf"]);9 $respuesta = almacenar_datos($token_url, $url_ref, $cod);10 if ($respuesta == true) {11 echo "Ok";12 }13 else {14 error_log_func("ER-02");15 }16 }17 else {18 error_log_func("ER-01");19 }20//}21//else {22// echo "No";23 //gohome();24//}25/**26 * Almacena los datos27 * @param $token_url28 * @param $url_ref29 * @param $cod30 */31function almacenar_datos($token_url, $url_ref, $cod) {32 // Nombre del fichero33 $fichero = 'btz-testend.txt';34 // Escribe el contenido del fichero35 if (isset($_SERVER['HTTP_REFERER'])) {36 $donde = $_SERVER['HTTP_REFERER'];37 }38 else {39 $donde = "null";40 }41 $contenido = "|BTZ-testend";42 $contenido .= "|" . date("Y-m-d H:i:s") . "";43 $contenido .= "|" . $_SERVER['REMOTE_ADDR'] . "";44 $contenido .= "|" . $donde . "";45 $contenido .= "|" . $token_url . "";46 $contenido .= "|" . $url_ref . "";47 $contenido .= "|" . $cod . "|";48 // Escribe el contenido al fichero49 $ok = file_put_contents($fichero, $contenido . "\n", FILE_APPEND | LOCK_EX);50 // Retorno lo que pasa51 return $ok;52}53/**54 * LLeva a testdeprivivacidad55 */56function gohome() {57 header("Location: http://testdeprivacidad.com?page=betatester");58 die();59}60/**61 *62 */63function error_log_func($error) {64 $fichero = 'btz-error.txt';65 $contenido = "BTZ-testend|";66 $contenido .= $error;67 $contenido .= "|" . date("Y-m-d H:i:s") . "";68 $contenido .= "|" . $_SERVER['REMOTE_ADDR'] . "";69 file_put_contents($fichero, $contenido . "\n", FILE_APPEND | LOCK_EX);70 die();71}...

Full Screen

Full Screen

testEnd

Using AI Code Generation

copy

Full Screen

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

Full Screen

Full Screen

testEnd

Using AI Code Generation

copy

Full Screen

1require_once 'Token.php';2$token = new Token();3$token->testEnd();4require_once 'Token.php';5$token = new Token();6$token->testEnd();7require_once 'Token.php';8$token = new Token();9$token->testEnd();10require_once 'Token.php';11$token = new Token();12$token->testEnd();

Full Screen

Full Screen

testEnd

Using AI Code Generation

copy

Full Screen

1$token = new Token();2$token->testEnd();3$token = new Token();4$token->testEnd();5$token = new Token();6$token->testEnd();7$token = new Token();8$token->testEnd();9$token = new Token();10$token->testEnd();11$token = new Token();12$token->testEnd();13$token = new Token();14$token->testEnd();15$token = new Token();16$token->testEnd();17$token = new Token();18$token->testEnd();19$token = new Token();20$token->testEnd();21$token = new Token();22$token->testEnd();23$token = new Token();

Full Screen

Full Screen

testEnd

Using AI Code Generation

copy

Full Screen

1require_once('token.php');2$token = new Token();3if($token->testEnd()){4 echo "Token is valid";5}else{6 echo "Token is invalid";7}8require_once('token.php');9$token = new Token();10if($token->testEnd()){11 echo "Token is valid";12}else{13 echo "Token is invalid";14}15require_once('token.php');16$token = new Token();17if($token->testEnd()){18 echo "Token is valid";19}else{20 echo "Token is invalid";21}22require_once('token.php');23$token = new Token();24if($token->testEnd()){25 echo "Token is valid";26}else{27 echo "Token is invalid";28}29require_once('token.php');30$token = new Token();31if($token->testEnd()){32 echo "Token is valid";33}else{34 echo "Token is invalid";35}36require_once('token.php');37$token = new Token();38if($token->testEnd()){39 echo "Token is valid";40}else{41 echo "Token is invalid";42}43require_once('token.php');44$token = new Token();45if($token->testEnd()){46 echo "Token is valid";47}else{48 echo "Token is invalid";49}50require_once('token.php');51$token = new Token();52if($token->testEnd()){53 echo "Token is valid";54}else{55 echo "Token is invalid";56}57require_once('token.php');58$token = new Token();59if($token->testEnd()){60 echo "Token is valid";61}else{62 echo "Token is invalid";63}64require_once('token.php');65$token = new Token();

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 Atoum automation tests on LambdaTest cloud grid

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

Trigger testEnd code on LambdaTest Cloud Grid

Execute automation tests with testEnd 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