public function testOverwriteStateDefault() { $colorSet = ['text' => '#000000', 'color' => '#444444', 'style' => 'solid', 'altColor' => '#999999']; $stylist = new Stylist(75, 'Courier', []); $stylist->setStyles(['state' => $colorSet]); $expected = new Style('#000000', '#444444', 'solid', '#999999'); $this->assertEquals($expected, $stylist->getStyle('state', 'stateName', 'eventName')); }
function test_save() { //Arrange $stylist_name = "Work stuff"; $test_Stylist = new Stylist($name); $test_Stylist->save(); //Act $result = Stylist::getAll(); //Assert $this->assertEquals($test_Stylist, $result[0]); }
function testSave() { $stylist_name = "Kevin"; $test_stylist = new Stylist($stylist_name); $test_stylist->save(); $name = "Stuart"; $phone = "555-555-5555"; $stylist_id = $test_stylist->getId(); $test_client = new Client($name, $phone, $stylist_id); $test_client->save(); $result = Client::getAll(); $this->assertEquals($test_client, $result[0]); }
function testDeleteAll() { //Arrange $name = "Michael"; $id = null; $test_stylist = new Stylist($name, $id); $test_stylist->save(); $name2 = "John"; $id2 = null; $test_stylist2 = new Stylist($name2, $id2); $test_stylist2->save(); //Act Stylist::deleteAll(); //Assert $result = Stylist::getAll(); $this->assertEquals([], $result); }
static function find($search_id) { $found_stylist = null; $all_stylists = Stylist::getAll(); foreach ($all_stylists as $stylist) { if ($stylist->getId() == $search_id) { $found_stylist = $stylist; } } return $found_stylist; }
/** * Generate a URL to an application asset. * * @param string $path * @param bool|null $secure * @return string */ public function asset($path, $secure = null) { if ($this->isValidUrl($path)) { return $path; } // Once we get the root URL, we will check to see if it contains an index.php // file in the paths. If it does, we will remove it since it is not needed // for asset paths, but only for routes to endpoints in the application. $root = $this->getRootUrl($this->getScheme($secure)); $theme = Stylist::current(); return $this->removeIndex($root) . '/themes/' . $theme->getPath() . '/' . trim($path, '/'); }
static function find($search_id) { $found_stylist = null; $stylists = Stylist::getAll(); foreach ($stylists as $stylist) { $stylist_id = $stylist->getId(); if ($stylist_id == $search_id) { $found_stylist = $stylist; } //end of if } //end of foreach return $found_stylist; }
$stylist = Stylist::find($id); $stylist->update($name); return $app['twig']->render('stylist_edit.html.twig', array('stylist' => $stylist, 'clients' => $stylist->getClients())); }); $app->patch("/clients/{id}/edit", function ($id) use($app) { $name = preg_quote($_POST['client_name'], "'"); $client = Client::find($id); // echo "Name: " . $name . " Id: " . $id . " "; // var_dump($client); $client->update($name); return $app['twig']->render('client_edit.html.twig', array('client' => Client::find($id))); }); $app->delete("/stylists/{id}", function ($id) use($app) { $stylist = Stylist::find($id); $stylist->delete(); return $app['twig']->render('index.html.twig', array('stylists' => Stylist::getAll())); }); $app->get("/stylists/{id}/edit", function ($id) use($app) { $stylist = Stylist::find($id); return $app['twig']->render('stylist_edit.html.twig', array('stylist' => $stylist)); }); $app->post("/delete_stylists", function () use($app) { Stylist::deleteAll(); return $app['twig']->render('delete_stylists.html.twig'); }); $app->post("/delete_clients", function () use($app) { // echo "ID is: " . $id . " "; Client::deleteAll(); return $app['twig']->render('delete_clients.html.twig'); }); return $app;
}); //Stylist Post Calls $app->post("/stylists", function () use($app) { $stylist = new Stylist($_POST['stylist_name']); $stylist->save(); return $app['twig']->render('index.html.twig', array('stylists' => Stylist::getAll())); }); //Delete Calls //Client Delete Call $app->post("/delete_clients", function () use($app) { Client::deleteAll(); return $app['twig']->render('delete_clients.html.twig'); }); //Stylist Delete All Call $app->post("/delete_stylists", function () use($app) { Stylist::deleteAll(); return $app['twig']->render('delete_stylists.html.twig'); }); //Stylist Delete Single Call $app->delete("/stylists/{id}", function ($id) use($app) { $stylist = Stylist::find($id); $stylist->delete(); return $app['twig']->render('index.html.twig', array('stylists' => Stylist::getAll())); }); //Client delete single call $app->delete("/clients/{id}", function ($id) use($app) { $client = Client::find($id); $client->delete(); return $app['twig']->render('index.html.twig', array('stylists' => Stylist::getAll())); }); return $app;
function test_delete() { //arrange $stylist_name = "Nora"; $id = null; $test_stylist = new Stylist($stylist_name, $id); $test_stylist->save(); $stylist_name2 = "Andrea"; $test_stylist2 = new Stylist($stylist_name2, $id); $test_stylist2->save(); //act $test_stylist->delete(); //assert $this->assertEquals([$test_stylist2], Stylist::getAll()); }
$client->save(); $stylist = Stylist::find($stylist_id); return $app['twig']->render('stylist.html.twig', array('stylist' => $stylist, 'client' => $stylist->getClient())); }); $app->post("/stylists", function () use($app) { $stylist = new Stylist($_POST['name']); $stylist->save(); return $app['twig']->render('index.html.twig', array('stylists' => Stylist::getAll())); }); $app->post("/delete_stylists", function () use($app) { //Clients::deleteAll(); Stylist::deleteAll(); return $app['twig']->render('index.html.twig', array('stylists' => Stylist::getAll())); }); $app->post("/delete_client", function () use($app) { $category_id = $_POST['stylist_id']; Client::delete($stylist_id); return $app['twig']->render('index.html.twig', array('stylists' => Stylist::getAll())); }); $app->get("/all_clients", function () use($app) { return $app['twig']->render('all_clients.html.twig', array('clients' => Client::getAll(), 'stylists' => Stylist::getAll())); }); $app->post("/client", function () use($app) { $name = $_POST['name']; $stylist_id = $_POST['stylist_id']; $client = new Client($name, $stylist_id); $client->save(); $stylist = Stylist::find($stylist_id); return $app['twig']->render('stylist.html.twig', array('stylist' => $stylist, 'clients' => Client::getAll())); }); return $app;
$username = '******'; $password = '******'; $DB = new PDO($server, $username, $password); $app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views')); use Symfony\Component\HttpFoundation\Request; Request::enableHttpMethodParameterOverride(); ////// //////// Landing Page ////// //////Route to landing page. Uses twig to render array of stylists. $app->get("/", function () use($app) { return $app['twig']->render('index.html.twig', array('stylists' => Stylist::getAll())); }); //////adds stylists to the list of stylists. renders them on a list on the same landing page. $app->post("/stylists", function () use($app) { $stylist_name = new Stylist($_POST['stylist_name']); $stylist_name->save(); return $app['twig']->render('index.html.twig', array('stylist_names' => Stylist::getAll())); }); //////clears the whole list of stylists on the landing page. $app->post("/delete_stylists", function () use($app) { Stylist::deleteAll(); return $app['twig']->render('index.html.twig', array('stylist_names' => Stylist::getAll())); }); // //When the user submits a client name: // $app->post("/clients", function() use ($app){ // $client = $_POST['client']; // $stylist_id = $_POST['stylist_id']; // // //Creates a new Client object with the above mentioned client, and stylist_id. Sets the client id to null because it is assigned by the database // $client = new Client($_POST['client'], $id = null, $stylist_id);
$app->post("/stylists/{id}", function ($id) use($app) { Client::deleteAll(); $stylist = Stylist::find($id); return $app['twig']->render('stylist.html.twig', array('stylist' => $stylist, 'clients' => $stylist->getClients())); }); $app->patch("/stylists/{id}", function ($id) use($app) { $name = $_POST['name']; $phone = $_POST['phone']; $stylist = Stylist::find($id); $stylist->update($name, $phone); return $app['twig']->render('stylist.html.twig', array('stylist' => $stylist, 'clients' => $stylist->getClients())); }); $app->delete("/stylists/{id}", function ($id) use($app) { $stylist = Stylist::find($id); $stylist->delete(); return $app['twig']->render('stylist_deleted.html.twig', array('stylists' => Stylist::getAll())); }); $app->patch("/clients/{id}", function ($id) use($app) { $name = $_POST['name']; $phone = $_POST['phone']; $client = Client::find($id); $stylist = Stylist::find($id); $client->update($name, $phone); return $app['twig']->render('client_edit.html.twig', array('client' => $client, 'stylist' => $stylist)); }); $app->delete("/clients/{id}", function ($id) use($app) { $client = Client::find($id); $client->delete(); return $app['twig']->render('client_deleted.html.twig', array('stylists' => Stylist::getAll())); }); return $app;
$stylist->delete(); return $app['twig']->render('index.html.twig', array('stylists' => Stylist::getAll())); }); //allows the user to find a client's id $app->get("/clients/{id}", function ($id) use($app) { $client = Client::find($id); return $app['twig']->render('client.html.twig', array('client' => $client)); }); $app->get("/clients/{id}/edit", function ($id) use($app) { $client = Client::find($id); return $app['twig']->render('client.html.twig', array('client' => $client)); }); //Allows the user to update the client $app->patch("/clients/{id}", function ($id) use($app) { $client_name = $_POST['client_name']; $client = Client::find($id); $stylist = Stylist::find($id); $client->update($client_name); return $app['twig']->render('client.html.twig', array('client' => $client)); }); //Allows a user to delete a client //Getting error: Impossible to access attribute getStylistName //on null variable in stylist.html.twig at 8. $app->delete("/clients/{id}", function ($id) use($app) { $client = Client::find($id); $stylist = Stylist::find($client->getStylistId()); $client->delete(); $clients = Client::getAll(); return $app['twig']->render('stylist.html.twig', array('stylist' => $stylist, 'clients' => $clients)); }); return $app;
function test_deleteAll() { $name = "Megan"; $id = null; $test_stylist = new Stylist($name, $id); $test_stylist->save(); $client_name = "Shawnee"; $stylist_id = $test_stylist->getId(); $test_client = new Client($id, $client_name, $stylist_id); $test_client->save(); $client_name2 = "Katie"; $stylist_id = $test_stylist->getId(); $test_client2 = new Client($id, $client_name, $stylist_id); $test_client2->save(); Client::deleteAll(); $result = Client::getAll(); $this->assertEquals([], $result); }
protected function tearDown() { Stylist::deleteAll(); Client::deleteAll(); }
function testFind() { //Arrange $stylist_name = "Gandalf the Gray"; $test_stylist = new Stylist($stylist_name, $id = null); $test_stylist->save(); $client_name = "Samwise"; $stylist_id = $test_stylist->getId(); $test_client = new Client($client_name, $id = null, $stylist_id); $test_client->save(); $client_name2 = "Arwen"; $test_client2 = new Client($client_name2, $id = null, $stylist_id); $test_client2->save(); //Act $result = Client::find($test_client->getId()); //Assert $this->assertEquals($test_client, $result); }
function test_find() { //Arrange $name = "Tessa"; $id = null; $visits = 4; $description = "The best!"; $test_stylist = new Stylist($name, $id); $test_stylist->save(); $name = "jack"; $name2 = "Bob"; $stylist_id = $test_stylist->getId(); $test_client = new Client($name, $stylist_id, $id, $visits, $description); $test_client->save(); $test_client2 = new Client($name, $stylist_id, $id, $visits, $description); $test_client2->save(); //Act $result = Client::find($test_client->getId()); //Assert $this->assertEquals($test_client, $result); }
function test_find() { //Arrange $name = "Stylist1"; $id = null; $test_stylist = new Stylist($name, $id); $test_stylist->save(); $name = "Client1"; $stylist_id = $test_stylist->getId(); $test_client = new Client($name, $id, $stylist_id); $test_client->save(); $name = "Client2"; $test_client2 = new Client($name, $id, $stylist_id); $test_client2->save(); //Act $result = Client::find($test_client->getId()); //Assert $this->assertEquals($test_client, $result); }
function test_delete() { //Arrange $name = "Erin"; $id = null; $test_stylist = new Stylist($name, $id); $test_stylist->save(); $name = "George"; $stylist_id = $test_stylist->getId(); $test_client = new Client($name, $stylist_id, $id); $test_client->save(); $name2 = "Judy"; $test_client2 = new Client($name2, $stylist_id, $id); $test_client2->save(); //Act $test_client2->delete(); //Assert $this->assertEquals([$test_client], Client::getAll()); }
function test_delete() { //Arrange $stylist_name = "bob"; $id = null; $test_stylist = new Stylist($stylist_name, $id); $test_stylist->save(); $client_name = "joe"; $stylist_id = $test_stylist->getId(); $test_client = new Client($client_name, $id, $stylist_id); $test_client->save(); $client_name2 = "jerry"; $test_client2 = new Client($client_name2, $id, $stylist_id); $test_client2->save(); //Act $test_client->delete(); //Assert $this->assertEquals([$test_client2], Client::getAll()); }
function testGetClients() { //Arrange $name = "Jackie"; $id = null; $test_stylist = new Stylist($name, $id); $test_stylist->save(); $test_stylist_id = $test_stylist->getId(); $name = "Sandra Jane"; $phone = "542-334-0984"; $style_choice = "The Rachel"; $test_client = new Client($name, $phone, $style_choice, $test_stylist_id); $test_client->save(); $name2 = "Jordy Duran"; $phone2 = "239-094-0281"; $style_choice2 = "Bowl Cut"; $test_client2 = new Client($name2, $phone2, $style_choice2, $test_stylist_id); $test_client2->save(); //Act $result = $test_stylist->getClients(); //Assert $this->assertEquals([$test_client, $test_client2], $result); }
function testGetClients() { //Arrange $name = "Bob"; $id = null; $test_stylist = new Stylist($name, $id); $test_stylist->save(); $test_stylist_id = $test_stylist->getId(); $client_name = "Betty"; $test_client = new Client($client_name, $test_stylist_id, $id); $test_client->save(); $client_name2 = "Gertrude"; $test_client2 = new Client($client_name2, $test_stylist_id, $id); $test_client2->save(); //Act $result = $test_stylist->getClients(); //Assert $this->assertEquals([$test_client, $test_client2], $result); }
function test_getClients() { //Arrange $name = "Sasha"; $id = null; $test_stylist = new Stylist($name, $id); $test_stylist->save(); $name2 = "Sandra"; $test_stylist2 = new Stylist($name2, $id); $test_stylist2->save(); $c_name = "Garry Gergich"; $phone = "503-472-8959"; $stylist_id = $test_stylist->getId(); $test_client = new Client($c_name, $phone, $id, $stylist_id); $test_client->save(); $c_name2 = "Jerry Gergich"; $phone2 = "503-864-4444"; $stylist_id2 = $test_stylist2->getId(); $test_client2 = new Client($c_name2, $phone2, $id, $stylist_id2); $test_client2->save(); $c_name3 = "Brock Samson"; $phone3 = "555-555-5555"; $stylist_id3 = $test_stylist->getId(); $test_client3 = new Client($c_name3, $phone3, $id, $stylist_id3); $test_client3->save(); //Act $result = $test_stylist->getClients(); //Assert $this->assertEquals([$test_client3, $test_client], $result); }
function test_getClients() { $stylist_name = "Hank Airpair"; $id = null; $test_stylist = new Stylist($stylist_name, $id); $test_stylist->save(); $client_name = "Wesley Pong"; $stylist_id = $test_stylist->getId(); $email = "*****@*****.**"; $test_client = new Client($client_name, $id, $email, $stylist_id); $test_client->save(); $client_name2 = "Wendy Git"; $email = "*****@*****.**"; $test_client2 = new Client($client_name2, $id, $email, $stylist_id); $test_client2->save(); $result = $test_stylist->getClients(); $this->assertEquals([$test_client, $test_client2], $result); }
function testGetClients() { //Arrange $name = "jerry"; $id = null; $test_stylist = new Stylist($name, $id); $test_stylist->save(); $test_stylist_id = $test_stylist->getId(); $name = "kramer"; $phone = "123-321-1234"; $style_choice = "bowl cut"; $test_client = new Client($name, $phone, $style_choice, $test_stylist_id); $test_client->save(); $name2 = "ben"; $phone2 = "123-456-1234"; $style_choice2 = "trim"; $test_client2 = new Client($name2, $phone2, $style_choice2, $test_stylist_id); $test_client2->save(); //Act $result = $test_stylist->getClients(); //Assert $this->assertEquals([$test_client, $test_client2], $result); }
function testDelete() { //Arrange $id = null; $stylist_name = "Nico"; $test_stylist = new Stylist($id, $stylist_name); $test_stylist->save(); $stylist_name2 = "Tina"; $test_stylist2 = new Stylist($id, $stylist_name2); $test_stylist2->save(); //Act $test_stylist->delete(); //Assert $result = Stylist::getAll(); $this->assertEquals([$test_stylist2], $result); }
function test_client_delete() { //Arrange $name = "Vidal Sassoon"; $test_stylist = new Stylist($name); $test_stylist->save(); $name2 = "Sweeney Todd"; $test_stylist2 = new Stylist($name2); $test_stylist2->save(); $name3 = "Mr. T"; $stylist_id = $test_stylist->getId(); $test_client = new Client($name3, $stylist_id, null); $test_client->save(); $name4 = "Mrs. T"; $stylist_id2 = $test_stylist2->getId(); $test_client2 = new Client($name4, $stylist_id2, null); $test_client2->save(); //Act $test_client->delete(); //Assert $this->assertEquals([$test_client2], Client::getAll()); }
function test_delete() { //Arrange $name = "Tony"; $id = null; $test_Stylist = new Stylist($name, $id); $test_Stylist->save(); $name2 = "Ted"; $id = null; $test_Stylist2 = new Stylist($name, $id); $test_Stylist2->save(); //Act $test_Stylist->deleteStylist(); //Assert $this->assertEquals([$test_Stylist2], Stylist::getAll()); }
function test_stylist_getClient() { //Arrange $name = "Vidal Sassoon"; $test_stylist = new Stylist($name); $test_stylist->save(); $name2 = "Sweeney Todd"; $test_stylist2 = new Stylist($name2); $test_stylist2->save(); $name3 = "Mr. T"; $stylist_id = $test_stylist->getId(); $test_client = new Client($name3, $stylist_id, null); $test_client->save(); $name4 = "Mrs. T"; $stylist_id2 = $test_stylist2->getId(); $test_client2 = new Client($name4, $stylist_id2, null); $test_client2->save(); //Act $result = $test_stylist->getClient(); //Assert $this->assertEquals($test_client, $result[0]); }