Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #168 from devenbansod/add_tests_shell
Add tests for shells
- Loading branch information
Showing
12 changed files
with
280 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
<?php | ||
/* vim: set expandtab sw=4 ts=4 sts=4: */ | ||
|
||
/** | ||
* Tests for Clean Old Notifications Shell. | ||
* | ||
* phpMyAdmin Error reporting server | ||
* Copyright (c) phpMyAdmin project (https://www.phpmyadmin.net/) | ||
* | ||
* Licensed under The MIT License | ||
* For full copyright and license information, please see the LICENSE.txt | ||
* Redistributions of files must retain the above copyright notice. | ||
* | ||
* @copyright Copyright (c) phpMyAdmin project (https://www.phpmyadmin.net/) | ||
* @license https://opensource.org/licenses/mit-license.php MIT License | ||
* | ||
* @see https://www.phpmyadmin.net/ | ||
*/ | ||
|
||
namespace App\Test\TestCase\Shell; | ||
|
||
use App\Shell\CleanOldNotifsShell; | ||
use Cake\TestSuite\TestCase; | ||
|
||
/** | ||
* App\Shell\CleanOldNotifsShell Test Case | ||
*/ | ||
class CleanOldNotifsShellTest extends TestCase | ||
{ | ||
|
||
/** | ||
* ConsoleIo mock | ||
* | ||
* @var \Cake\Console\ConsoleIo|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
public $io; | ||
|
||
/** | ||
* Test subject | ||
* | ||
* @var \App\Shell\CleanOldNotifsShell | ||
*/ | ||
public $CleanOldNotifs; | ||
|
||
public $fixtures = array( | ||
'app.notifications', | ||
'app.developers' | ||
); | ||
|
||
/** | ||
* setUp method | ||
* | ||
* @return void | ||
*/ | ||
public function setUp() | ||
{ | ||
parent::setUp(); | ||
$this->io = $this->getMockBuilder('Cake\Console\ConsoleIo')->getMock(); | ||
$this->CleanOldNotifs = new CleanOldNotifsShell($this->io); | ||
} | ||
|
||
/** | ||
* tearDown method | ||
* | ||
* @return void | ||
*/ | ||
public function tearDown() | ||
{ | ||
unset($this->CleanOldNotifs); | ||
|
||
parent::tearDown(); | ||
} | ||
|
||
/** | ||
* Test main method | ||
* | ||
* @return void | ||
*/ | ||
public function testMain() | ||
{ | ||
// Call intialize method to load the models | ||
$this->CleanOldNotifs->initialize(); | ||
|
||
$conditions = array( | ||
'developer_id' => 1 | ||
); | ||
$currentNotificationCount | ||
= $this->CleanOldNotifs->Notifications->find('all')->where($conditions)->count(); | ||
$this->assertEquals(2, $currentNotificationCount); | ||
|
||
// Run shell command | ||
$this->CleanOldNotifs->main(); | ||
|
||
$newNotificationCount | ||
= $this->CleanOldNotifs->Notifications->find('all')->where($conditions)->count(); | ||
$this->assertEquals(0, $newNotificationCount); | ||
|
||
// Run shell command to generate zero notifications error | ||
$this->CleanOldNotifs->main(); | ||
} | ||
} |
Oops, something went wrong.