[Ivan Diaz] - OS-#39 - Fix test issues

This commit is contained in:
Ivan Diaz 2016-05-14 20:22:46 -03:00
parent 953aa52584
commit 108ebd781c
14 changed files with 33 additions and 33 deletions

View File

@ -1,12 +0,0 @@
describe '/user/signup' do
it 'should create user in database' do
response = request('/user/signup', {
'email' => 'steve@jobs.com',
'password' => 'custom'
})
userRow = $database.getRow('users', response['data']['userId'])
(userRow['email']).should.equal('steve@jobs.com')
end
end

View File

@ -1,9 +0,0 @@
#!/bin/bash
# DELETE ALL TABLES
TABLES=$(mysql -u os_dev -pos_dev os_dev -e "SHOW TABLES IN os_dev;" | awk '{ print $1}' | grep -v '^Tables')
for t in $TABLES
do
mysql -u os_dev -pos_dev os_dev -e "DROP TABLE $t"
done

View File

@ -1,7 +1,7 @@
<?php
class Comment extends DataStore {
const TABLE = 'comment';
const TABLE = 'comments';
public static function getProps() {
return array(

View File

@ -1,7 +1,7 @@
<?php
class Ticket extends DataStore {
const TABLE = 'ticket';
const TABLE = 'tickets';
public static function getProps() {
return array(

View File

@ -1,7 +1,7 @@
<?php
class User extends DataStore {
const TABLE = 'user';
const TABLE = 'users';
public static function authenticate($userEmail, $userPassword) {
$user = User::getUser($userEmail, 'email');
@ -19,7 +19,7 @@ class User extends DataStore {
);
}
public function getDefaultProperties() {
public function getDefaultProps() {
return array(
'ownTickets' => []
);

View File

@ -17,16 +17,12 @@ class DataStoreMock extends DataStore {
);
}
public function getDefaultProperties() {
public function getDefaultProps() {
return array(
'prop1' => 0,
'prop2' => 'hello'
);
}
public static function deleteDataStore($dataStore) {
return parent::deleteDataStore($dataStore);
}
}
class DataStoreTest extends PHPUnit_Framework_TestCase {
@ -78,9 +74,8 @@ class DataStoreTest extends PHPUnit_Framework_TestCase {
}
public function testDeleteDataStore() {
$beanInstance = $this->instance->getBeanInstance();
DataStoreMock::deleteDataStore($this->instance);
$this->instance->delete();
$this->assertTrue(RedBean::get('trash')->hasBeenCalledWithArgs($beanInstance));
$this->assertTrue(RedBean::get('trash')->hasBeenCalledWithArgs($this->instance->getBeanInstance()));
}
}

9
tests/clean_db.sh Executable file
View File

@ -0,0 +1,9 @@
#!/bin/bash
# DELETE ALL TABLES
TABLES=$(mysql -u root development -e "SHOW TABLES IN os_dev;" | awk '{ print $1}' | grep -v '^Tables')
for t in $TABLES
do
mysql -u root development -e "DROP TABLE $t"
done

View File

@ -5,6 +5,7 @@ require 'uri'
require 'mysql'
require 'json'
require './libs.rb'
require './scripts.rb'
# TESTS
require './user/signup.rb'

2
tests/run-tests.sh Executable file
View File

@ -0,0 +1,2 @@
./clean_db.sh
bacon init.rb

View File

@ -7,5 +7,6 @@ class Scripts
if response['status'] === 'fail'
raise "Could not create user"
end
end
end

View File

@ -22,3 +22,4 @@ describe '/user/login' do
it 'should fail if already logged in' do
end
end

12
tests/user/signup.rb Normal file
View File

@ -0,0 +1,12 @@
describe '/user/signup' do
it 'should create user in database' do
response = request('/user/signup', {
'email' => 'steve@jobs.com',
'password' => 'custom'
})
userRow = $database.getRow('users', response['data']['userId'])
(userRow['email']).should.equal('steve@jobs.com')
end
end