Skip to content

Commit

Permalink
Created dummy test for Pommo_Setup class
Browse files Browse the repository at this point in the history
  • Loading branch information
soonick committed Apr 1, 2014
1 parent f9b095a commit ed1e56d
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 7 deletions.
14 changes: 10 additions & 4 deletions classes/Pommo_Setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,21 @@ class Pommo_Setup
* ]
* @return
*/
public function saveBouncesForm()
public function saveBouncesForm($data)
{
$this->error = null;
$messages = array();

if (empty($data['bounces_address'])) {
$messages['bounces_address'] = _(
'You must specify an e-mail address where the bounces will be'
. 'sent'
);
}

$this->error = array(
'code' => 1,
'message' => [
'something' => 'something'
]
'message' => $messages
);

return false;
Expand Down
16 changes: 14 additions & 2 deletions gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module.exports = function(grunt) {
'classes/*.php'
]
},

phpcs: {
api: {
dir: 'classes/Pommo_Api.php'
Expand All @@ -29,11 +30,21 @@ module.exports = function(grunt) {
options: {
standard: 'ruleset.xml'
}
},

phpunit: {
classes: {
dir: 'tests/unit/'
},
options: {
colors: true
}
}
});

grunt.loadNpmTasks('grunt-phplint');
grunt.loadNpmTasks('grunt-phpcs');
grunt.loadNpmTasks('grunt-phplint');
grunt.loadNpmTasks('grunt-phpunit');

grunt.registerTask(
'default',
Expand All @@ -44,7 +55,8 @@ module.exports = function(grunt) {
'phpcs:csvstream',
'phpcs:attachment',
'phpcs:ajaxbounces',
'phpcs:setup'
'phpcs:setup',
'phpunit'
]
);
};
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"devDependencies": {
"grunt": "~0.4.0",
"grunt-cli": "*",
"grunt-phpcs": "0.2.0",
"grunt-phplint": "0.0.5",
"grunt-phpcs": "0.2.0"
"grunt-phpunit": "0.3.3"
}
}
22 changes: 22 additions & 0 deletions tests/unit/classes/Pommo_Setup_Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

require 'classes/Pommo_Setup.php';

class Pommo_Setup_Test extends PHPUnit_Framework_Testcase
{
private $_instance;

public function setUp()
{
$this->_instance = new Pommo_Setup();
}

public function testIfBouncesAddressNotGivenReturnErrorMessage()
{
$this->_instance->saveBouncesForm(array());

$this->assertTrue(
isset($this->_instance->error['message']['bounces_address'])
);
}
}

0 comments on commit ed1e56d

Please sign in to comment.