public function testAssertElementHasNotText() { S::get("/"); $this->assertElementHasNotText("h1", "asdasdasdasd"); }
public function testFormSubmit() { S::get("/"); S::click(".form-submit"); $this->assertBodyHasText("You have arrived"); }
$this->_data['data'] = $value; } } // Initialize S class $app = new S(); $app->_initData(); // Assigned database connection // created at step #3 $app->conn = $database; /* STEP 5: SET CONTENT TYPE AS JSON */ header("Content-Type: application/json; charset=utf-8"); /* STEP 7: Allow access to API */ header("Access-Control-Allow-Origin: *"); $app->get('/test-json', function () use($app) { $variable = [1, 2, 3, 4, 4, 5, $app]; // STEP: 6 Use json_encode() output as JSON format echo json_encode($variable); }); $app->get('/user/:name', function ($name) use($app) { // $user = $app->conn->GetRow('select * from users where id = ?',[$id]); // $app->output($user); $sql = 'select * from users where name like '; $user = $app->conn->GetAll($sql, ['%' . $name . '%']); if ($user) { $app->message(count($user) . ' record(s) found.'); $app->data($user); } else { $app->message('No record found', true); } $app->output(); # Updating tables
<?php require 'Slim/Slim.php'; require 'app/libs/S.php'; \Slim\Slim::registerAutoloader(); $app = new S(); $app->hook('slim.before', function () use($app) { $app->response->header("Content-Type", "application/json; charset=utf-8"); }); $app->hook('slim.after', function () use($app) { $app->output(); }); $app->get('/', function () use($app) { $app->contents['messages'] = 'Welcome to S Web Services. Please provide application token to use the API.'; }); $app->run();