<commit_before><?php 
	
	require_once "./php/models/DatabaseCommunicator.php";
	require_once "./php/models/Session.php";
	require_once "./php/models/User.php";
	
	/* Run with phpunit --stderr TestModels.php */
	
	class TestModels extends PHPUnit_Framework_TestCase {
	
	
		/**** DatabaseCommunicator Tests ****/
		
	    public function testCreateDBCom()
	    {
	        $dbCom = new DatabaseCommunicator();
	        $dbCom->clean();
	
	        $dbCom->runQuery("SELECT * FROM users WHERE id = 1");
	        $result = $dbCom->getQueryResult();
	        $id = $result['id'];
	        $email = $result['email'];
	
	        $this->assertEquals(1, $id);
	        $this->assertEquals('<EMAIL>', $email);
	    }
	    
	    public function testRunDBComQuery() {
		    
		    $dbCom = new DatabaseCommunicator();
		    $dbCom->clean();
		    
		    $query = "INSERT INTO users
						(lastName, firstName, email, password) VALUES
						('User2', 'Sample2', '<EMAIL>', '');";
						
			$dbCom->runQuery($query);
			
			$dbCom->runQuery("SELECT * FROM users WHERE id = 2");
	        $result = $dbCom->getQueryResult();
	        $id = $result['id'];
	        $email = $result['email'];
			
			$this->assertEquals(2, $id);
			$this->assertEquals('<EMAIL>', $email);
			
	    }
	    
	    
	    
	    /**** Session Tests ****/
	    
	    public function testSession() {
		    
		    $session = new Session();
		    $session->setSessionVariable("testSessionID", 909);
		    $id = $session->getSessionVariable("testSessionID");
		    
		    $this->assertEquals(909, $id);
		    
	    }
	    
	    
	    
	    /**** User Tests ****/
	    
	    public function testCreateUser() {
		    
		    $user = new User();
		    $user->setFirstName("Test");
		    $user->setLastName("Buddy");
		    $user->setEmail("<EMAIL>");
		    $user->setPassword("<PASSWORD>");
			$user->saveUser();
			
			$dbCom = new DatabaseCommunicator();
			
			$dbCom->runQuery("SELECT * FROM users WHERE email = '<EMAIL>'");
			$result = $dbCom->getQueryResult();

			$this->assertEquals($user->getFirstName(), $result['firstName']);
			$this->assertEquals($user->getLastName(), $result['lastName']);
			$this->assertTrue($result['password'] != "");
			
	    }
	    
	    public function testLoadUser() {
		    
		    $user = new User();
			$user->loadUser(1);
			
			$this->assertEquals($user->getFirstName(), "Sample");
			$this->assertEquals($user->getLastName(), "User");
			$this->assertTrue($user->getPassword() != "");
			
	    }
	    
	    public function testVerifyUser() {
		    
			$user = new User();
			$user->setEmail("<EMAIL>");
			$this->assertEquals(1, $user->verifyUser("password"));
	    }
	    
	    
	
	}
	
	
	
	
	<commit_msg>fixed Quickbar so it passes all tests<commit_after><?php 
	
	require_once "../php/models/DatabaseCommunicator.php";
	require_once "../php/models/Session.php";
	require_once "../php/models/User.php";
	
	/* Run with phpunit --stderr TestModels.php */
	
	class TestModels extends PHPUnit_Framework_TestCase {
	
	
		/**** DatabaseCommunicator Tests ****/
		
	    public function testCreateDBCom()
	    {
	        $dbCom = new DatabaseCommunicator();
	        $dbCom->clean();
	
	        $dbCom->runQuery("SELECT * FROM users WHERE id = 1");
	        $result = $dbCom->getQueryResult();
	        $id = $result['id'];
	        $email = $result['email'];
	
	        $this->assertEquals(1, $id);
	        $this->assertEquals('<EMAIL>', $email);
	    }
	    
	    public function testRunDBComQuery() {
		    
		    $dbCom = new DatabaseCommunicator();
		    $dbCom->clean();
		    
		    $query = "INSERT INTO users
						(lastName, firstName, email, password) VALUES
						('User2', 'Sample2', '<EMAIL>', '');";
						
			$dbCom->runQuery($query);
			
			$dbCom->runQuery("SELECT * FROM users WHERE id = 2");
	        $result = $dbCom->getQueryResult();
	        $id = $result['id'];
	        $email = $result['email'];
			
			$this->assertEquals(2, $id);
			$this->assertEquals('<EMAIL>', $email);
			
	    }
	    
	    
	    
	    /**** Session Tests ****/
	    
	    public function testSession() {
		    
		    $session = new Session();
		    $session->setSessionVariable("testSessionID", 909);
		    $id = $session->getSessionVariable("testSessionID");
		    
		    $this->assertEquals(909, $id);
		    
	    }
	    
	    
	    
	    /**** User Tests ****/
	    
	    public function testCreateUser() {
		    
		    $user = new User();
		    $user->setFirstName("Test");
		    $user->setLastName("Buddy");
		    $user->setEmail("<EMAIL>");
		    $user->setPassword("<PASSWORD>");
		    $user->setQuickbarToDefault();
			$user->saveUser();
			
			$dbCom = new DatabaseCommunicator();
			
			$dbCom->runQuery("SELECT * FROM users WHERE email = '<EMAIL>'");
			$result = $dbCom->getQueryResult();

			$this->assertEquals($user->getFirstName(), $result['firstName']);
			$this->assertEquals($user->getLastName(), $result['lastName']);
			$this->assertTrue($result['password'] != "");
			
	    }
	    
	    public function testLoadUser() {
		    
		    $user = new User();
			$user->loadUser(1);
			
			$this->assertEquals($user->getFirstName(), "Sample");
			$this->assertEquals($user->getLastName(), "User");
			$this->assertTrue($user->getPassword() != "");
			
	    }
	    
	    public function testVerifyUser() {
		    
			$user = new User();
			$user->setEmail("<EMAIL>");
			$this->assertEquals(1, $user->verifyUser("password"));
	    }
	    
	    
	    
	    /**** Quickbar Tests ****/
	    
	    public function testQuickbarAdd() {
		    
			$quickbar = new Quickbar();
			$this->assertEquals(0, $quickbar->getSize());
			$quickbar->add("Reddit", "http://reddit.com");
			$this->assertEquals(1, $quickbar->getSize());
			$quickbar->add("The Weather Channel", "http://theweatherchannel.com");
			$this->assertEquals(2, $quickbar->getSize());
	    }
	    
	    
	    public function testQuickbarClear() {
		    
			$quickbar = new Quickbar();
			$this->assertEquals(0, $quickbar->getSize());
			$quickbar->add("Reddit", "http://reddit.com");
			$this->assertEquals(1, $quickbar->getSize());
			$quickbar->clear();
			$this->assertEquals(0, $quickbar->getSize());
	    }
	    
	    
	    public function testQuickbarSetToDefault() {
		    
			$quickbar = new Quickbar();
			$quickbar->setToDefault();
			$titles = $quickbar->getTitles();
			$links = $quickbar->getLinks();
			$icons = $quickbar->getIcons();
			$this->assertEquals(3, sizeof($titles));
			$this->assertEquals(3, sizeof($links));
			$this->assertEquals(3, sizeof($icons));
			$this->assertTrue($quickbar->getTitles()[0] != "");
			$this->assertTrue($quickbar->getLinks()[1] != "");
			$this->assertTrue($quickbar->getIcons()[2] != "");
	    }
	    
	    
	    public function testQuickbarSet() {
		    
			$quickbar = new Quickbar();
			
			$titles = array();
			$links = array();
			$quickbar->set($titles, $links);
			$this->assertEquals(0, $quickbar->getSize());
			
			$titles = array("Reddit", "Youtube", "Vimeo", "SoundCloud");
			$links = array("http://reddit.com", "http://youtube.com", "http://vimeo.com", "http://soundcloud.com");
			$quickbar->set($titles, $links);
			$this->assertEquals(4, $quickbar->getSize());
			$this->assertTrue($quickbar->getTitles()[0] != "");
			$this->assertTrue($quickbar->getLinks()[1] != "");
			$this->assertTrue($quickbar->getIcons()[2] != "");
			$this->assertTrue($quickbar->getTitles()[3] != "");
	    }
	
	}
	
	
	
	
	
{'fraction_non_alphanumeric': 0.19431726366819282, 'fraction_numerical': 0.0061944519256665765, 'mean_word_length': 2.700548081714001, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 133, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6318566', 'n_tokens_mistral': 2763, 'n_tokens_neox': 2294, 'n_words': 378}