Fixed PHPUnit assert calls to static.

This commit is contained in:
Dmitry Khomutov 2018-02-16 16:41:56 +07:00
parent 1dc8acd263
commit c05d3d6c90
No known key found for this signature in database
GPG key ID: EC19426474B37AAC
29 changed files with 355 additions and 346 deletions

View file

@ -47,7 +47,7 @@ class DatabaseTest extends \PHPUnit\Framework\TestCase
$this->checkDatabaseConnection(); $this->checkDatabaseConnection();
$connection = Database::getConnection('write'); $connection = Database::getConnection('write');
$this->assertInstanceOf('\b8\Database', $connection); self::assertInstanceOf('\b8\Database', $connection);
} }
public function testGetDetails() public function testGetDetails()
@ -55,10 +55,10 @@ class DatabaseTest extends \PHPUnit\Framework\TestCase
$this->checkDatabaseConnection(); $this->checkDatabaseConnection();
$details = Database::getConnection('read')->getDetails(); $details = Database::getConnection('read')->getDetails();
$this->assertTrue(is_array($details)); self::assertTrue(is_array($details));
$this->assertTrue(($details['db'] == DB_NAME)); self::assertTrue(($details['db'] == DB_NAME));
$this->assertTrue(($details['user'] == DB_USER)); self::assertTrue(($details['user'] == DB_USER));
$this->assertTrue(($details['pass'] == DB_PASS)); self::assertTrue(($details['pass'] == DB_PASS));
} }
/** /**

View file

@ -2,9 +2,11 @@
namespace Tests\b8; namespace Tests\b8;
use b8\Form, b8\Config; use b8\Form;
use b8\Config;
use PHPUnit\Framework\TestCase;
class FormTest extends \PHPUnit\Framework\TestCase class FormTest extends TestCase
{ {
public function testFormBasics() public function testFormBasics()
{ {
@ -12,8 +14,8 @@ class FormTest extends \PHPUnit\Framework\TestCase
$f->setAction('/'); $f->setAction('/');
$f->setMethod('POST'); $f->setMethod('POST');
$this->assertTrue($f->getAction() == '/'); self::assertTrue($f->getAction() == '/');
$this->assertTrue($f->getMethod() == 'POST'); self::assertTrue($f->getMethod() == 'POST');
$config = new Config([ $config = new Config([
'b8' => [ 'b8' => [
@ -23,10 +25,11 @@ class FormTest extends \PHPUnit\Framework\TestCase
] ]
]); ]);
$this->assertTrue($f->render('form') == '/POST'); self::assertTrue($f->render('form') == '/POST');
Config::getInstance()->set('b8.view.path', ''); Config::getInstance()->set('b8.view.path', '');
$this->assertTrue(strpos((string)$f, '<form') !== false);
self::assertTrue(strpos((string)$f, '<form') !== false);
} }
public function testElementBasics() public function testElementBasics()
@ -37,44 +40,49 @@ class FormTest extends \PHPUnit\Framework\TestCase
$f->setClass('element-class'); $f->setClass('element-class');
$f->setContainerClass('container-class'); $f->setContainerClass('container-class');
$this->assertTrue($f->getName() == 'element-name'); self::assertTrue($f->getName() == 'element-name');
$this->assertTrue($f->getId() == 'element-id'); self::assertTrue($f->getId() == 'element-id');
$this->assertTrue($f->getLabel() == 'element-label'); self::assertTrue($f->getLabel() == 'element-label');
$this->assertTrue($f->getClass() == 'element-class'); self::assertTrue($f->getClass() == 'element-class');
$this->assertTrue($f->getContainerClass() == 'container-class'); self::assertTrue($f->getContainerClass() == 'container-class');
$output = $f->render(); $output = $f->render();
$this->assertTrue(is_string($output));
$this->assertTrue(!empty($output)); self::assertTrue(is_string($output));
$this->assertTrue(strpos($output, 'container-class') !== false); self::assertTrue(!empty($output));
self::assertTrue(strpos($output, 'container-class') !== false);
} }
public function testInputBasics() public function testInputBasics()
{ {
$f = new Form\Element\Text(); $f = new Form\Element\Text();
$f->setValue('input-value'); $f->setValue('input-value');
$f->setRequired(true); $f->setRequired(true);
$f->setValidator(function ($value) { $f->setValidator(function ($value) {
return ($value == 'input-value'); return ($value == 'input-value');
}); });
$this->assertTrue($f->getValue() == 'input-value'); self::assertTrue($f->getValue() == 'input-value');
$this->assertTrue($f->getRequired() == true); self::assertTrue($f->getRequired() == true);
$this->assertTrue(is_callable($f->getValidator())); self::assertTrue(is_callable($f->getValidator()));
} }
public function testInputValidation() public function testInputValidation()
{ {
$f = new Form\Element\Text(); $f = new Form\Element\Text();
$f->setRequired(true); $f->setRequired(true);
$this->assertFalse($f->validate());
self::assertFalse($f->validate());
$f->setRequired(false); $f->setRequired(false);
$f->setPattern('input\-value'); $f->setPattern('input\-value');
$this->assertFalse($f->validate());
self::assertFalse($f->validate());
$f->setValue('input-value'); $f->setValue('input-value');
$this->assertTrue($f->validate());
self::assertTrue($f->validate());
$f->setValidator(function ($item) { $f->setValidator(function ($item) {
if ($item != 'input-value') { if ($item != 'input-value') {
@ -82,11 +90,12 @@ class FormTest extends \PHPUnit\Framework\TestCase
} }
}); });
$this->assertTrue($f->validate()); self::assertTrue($f->validate());
$f->setValue('fail'); $f->setValue('fail');
$f->setPattern(null); $f->setPattern(null);
$this->assertFalse($f->validate());
self::assertFalse($f->validate());
} }
public function testFieldSetBasics() public function testFieldSetBasics()
@ -108,76 +117,76 @@ class FormTest extends \PHPUnit\Framework\TestCase
$f->addField($f2); $f->addField($f2);
$f->addField($f3); $f->addField($f3);
$this->assertFalse($f->validate()); self::assertFalse($f->validate());
$f->setValues(['group' => ['one' => 'ONE', 'two' => 'TWO'], 'three' => 'THREE']); $f->setValues(['group' => ['one' => 'ONE', 'two' => 'TWO'], 'three' => 'THREE']);
$values = $f->getValues(); $values = $f->getValues();
$this->assertTrue(is_array($values)); self::assertTrue(is_array($values));
$this->assertTrue(array_key_exists('group', $values)); self::assertTrue(array_key_exists('group', $values));
$this->assertTrue(array_key_exists('one', $values['group'])); self::assertTrue(array_key_exists('one', $values['group']));
$this->assertTrue(array_key_exists('three', $values)); self::assertTrue(array_key_exists('three', $values));
$this->assertTrue($values['group']['one'] == 'ONE'); self::assertTrue($values['group']['one'] == 'ONE');
$this->assertTrue($values['group']['two'] == 'TWO'); self::assertTrue($values['group']['two'] == 'TWO');
$this->assertTrue($values['three'] == 'THREE'); self::assertTrue($values['three'] == 'THREE');
$this->assertTrue($f->validate()); self::assertTrue($f->validate());
$html = $f->render(); $html = $f->render();
$this->assertTrue(strpos($html, 'one') !== false); self::assertTrue(strpos($html, 'one') !== false);
$this->assertTrue(strpos($html, 'two') !== false); self::assertTrue(strpos($html, 'two') !== false);
} }
public function testElements() public function testElements()
{ {
$e = new Form\Element\Button(); $e = new Form\Element\Button();
$this->assertTrue($e->validate()); self::assertTrue($e->validate());
$this->assertTrue(strpos($e->render(), 'button') !== false); self::assertTrue(strpos($e->render(), 'button') !== false);
$e = new Form\Element\Checkbox(); $e = new Form\Element\Checkbox();
$e->setCheckedValue('ten'); $e->setCheckedValue('ten');
$this->assertTrue($e->getCheckedValue() == 'ten'); self::assertTrue($e->getCheckedValue() == 'ten');
$this->assertTrue(strpos($e->render(), 'checkbox') !== false); self::assertTrue(strpos($e->render(), 'checkbox') !== false);
$this->assertTrue(strpos($e->render(), 'checked') === false); self::assertTrue(strpos($e->render(), 'checked') === false);
$e->setValue(true); $e->setValue(true);
$this->assertTrue(strpos($e->render(), 'checked') !== false); self::assertTrue(strpos($e->render(), 'checked') !== false);
$e->setValue('ten'); $e->setValue('ten');
$this->assertTrue(strpos($e->render(), 'checked') !== false); self::assertTrue(strpos($e->render(), 'checked') !== false);
$e->setValue('fail'); $e->setValue('fail');
$this->assertTrue(strpos($e->render(), 'checked') === false); self::assertTrue(strpos($e->render(), 'checked') === false);
$e = new Form\Element\CheckboxGroup(); $e = new Form\Element\CheckboxGroup();
$this->assertTrue(strpos($e->render(), 'group') !== false); self::assertTrue(strpos($e->render(), 'group') !== false);
$e = new Form\ControlGroup(); $e = new Form\ControlGroup();
$this->assertTrue(strpos($e->render(), 'group') !== false); self::assertTrue(strpos($e->render(), 'group') !== false);
$e = new Form\Element\Email(); $e = new Form\Element\Email();
$this->assertTrue(strpos($e->render(), 'email') !== false); self::assertTrue(strpos($e->render(), 'email') !== false);
$e = new Form\Element\Select(); $e = new Form\Element\Select();
$e->setOptions(['key' => 'Val']); $e->setOptions(['key' => 'Val']);
$html = $e->render(); $html = $e->render();
$this->assertTrue(strpos($html, 'select') !== false); self::assertTrue(strpos($html, 'select') !== false);
$this->assertTrue(strpos($html, 'option') !== false); self::assertTrue(strpos($html, 'option') !== false);
$this->assertTrue(strpos($html, 'key') !== false); self::assertTrue(strpos($html, 'key') !== false);
$this->assertTrue(strpos($html, 'Val') !== false); self::assertTrue(strpos($html, 'Val') !== false);
$e = new Form\Element\Submit(); $e = new Form\Element\Submit();
$this->assertTrue($e->validate()); self::assertTrue($e->validate());
$this->assertTrue(strpos($e->render(), 'submit') !== false); self::assertTrue(strpos($e->render(), 'submit') !== false);
$e = new Form\Element\Text(); $e = new Form\Element\Text();
$e->setValue('test'); $e->setValue('test');
$this->assertTrue(strpos($e->render(), 'test') !== false); self::assertTrue(strpos($e->render(), 'test') !== false);
$e = new Form\Element\TextArea(); $e = new Form\Element\TextArea();
$e->setRows(10); $e->setRows(10);
$this->assertTrue(strpos($e->render(), '10') !== false); self::assertTrue(strpos($e->render(), '10') !== false);
$e = new Form\Element\Url(); $e = new Form\Element\Url();
$this->assertTrue(strpos($e->render(), 'url') !== false); self::assertTrue(strpos($e->render(), 'url') !== false);
} }
} }

View file

@ -9,7 +9,7 @@ class HttpExceptionTest extends \PHPUnit\Framework\TestCase
public function testHttpExceptionIsException() public function testHttpExceptionIsException()
{ {
$ex = new HttpException(); $ex = new HttpException();
$this->assertTrue($ex instanceof \Exception); self::assertTrue($ex instanceof \Exception);
} }
public function testHttpException() public function testHttpException()
@ -17,10 +17,10 @@ class HttpExceptionTest extends \PHPUnit\Framework\TestCase
try { try {
throw new HttpException('Test'); throw new HttpException('Test');
} catch (HttpException $ex) { } catch (HttpException $ex) {
$this->assertTrue($ex->getMessage() == 'Test'); self::assertTrue($ex->getMessage() == 'Test');
$this->assertTrue($ex->getErrorCode() == 500); self::assertTrue($ex->getErrorCode() == 500);
$this->assertTrue($ex->getStatusMessage() == 'Internal Server Error'); self::assertTrue($ex->getStatusMessage() == 'Internal Server Error');
$this->assertTrue($ex->getHttpHeader() == 'HTTP/1.1 500 Internal Server Error'); self::assertTrue($ex->getHttpHeader() == 'HTTP/1.1 500 Internal Server Error');
} }
} }
@ -29,8 +29,8 @@ class HttpExceptionTest extends \PHPUnit\Framework\TestCase
try { try {
throw new HttpException\BadRequestException('Test'); throw new HttpException\BadRequestException('Test');
} catch (HttpException $ex) { } catch (HttpException $ex) {
$this->assertTrue($ex->getErrorCode() == 400); self::assertTrue($ex->getErrorCode() == 400);
$this->assertTrue($ex->getStatusMessage() == 'Bad Request'); self::assertTrue($ex->getStatusMessage() == 'Bad Request');
} }
} }
@ -39,8 +39,8 @@ class HttpExceptionTest extends \PHPUnit\Framework\TestCase
try { try {
throw new HttpException\ForbiddenException('Test'); throw new HttpException\ForbiddenException('Test');
} catch (HttpException $ex) { } catch (HttpException $ex) {
$this->assertTrue($ex->getErrorCode() == 403); self::assertTrue($ex->getErrorCode() == 403);
$this->assertTrue($ex->getStatusMessage() == 'Forbidden'); self::assertTrue($ex->getStatusMessage() == 'Forbidden');
} }
} }
@ -49,8 +49,8 @@ class HttpExceptionTest extends \PHPUnit\Framework\TestCase
try { try {
throw new HttpException\NotAuthorizedException('Test'); throw new HttpException\NotAuthorizedException('Test');
} catch (HttpException $ex) { } catch (HttpException $ex) {
$this->assertTrue($ex->getErrorCode() == 401); self::assertTrue($ex->getErrorCode() == 401);
$this->assertTrue($ex->getStatusMessage() == 'Not Authorized'); self::assertTrue($ex->getStatusMessage() == 'Not Authorized');
} }
} }
@ -59,8 +59,8 @@ class HttpExceptionTest extends \PHPUnit\Framework\TestCase
try { try {
throw new HttpException\NotFoundException('Test'); throw new HttpException\NotFoundException('Test');
} catch (HttpException $ex) { } catch (HttpException $ex) {
$this->assertTrue($ex->getErrorCode() == 404); self::assertTrue($ex->getErrorCode() == 404);
$this->assertTrue($ex->getStatusMessage() == 'Not Found'); self::assertTrue($ex->getStatusMessage() == 'Not Found');
} }
} }
@ -69,8 +69,8 @@ class HttpExceptionTest extends \PHPUnit\Framework\TestCase
try { try {
throw new HttpException\ServerErrorException('Test'); throw new HttpException\ServerErrorException('Test');
} catch (HttpException $ex) { } catch (HttpException $ex) {
$this->assertTrue($ex->getErrorCode() == 500); self::assertTrue($ex->getErrorCode() == 500);
$this->assertTrue($ex->getStatusMessage() == 'Internal Server Error'); self::assertTrue($ex->getStatusMessage() == 'Internal Server Error');
} }
} }
@ -79,8 +79,8 @@ class HttpExceptionTest extends \PHPUnit\Framework\TestCase
try { try {
throw new HttpException\ValidationException('Test'); throw new HttpException\ValidationException('Test');
} catch (HttpException $ex) { } catch (HttpException $ex) {
$this->assertTrue($ex->getErrorCode() == 400); self::assertTrue($ex->getErrorCode() == 400);
$this->assertTrue($ex->getStatusMessage() == 'Bad Request'); self::assertTrue($ex->getStatusMessage() == 'Bad Request');
} }
} }
} }

View file

@ -10,7 +10,7 @@ class ViewTest extends \PHPUnit\Framework\TestCase
public function testSimpleView() public function testSimpleView()
{ {
$view = new View('simple', __DIR__ . '/data/view/'); $view = new View('simple', __DIR__ . '/data/view/');
$this->assertTrue($view->render() == 'Hello'); self::assertTrue($view->render() == 'Hello');
} }
/** /**
@ -26,9 +26,9 @@ class ViewTest extends \PHPUnit\Framework\TestCase
$view = new View('vars', __DIR__ . '/data/view/'); $view = new View('vars', __DIR__ . '/data/view/');
$view->who = 'World'; $view->who = 'World';
$this->assertTrue(isset($view->who)); self::assertTrue(isset($view->who));
$this->assertFalse(isset($view->what)); self::assertFalse(isset($view->what));
$this->assertTrue($view->render() == 'Hello World'); self::assertTrue($view->render() == 'Hello World');
} }
/** /**
@ -43,78 +43,78 @@ class ViewTest extends \PHPUnit\Framework\TestCase
public function testSimpleUserView() public function testSimpleUserView()
{ {
$view = new Template('Hello'); $view = new Template('Hello');
$this->assertTrue($view->render() == 'Hello'); self::assertTrue($view->render() == 'Hello');
} }
public function testUserViewYear() public function testUserViewYear()
{ {
$view = new Template('{@year}'); $view = new Template('{@year}');
$this->assertTrue($view->render() == date('Y')); self::assertTrue($view->render() == date('Y'));
} }
public function testUserViewVars() public function testUserViewVars()
{ {
$view = new Template('Hello {@who}'); $view = new Template('Hello {@who}');
$view->who = 'World'; $view->who = 'World';
$this->assertTrue($view->render() == 'Hello World'); self::assertTrue($view->render() == 'Hello World');
$view = new Template('Hello {@who}'); $view = new Template('Hello {@who}');
$this->assertTrue($view->render() == 'Hello '); self::assertTrue($view->render() == 'Hello ');
$view = new Template('Hello {@who.name}'); $view = new Template('Hello {@who.name}');
$view->who = ['name' => 'Dan']; $view->who = ['name' => 'Dan'];
$this->assertTrue($view->render() == 'Hello Dan'); self::assertTrue($view->render() == 'Hello Dan');
$tmp = new Template('Hello'); $tmp = new Template('Hello');
$tmp->who = 'World'; $tmp->who = 'World';
$view = new Template('Hello {@tmp.who}'); $view = new Template('Hello {@tmp.who}');
$view->tmp = $tmp; $view->tmp = $tmp;
$this->assertTrue($view->render() == 'Hello World'); self::assertTrue($view->render() == 'Hello World');
try { try {
$tmp = new Template('Hello'); $tmp = new Template('Hello');
$view = new Template('Hello {@tmp.who}'); $view = new Template('Hello {@tmp.who}');
$view->tmp = $tmp; $view->tmp = $tmp;
$this->assertTrue($view->render() == 'Hello '); self::assertTrue($view->render() == 'Hello ');
} catch (\Exception $e) { } catch (\Exception $e) {
self::assertInstanceOf('\PHPUnit_Framework_Error_Notice', $e); self::assertInstanceOf('\PHPUnit_Framework_Error_Notice', $e);
} }
$view = new Template('Hello {@who.toUpperCase}'); $view = new Template('Hello {@who.toUpperCase}');
$view->who = 'World'; $view->who = 'World';
$this->assertTrue($view->render() == 'Hello WORLD'); self::assertTrue($view->render() == 'Hello WORLD');
$view = new Template('Hello {@who.toLowerCase}'); $view = new Template('Hello {@who.toLowerCase}');
$view->who = 'World'; $view->who = 'World';
$this->assertTrue($view->render() == 'Hello world'); self::assertTrue($view->render() == 'Hello world');
} }
public function testUserViewIf() public function testUserViewIf()
{ {
$view = new Template('Hello{if who} World{/if}'); $view = new Template('Hello{if who} World{/if}');
$view->who = true; $view->who = true;
$this->assertTrue($view->render() == 'Hello World'); self::assertTrue($view->render() == 'Hello World');
$view = new Template('Hello{if who} World{/if}'); $view = new Template('Hello{if who} World{/if}');
$view->who = false; $view->who = false;
$this->assertTrue($view->render() == 'Hello'); self::assertTrue($view->render() == 'Hello');
$view = new Template('Hello{ifnot who} World{/ifnot}'); $view = new Template('Hello{ifnot who} World{/ifnot}');
$view->who = true; $view->who = true;
$this->assertTrue($view->render() == 'Hello'); self::assertTrue($view->render() == 'Hello');
} }
public function testUserViewLoop() public function testUserViewLoop()
{ {
$view = new Template('Hello {loop who}{@item}{/loop}'); $view = new Template('Hello {loop who}{@item}{/loop}');
$view->who = ['W', 'o', 'r', 'l', 'd']; $view->who = ['W', 'o', 'r', 'l', 'd'];
$this->assertTrue($view->render() == 'Hello World'); self::assertTrue($view->render() == 'Hello World');
$view = new Template('Hello {loop who}{@item}{/loop}'); $view = new Template('Hello {loop who}{@item}{/loop}');
$this->assertTrue($view->render() == 'Hello '); self::assertTrue($view->render() == 'Hello ');
$view = new Template('Hello {loop who}{@item}{/loop}'); $view = new Template('Hello {loop who}{@item}{/loop}');
$view->who = 'World'; $view->who = 'World';
$this->assertTrue($view->render() == 'Hello World'); self::assertTrue($view->render() == 'Hello World');
} }
} }

View file

@ -28,7 +28,7 @@ class CreateAdminCommandTest extends \PHPUnit\Framework\TestCase
parent::setUp(); parent::setUp();
$userStoreMock = $this->getMockBuilder('PHPCensor\\Store\\UserStore')->getMock(); $userStoreMock = $this->getMockBuilder('PHPCensor\\Store\\UserStore')->getMock();
$this->command = new CreateAdminCommand($userStoreMock); $this->command = new CreateAdminCommand($userStoreMock);
$this->helper = $this $this->helper = $this
@ -60,6 +60,6 @@ class CreateAdminCommandTest extends \PHPUnit\Framework\TestCase
$commandTester = $this->getCommandTester(); $commandTester = $this->getCommandTester();
$commandTester->execute([]); $commandTester->execute([]);
$this->assertEquals('User account created!' . PHP_EOL, $commandTester->getDisplay()); self::assertEquals('User account created!' . PHP_EOL, $commandTester->getDisplay());
} }
} }

View file

@ -140,7 +140,7 @@ class InstallCommandTest extends \PHPUnit\Framework\TestCase
$this->executeWithoutParam('--db-type', $dialog); $this->executeWithoutParam('--db-type', $dialog);
// Check that specified arguments are correctly loaded. // Check that specified arguments are correctly loaded.
$this->assertEquals('testedvalue', $this->config['b8']['database']['type']); self::assertEquals('testedvalue', $this->config['b8']['database']['type']);
} }
public function testDatabaseHostConfig() public function testDatabaseHostConfig()
@ -153,8 +153,8 @@ class InstallCommandTest extends \PHPUnit\Framework\TestCase
$this->executeWithoutParam('--db-host', $dialog); $this->executeWithoutParam('--db-host', $dialog);
// Check that specified arguments are correctly loaded. // Check that specified arguments are correctly loaded.
$this->assertEquals('testedvalue', $this->config['b8']['database']['servers']['read'][0]['host']); self::assertEquals('testedvalue', $this->config['b8']['database']['servers']['read'][0]['host']);
$this->assertEquals('testedvalue', $this->config['b8']['database']['servers']['write'][0]['host']); self::assertEquals('testedvalue', $this->config['b8']['database']['servers']['write'][0]['host']);
} }
public function testDatabaseStringPortConfig() public function testDatabaseStringPortConfig()
@ -167,8 +167,8 @@ class InstallCommandTest extends \PHPUnit\Framework\TestCase
$this->executeWithoutParam('--db-port', $dialog); $this->executeWithoutParam('--db-port', $dialog);
// Check that specified arguments are correctly loaded. // Check that specified arguments are correctly loaded.
$this->assertArrayNotHasKey('port', $this->config['b8']['database']['servers']['read'][0]); self::assertArrayNotHasKey('port', $this->config['b8']['database']['servers']['read'][0]);
$this->assertArrayNotHasKey('port', $this->config['b8']['database']['servers']['write'][0]); self::assertArrayNotHasKey('port', $this->config['b8']['database']['servers']['write'][0]);
} }
public function testDatabasePortConfig() public function testDatabasePortConfig()
@ -181,8 +181,8 @@ class InstallCommandTest extends \PHPUnit\Framework\TestCase
$this->executeWithoutParam('--db-port', $dialog); $this->executeWithoutParam('--db-port', $dialog);
// Check that specified arguments are correctly loaded. // Check that specified arguments are correctly loaded.
$this->assertEquals(333, $this->config['b8']['database']['servers']['read'][0]['port']); self::assertEquals(333, $this->config['b8']['database']['servers']['read'][0]['port']);
$this->assertEquals(333, $this->config['b8']['database']['servers']['write'][0]['port']); self::assertEquals(333, $this->config['b8']['database']['servers']['write'][0]['port']);
} }
public function testDatabaseNameConfig() public function testDatabaseNameConfig()
@ -195,7 +195,7 @@ class InstallCommandTest extends \PHPUnit\Framework\TestCase
$this->executeWithoutParam('--db-name', $dialog); $this->executeWithoutParam('--db-name', $dialog);
// Check that specified arguments are correctly loaded. // Check that specified arguments are correctly loaded.
$this->assertEquals('testedvalue', $this->config['b8']['database']['name']); self::assertEquals('testedvalue', $this->config['b8']['database']['name']);
} }
public function testDatabaseUserConfig() public function testDatabaseUserConfig()
@ -208,19 +208,19 @@ class InstallCommandTest extends \PHPUnit\Framework\TestCase
$this->executeWithoutParam('--db-user', $dialog); $this->executeWithoutParam('--db-user', $dialog);
// Check that specified arguments are correctly loaded. // Check that specified arguments are correctly loaded.
$this->assertEquals('testedvalue', $this->config['b8']['database']['username']); self::assertEquals('testedvalue', $this->config['b8']['database']['username']);
} }
public function testDatabasePasswordConfig() public function testDatabasePasswordConfig()
{ {
$dialog = $this->getHelperMock(); $dialog = $this->getHelperMock();
$dialog->expects($this->once())->method('ask')->willReturn('testedvalue'); $dialog->expects($this->once())->method('ask')->willReturn('testedvalue');
$this->executeWithoutParam('--db-password', $dialog); $this->executeWithoutParam('--db-password', $dialog);
// Check that specified arguments are correctly loaded. // Check that specified arguments are correctly loaded.
$this->assertEquals('testedvalue', $this->config['b8']['database']['password']); self::assertEquals('testedvalue', $this->config['b8']['database']['password']);
} }
public function testUrlConfig() public function testUrlConfig()
@ -233,7 +233,7 @@ class InstallCommandTest extends \PHPUnit\Framework\TestCase
$this->executeWithoutParam('--url', $dialog); $this->executeWithoutParam('--url', $dialog);
// Check that specified arguments are correctly loaded. // Check that specified arguments are correctly loaded.
$this->assertEquals('http://testedvalue.com', $this->config['php-censor']['url']); self::assertEquals('http://testedvalue.com', $this->config['php-censor']['url']);
} }
public function testAdminEmailConfig() public function testAdminEmailConfig()
@ -246,7 +246,7 @@ class InstallCommandTest extends \PHPUnit\Framework\TestCase
$this->executeWithoutParam('--admin-email', $dialog); $this->executeWithoutParam('--admin-email', $dialog);
// Check that specified arguments are correctly loaded. // Check that specified arguments are correctly loaded.
$this->assertEquals('admin@php-censor.local', $this->admin['email']); self::assertEquals('admin@php-censor.local', $this->admin['email']);
} }
public function testAdminNameConfig() public function testAdminNameConfig()
@ -259,7 +259,7 @@ class InstallCommandTest extends \PHPUnit\Framework\TestCase
$this->executeWithoutParam('--admin-name', $dialog); $this->executeWithoutParam('--admin-name', $dialog);
// Check that specified arguments are correctly loaded. // Check that specified arguments are correctly loaded.
$this->assertEquals('testedvalue', $this->admin['name']); self::assertEquals('testedvalue', $this->admin['name']);
} }
public function testAdminPasswordConfig() public function testAdminPasswordConfig()
@ -272,6 +272,6 @@ class InstallCommandTest extends \PHPUnit\Framework\TestCase
$this->executeWithoutParam('--admin-password', $dialog); $this->executeWithoutParam('--admin-password', $dialog);
// Check that specified arguments are correctly loaded. // Check that specified arguments are correctly loaded.
$this->assertEquals('testedvalue', $this->admin['password']); self::assertEquals('testedvalue', $this->admin['password']);
} }
} }

View file

@ -16,17 +16,17 @@ class WebhookControllerTest extends \PHPUnit\Framework\TestCase
$error = $webController->handleAction('test', []); $error = $webController->handleAction('test', []);
$this->assertInstanceOf('b8\Http\Response\JsonResponse', $error); self::assertInstanceOf('b8\Http\Response\JsonResponse', $error);
$responseData = $error->getData(); $responseData = $error->getData();
$this->assertEquals(500, $responseData['code']); self::assertEquals(500, $responseData['code']);
$this->assertEquals('failed', $responseData['body']['status']); self::assertEquals('failed', $responseData['body']['status']);
$this->assertEquals('application/json', $responseData['headers']['Content-Type']); self::assertEquals('application/json', $responseData['headers']['Content-Type']);
// @todo: we can't text the result is JSON file with // @todo: we can't text the result is JSON file with
// $this->assertJson((string) $error); // self::assertJson((string) $error);
// since the flush method automatically add the header and break the // since the flush method automatically add the header and break the
// testing framework. // testing framework.
} }

View file

@ -13,6 +13,6 @@ class AnsiConverterTest extends TestCase
$expectedOutput = '<span class="ansi_color_bg_black ansi_color_fg_red">This is red !</span>'; $expectedOutput = '<span class="ansi_color_bg_black ansi_color_fg_red">This is red !</span>';
$actualOutput = AnsiConverter::convert($input); $actualOutput = AnsiConverter::convert($input);
$this->assertEquals($expectedOutput, $actualOutput); self::assertEquals($expectedOutput, $actualOutput);
} }
} }

View file

@ -24,7 +24,7 @@ class BuildInterpolatorTest extends \PHPUnit\Framework\TestCase
$actualOutput = $this->testedInterpolator->interpolate($string); $actualOutput = $this->testedInterpolator->interpolate($string);
$this->assertEquals($expectedOutput, $actualOutput); self::assertEquals($expectedOutput, $actualOutput);
} }
public function testInterpolate_LeavesStringsUnchangedWhenBuildIsSet() public function testInterpolate_LeavesStringsUnchangedWhenBuildIsSet()
@ -42,7 +42,7 @@ class BuildInterpolatorTest extends \PHPUnit\Framework\TestCase
$actualOutput = $this->testedInterpolator->interpolate($string); $actualOutput = $this->testedInterpolator->interpolate($string);
$this->assertEquals($expectedOutput, $actualOutput); self::assertEquals($expectedOutput, $actualOutput);
} }
} }

View file

@ -25,7 +25,7 @@ class CommandExecutorTest extends \PHPUnit\Framework\TestCase
{ {
$this->testedExecutor->executeCommand(['echo "%s"', 'Hello World']); $this->testedExecutor->executeCommand(['echo "%s"', 'Hello World']);
$output = $this->testedExecutor->getLastOutput(); $output = $this->testedExecutor->getLastOutput();
$this->assertEquals("Hello World", $output); self::assertEquals("Hello World", $output);
} }
public function testGetLastOutput_ForgetsPreviousCommandOutput() public function testGetLastOutput_ForgetsPreviousCommandOutput()
@ -33,19 +33,19 @@ class CommandExecutorTest extends \PHPUnit\Framework\TestCase
$this->testedExecutor->executeCommand(['echo "%s"', 'Hello World']); $this->testedExecutor->executeCommand(['echo "%s"', 'Hello World']);
$this->testedExecutor->executeCommand(['echo "%s"', 'Hello Tester']); $this->testedExecutor->executeCommand(['echo "%s"', 'Hello Tester']);
$output = $this->testedExecutor->getLastOutput(); $output = $this->testedExecutor->getLastOutput();
$this->assertEquals("Hello Tester", $output); self::assertEquals("Hello Tester", $output);
} }
public function testExecuteCommand_ReturnsTrueForValidCommands() public function testExecuteCommand_ReturnsTrueForValidCommands()
{ {
$returnValue = $this->testedExecutor->executeCommand(['echo "%s"', 'Hello World']); $returnValue = $this->testedExecutor->executeCommand(['echo "%s"', 'Hello World']);
$this->assertTrue($returnValue); self::assertTrue($returnValue);
} }
public function testExecuteCommand_ReturnsFalseForInvalidCommands() public function testExecuteCommand_ReturnsFalseForInvalidCommands()
{ {
$returnValue = $this->testedExecutor->executeCommand(['eerfdcvcho "%s" > /dev/null 2>&1', 'Hello World']); $returnValue = $this->testedExecutor->executeCommand(['eerfdcvcho "%s" > /dev/null 2>&1', 'Hello World']);
$this->assertFalse($returnValue); self::assertFalse($returnValue);
} }
/** /**
@ -62,9 +62,9 @@ class CommandExecutorTest extends \PHPUnit\Framework\TestCase
EOD; EOD;
$data = str_repeat("-", $length); $data = str_repeat("-", $length);
$returnValue = $this->testedExecutor->executeCommand([$script]); $returnValue = $this->testedExecutor->executeCommand([$script]);
$this->assertTrue($returnValue); self::assertTrue($returnValue);
$this->assertEquals($data, trim($this->testedExecutor->getLastOutput())); self::assertEquals($data, trim($this->testedExecutor->getLastOutput()));
$this->assertEquals($data, trim($this->testedExecutor->getLastError())); self::assertEquals($data, trim($this->testedExecutor->getLastError()));
} }
/** /**
@ -80,26 +80,26 @@ EOD;
public function testFindBinary_ReturnsNullWihQuietArgument() public function testFindBinary_ReturnsNullWihQuietArgument()
{ {
$thisFileName = "WorldWidePeace"; $thisFileName = "WorldWidePeace";
$this->assertFalse($this->testedExecutor->findBinary($thisFileName, true)); self::assertFalse($this->testedExecutor->findBinary($thisFileName, true));
} }
public function testReplaceIllegalCharacters() public function testReplaceIllegalCharacters()
{ {
$this->assertEquals( self::assertEquals(
"start <20> end", "start <20> end",
$this->testedExecutor->replaceIllegalCharacters( $this->testedExecutor->replaceIllegalCharacters(
"start \xf0\x9c\x83\x96 end" "start \xf0\x9c\x83\x96 end"
) )
); );
$this->assertEquals( self::assertEquals(
"start <20> end", "start <20> end",
$this->testedExecutor->replaceIllegalCharacters( $this->testedExecutor->replaceIllegalCharacters(
"start \xF0\x9C\x83\x96 end" "start \xF0\x9C\x83\x96 end"
) )
); );
$this->assertEquals( self::assertEquals(
"start 123_X08<30>_X00<30>_Xa4<61>_5432 end", "start 123_X08<30>_X00<30>_Xa4<61>_5432 end",
$this->testedExecutor->replaceIllegalCharacters( $this->testedExecutor->replaceIllegalCharacters(
"start 123_X08\x08_X00\x00_Xa4\xa4_5432 end" "start 123_X08\x08_X00\x00_Xa4\xa4_5432 end"

View file

@ -8,9 +8,9 @@ class LangTest extends LocalizationTestCase
{ {
public function testSuccess() public function testSuccess()
{ {
$this->assertTrue(true); self::assertTrue(true);
} }
/** /**
* @return array * @return array
*/ */
@ -37,7 +37,7 @@ class LangTest extends LocalizationTestCase
$en = include($directory . 'lang.en.php'); $en = include($directory . 'lang.en.php');
foreach ($en as $enIndex => $enString) { foreach ($en as $enIndex => $enString) {
$this->assertArrayHasKey($enIndex, $strings); self::assertArrayHasKey($enIndex, $strings);
} }
}*/ }*/
} }

View file

@ -27,12 +27,12 @@ class MailerFactoryTest extends \PHPUnit\Framework\TestCase
$factory = new MailerFactory(['email_settings' => $config]); $factory = new MailerFactory(['email_settings' => $config]);
$this->assertEquals($config['smtp_address'], $factory->getMailConfig('smtp_address')); self::assertEquals($config['smtp_address'], $factory->getMailConfig('smtp_address'));
$this->assertEquals($config['smtp_port'], $factory->getMailConfig('smtp_port')); self::assertEquals($config['smtp_port'], $factory->getMailConfig('smtp_port'));
$this->assertEquals($config['smtp_encryption'], $factory->getMailConfig('smtp_encryption')); self::assertEquals($config['smtp_encryption'], $factory->getMailConfig('smtp_encryption'));
$this->assertEquals($config['smtp_username'], $factory->getMailConfig('smtp_username')); self::assertEquals($config['smtp_username'], $factory->getMailConfig('smtp_username'));
$this->assertEquals($config['smtp_password'], $factory->getMailConfig('smtp_password')); self::assertEquals($config['smtp_password'], $factory->getMailConfig('smtp_password'));
$this->assertEquals($config['default_mailto_address'], $factory->getMailConfig('default_mailto_address')); self::assertEquals($config['default_mailto_address'], $factory->getMailConfig('default_mailto_address'));
} }
public function testExecute_TestMailer() public function testExecute_TestMailer()
@ -49,10 +49,10 @@ class MailerFactoryTest extends \PHPUnit\Framework\TestCase
$factory = new MailerFactory(['email_settings' => $config]); $factory = new MailerFactory(['email_settings' => $config]);
$mailer = $factory->getSwiftMailerFromConfig(); $mailer = $factory->getSwiftMailerFromConfig();
$this->assertEquals($config['smtp_address'], $mailer->getTransport()->getHost()); self::assertEquals($config['smtp_address'], $mailer->getTransport()->getHost());
$this->assertEquals($config['smtp_port'], $mailer->getTransport()->getPort()); self::assertEquals($config['smtp_port'], $mailer->getTransport()->getPort());
$this->assertEquals('tls', $mailer->getTransport()->getEncryption()); self::assertEquals('tls', $mailer->getTransport()->getEncryption());
$this->assertEquals($config['smtp_username'], $mailer->getTransport()->getUsername()); self::assertEquals($config['smtp_username'], $mailer->getTransport()->getUsername());
$this->assertEquals($config['smtp_password'], $mailer->getTransport()->getPassword()); self::assertEquals($config['smtp_password'], $mailer->getTransport()->getPassword());
} }
} }

View file

@ -7,7 +7,7 @@ use PHPCensor\Model;
/** /**
* Unit tests for the Build model class. * Unit tests for the Build model class.
* *
* @author Dan Cryer <dan@block8.co.uk> * @author Dan Cryer <dan@block8.co.uk>
*/ */
class BuildTest extends \PHPUnit\Framework\TestCase class BuildTest extends \PHPUnit\Framework\TestCase
@ -19,32 +19,32 @@ class BuildTest extends \PHPUnit\Framework\TestCase
public function testExecute_TestIsAValidModel() public function testExecute_TestIsAValidModel()
{ {
$build = new Build(); $build = new Build();
$this->assertTrue($build instanceof \b8\Model); self::assertTrue($build instanceof \b8\Model);
$this->assertTrue($build instanceof Model); self::assertTrue($build instanceof Model);
} }
public function testExecute_TestBaseBuildDefaults() public function testExecute_TestBaseBuildDefaults()
{ {
$build = new Build(); $build = new Build();
$this->assertEquals('#', $build->getCommitLink()); self::assertEquals('#', $build->getCommitLink());
$this->assertEquals('#', $build->getBranchLink()); self::assertEquals('#', $build->getBranchLink());
$this->assertEquals(null, $build->getFileLinkTemplate()); self::assertEquals(null, $build->getFileLinkTemplate());
} }
public function testExecute_TestIsSuccessful() public function testExecute_TestIsSuccessful()
{ {
$build = new Build(); $build = new Build();
$build->setStatus(Build::STATUS_PENDING); $build->setStatus(Build::STATUS_PENDING);
$this->assertFalse($build->isSuccessful()); self::assertFalse($build->isSuccessful());
$build->setStatus(Build::STATUS_RUNNING); $build->setStatus(Build::STATUS_RUNNING);
$this->assertFalse($build->isSuccessful()); self::assertFalse($build->isSuccessful());
$build->setStatus(Build::STATUS_FAILED); $build->setStatus(Build::STATUS_FAILED);
$this->assertFalse($build->isSuccessful()); self::assertFalse($build->isSuccessful());
$build->setStatus(Build::STATUS_SUCCESS); $build->setStatus(Build::STATUS_SUCCESS);
$this->assertTrue($build->isSuccessful()); self::assertTrue($build->isSuccessful());
} }
public function testExecute_TestBuildExtra() public function testExecute_TestBuildExtra()
@ -57,26 +57,26 @@ class BuildTest extends \PHPUnit\Framework\TestCase
$build = new Build(); $build = new Build();
$build->setExtra(json_encode($info)); $build->setExtra(json_encode($info));
$this->assertEquals('Item One', $build->getExtra('item1')); self::assertEquals('Item One', $build->getExtra('item1'));
$this->assertEquals(2, $build->getExtra('item2')); self::assertEquals(2, $build->getExtra('item2'));
$this->assertNull($build->getExtra('item3')); self::assertNull($build->getExtra('item3'));
$this->assertEquals($info, $build->getExtra()); self::assertEquals($info, $build->getExtra());
$build->setExtraValue('item3', 'Item Three'); $build->setExtraValue('item3', 'Item Three');
$this->assertEquals('Item One', $build->getExtra('item1')); self::assertEquals('Item One', $build->getExtra('item1'));
$this->assertEquals('Item Three', $build->getExtra('item3')); self::assertEquals('Item Three', $build->getExtra('item3'));
$build->setExtraValues([ $build->setExtraValues([
'item3' => 'Item Three New', 'item3' => 'Item Three New',
'item4' => 4, 'item4' => 4,
]); ]);
$this->assertEquals('Item One', $build->getExtra('item1')); self::assertEquals('Item One', $build->getExtra('item1'));
$this->assertEquals('Item Three New', $build->getExtra('item3')); self::assertEquals('Item Three New', $build->getExtra('item3'));
$this->assertEquals(4, $build->getExtra('item4')); self::assertEquals(4, $build->getExtra('item4'));
$this->assertEquals([ self::assertEquals([
'item1' => 'Item One', 'item1' => 'Item One',
'item2' => 2, 'item2' => 2,
'item3' => 'Item Three New', 'item3' => 'Item Three New',

View file

@ -7,7 +7,7 @@ use PHPCensor\Model;
/** /**
* Unit tests for the Project model class. * Unit tests for the Project model class.
* *
* @author Dan Cryer <dan@block8.co.uk> * @author Dan Cryer <dan@block8.co.uk>
*/ */
class ProjectTest extends \PHPUnit\Framework\TestCase class ProjectTest extends \PHPUnit\Framework\TestCase
@ -15,8 +15,8 @@ class ProjectTest extends \PHPUnit\Framework\TestCase
public function testExecute_TestIsAValidModel() public function testExecute_TestIsAValidModel()
{ {
$project = new Project(); $project = new Project();
$this->assertTrue($project instanceof \b8\Model); self::assertTrue($project instanceof \b8\Model);
$this->assertTrue($project instanceof Model); self::assertTrue($project instanceof Model);
} }
public function testExecute_TestGitDefaultBranch() public function testExecute_TestGitDefaultBranch()
@ -24,7 +24,7 @@ class ProjectTest extends \PHPUnit\Framework\TestCase
$project = new Project(); $project = new Project();
$project->setType('git'); $project->setType('git');
$this->assertEquals('master', $project->getBranch()); self::assertEquals('master', $project->getBranch());
} }
public function testExecute_TestGithubDefaultBranch() public function testExecute_TestGithubDefaultBranch()
@ -32,7 +32,7 @@ class ProjectTest extends \PHPUnit\Framework\TestCase
$project = new Project(); $project = new Project();
$project->setType('github'); $project->setType('github');
$this->assertEquals('master', $project->getBranch()); self::assertEquals('master', $project->getBranch());
} }
public function testExecute_TestGitlabDefaultBranch() public function testExecute_TestGitlabDefaultBranch()
@ -40,7 +40,7 @@ class ProjectTest extends \PHPUnit\Framework\TestCase
$project = new Project(); $project = new Project();
$project->setType('gitlab'); $project->setType('gitlab');
$this->assertEquals('master', $project->getBranch()); self::assertEquals('master', $project->getBranch());
} }
public function testExecute_TestBitbucketDefaultBranch() public function testExecute_TestBitbucketDefaultBranch()
@ -48,7 +48,7 @@ class ProjectTest extends \PHPUnit\Framework\TestCase
$project = new Project(); $project = new Project();
$project->setType('bitbucket'); $project->setType('bitbucket');
$this->assertEquals('master', $project->getBranch()); self::assertEquals('master', $project->getBranch());
} }
public function testExecute_TestMercurialDefaultBranch() public function testExecute_TestMercurialDefaultBranch()
@ -56,7 +56,7 @@ class ProjectTest extends \PHPUnit\Framework\TestCase
$project = new Project(); $project = new Project();
$project->setType('hg'); $project->setType('hg');
$this->assertEquals('default', $project->getBranch()); self::assertEquals('default', $project->getBranch());
} }
public function testExecute_TestProjectAccessInformation() public function testExecute_TestProjectAccessInformation()
@ -69,9 +69,9 @@ class ProjectTest extends \PHPUnit\Framework\TestCase
$project = new Project(); $project = new Project();
$project->setAccessInformation($info); $project->setAccessInformation($info);
$this->assertEquals('Item One', $project->getAccessInformation('item1')); self::assertEquals('Item One', $project->getAccessInformation('item1'));
$this->assertEquals(2, $project->getAccessInformation('item2')); self::assertEquals(2, $project->getAccessInformation('item2'));
$this->assertNull($project->getAccessInformation('item3')); self::assertNull($project->getAccessInformation('item3'));
$this->assertEquals($info, $project->getAccessInformation()); self::assertEquals($info, $project->getAccessInformation());
} }
} }

View file

@ -8,7 +8,7 @@ use PHPCensor\Model\Build;
/** /**
* Unit test for the PHPUnit plugin. * Unit test for the PHPUnit plugin.
* *
* @author meadsteve * @author meadsteve
*/ */
class EmailTest extends \PHPUnit\Framework\TestCase class EmailTest extends \PHPUnit\Framework\TestCase
@ -156,7 +156,7 @@ class EmailTest extends \PHPUnit\Framework\TestCase
// As no addresses will have been mailed as non are configured. // As no addresses will have been mailed as non are configured.
$expectedReturn = false; $expectedReturn = false;
$this->assertEquals($expectedReturn, $returnValue); self::assertEquals($expectedReturn, $returnValue);
} }
public function testBuildsBasicEmails() public function testBuildsBasicEmails()
@ -165,7 +165,7 @@ class EmailTest extends \PHPUnit\Framework\TestCase
$this->testedEmailPlugin->execute(); $this->testedEmailPlugin->execute();
$this->assertContains('test-receiver@example.com', $this->message['to']); self::assertContains('test-receiver@example.com', $this->message['to']);
} }
public function testBuildsDefaultEmails() public function testBuildsDefaultEmails()
@ -174,7 +174,7 @@ class EmailTest extends \PHPUnit\Framework\TestCase
$this->testedEmailPlugin->execute(); $this->testedEmailPlugin->execute();
$this->assertContains('default-mailto-address@example.com', $this->message['to']); self::assertContains('default-mailto-address@example.com', $this->message['to']);
} }
public function testExecute_UniqueRecipientsFromWithCommitter() public function testExecute_UniqueRecipientsFromWithCommitter()
@ -182,12 +182,12 @@ class EmailTest extends \PHPUnit\Framework\TestCase
$this->loadEmailPluginWithOptions(['addresses' => ['test-receiver@example.com', 'test-receiver2@example.com']]); $this->loadEmailPluginWithOptions(['addresses' => ['test-receiver@example.com', 'test-receiver2@example.com']]);
$returnValue = $this->testedEmailPlugin->execute(); $returnValue = $this->testedEmailPlugin->execute();
$this->assertTrue($returnValue); self::assertTrue($returnValue);
$this->assertCount(2, $this->message['to']); self::assertCount(2, $this->message['to']);
$this->assertContains('test-receiver@example.com', $this->message['to']); self::assertContains('test-receiver@example.com', $this->message['to']);
$this->assertContains('test-receiver2@example.com', $this->message['to']); self::assertContains('test-receiver2@example.com', $this->message['to']);
} }
public function testExecute_UniqueRecipientsWithCommitter() public function testExecute_UniqueRecipientsWithCommitter()
@ -198,10 +198,10 @@ class EmailTest extends \PHPUnit\Framework\TestCase
]); ]);
$returnValue = $this->testedEmailPlugin->execute(); $returnValue = $this->testedEmailPlugin->execute();
$this->assertTrue($returnValue); self::assertTrue($returnValue);
$this->assertContains('test-receiver@example.com', $this->message['to']); self::assertContains('test-receiver@example.com', $this->message['to']);
$this->assertContains('committer@test.com', $this->message['to']); self::assertContains('committer@test.com', $this->message['to']);
} }
public function testCcDefaultEmails() public function testCcDefaultEmails()
@ -220,7 +220,7 @@ class EmailTest extends \PHPUnit\Framework\TestCase
$this->testedEmailPlugin->execute(); $this->testedEmailPlugin->execute();
$this->assertEquals( self::assertEquals(
[ [
'cc-email-1@example.com', 'cc-email-1@example.com',
'cc-email-2@example.com', 'cc-email-2@example.com',
@ -241,7 +241,7 @@ class EmailTest extends \PHPUnit\Framework\TestCase
$this->testedEmailPlugin->execute(); $this->testedEmailPlugin->execute();
$this->assertContains('committer-email@example.com', $this->message['to']); self::assertContains('committer-email@example.com', $this->message['to']);
} }
public function testMailSuccessfulBuildHaveProjectName() public function testMailSuccessfulBuildHaveProjectName()
@ -255,8 +255,8 @@ class EmailTest extends \PHPUnit\Framework\TestCase
$this->testedEmailPlugin->execute(); $this->testedEmailPlugin->execute();
$this->assertContains('Test-Project', $this->message['subject']); self::assertContains('Test-Project', $this->message['subject']);
$this->assertContains('Test-Project', $this->message['body']); self::assertContains('Test-Project', $this->message['body']);
} }
public function testMailFailingBuildHaveProjectName() public function testMailFailingBuildHaveProjectName()
@ -270,8 +270,8 @@ class EmailTest extends \PHPUnit\Framework\TestCase
$this->testedEmailPlugin->execute(); $this->testedEmailPlugin->execute();
$this->assertContains('Test-Project', $this->message['subject']); self::assertContains('Test-Project', $this->message['subject']);
$this->assertContains('Test-Project', $this->message['body']); self::assertContains('Test-Project', $this->message['body']);
} }
public function testMailSuccessfulBuildHaveStatus() public function testMailSuccessfulBuildHaveStatus()
@ -285,8 +285,8 @@ class EmailTest extends \PHPUnit\Framework\TestCase
$this->testedEmailPlugin->execute(); $this->testedEmailPlugin->execute();
$this->assertContains('Passing', $this->message['subject']); self::assertContains('Passing', $this->message['subject']);
$this->assertContains('success', $this->message['body']); self::assertContains('success', $this->message['body']);
} }
public function testMailFailingBuildHaveStatus() public function testMailFailingBuildHaveStatus()
@ -300,8 +300,8 @@ class EmailTest extends \PHPUnit\Framework\TestCase
$this->testedEmailPlugin->execute(); $this->testedEmailPlugin->execute();
$this->assertContains('Failing', $this->message['subject']); self::assertContains('Failing', $this->message['subject']);
$this->assertContains('failed', $this->message['body']); self::assertContains('failed', $this->message['body']);
} }
public function testMailDeliverySuccess() public function testMailDeliverySuccess()
@ -316,7 +316,7 @@ class EmailTest extends \PHPUnit\Framework\TestCase
$returnValue = $this->testedEmailPlugin->execute(); $returnValue = $this->testedEmailPlugin->execute();
$this->assertEquals(true, $returnValue); self::assertEquals(true, $returnValue);
} }
public function testMailDeliveryFail() public function testMailDeliveryFail()
@ -331,6 +331,6 @@ class EmailTest extends \PHPUnit\Framework\TestCase
$returnValue = $this->testedEmailPlugin->execute(); $returnValue = $this->testedEmailPlugin->execute();
$this->assertEquals(false, $returnValue); self::assertEquals(false, $returnValue);
} }
} }

View file

@ -96,7 +96,7 @@ class PhpUnitOptionsTest extends \PHPUnit\Framework\TestCase
public function testCommandArguments($rawOptions, $parsedArguments) public function testCommandArguments($rawOptions, $parsedArguments)
{ {
$options = new PhpUnitOptions($rawOptions, '/location'); $options = new PhpUnitOptions($rawOptions, '/location');
$this->assertSame($parsedArguments, $options->getCommandArguments()); self::assertSame($parsedArguments, $options->getCommandArguments());
} }
public function testGetters() public function testGetters()
@ -109,14 +109,14 @@ class PhpUnitOptionsTest extends \PHPUnit\Framework\TestCase
'/location' '/location'
); );
$this->assertEquals('/path/to/run/from', $options->getRunFrom()); self::assertEquals('/path/to/run/from', $options->getRunFrom());
$this->assertEquals('subTest', $options->getTestsPath()); self::assertEquals('subTest', $options->getTestsPath());
$this->assertNull($options->getOption('random')); self::assertNull($options->getOption('random'));
$this->assertEmpty($options->getDirectories()); self::assertEmpty($options->getDirectories());
$this->assertEmpty($options->getConfigFiles()); self::assertEmpty($options->getConfigFiles());
$files = $options->getConfigFiles(ROOT_DIR); $files = $options->getConfigFiles(ROOT_DIR);
$this->assertFileExists(ROOT_DIR . $files[0]); self::assertFileExists(ROOT_DIR . $files[0]);
} }
} }

View file

@ -85,46 +85,46 @@ class PharTest extends \PHPUnit\Framework\TestCase
public function testPlugin() public function testPlugin()
{ {
$plugin = $this->getPlugin(); $plugin = $this->getPlugin();
$this->assertInstanceOf('PHPCensor\Plugin', $plugin); self::assertInstanceOf('PHPCensor\Plugin', $plugin);
$this->assertInstanceOf('PHPCensor\Model\Build', $plugin->getBuild()); self::assertInstanceOf('PHPCensor\Model\Build', $plugin->getBuild());
$this->assertInstanceOf('PHPCensor\Builder', $plugin->getBuilder()); self::assertInstanceOf('PHPCensor\Builder', $plugin->getBuilder());
} }
public function testDirectory() public function testDirectory()
{ {
$plugin = $this->getPlugin(); $plugin = $this->getPlugin();
$plugin->getBuilder()->buildPath = 'foo'; $plugin->getBuilder()->buildPath = 'foo';
$this->assertEquals('foo', $plugin->getDirectory()); self::assertEquals('foo', $plugin->getDirectory());
$plugin = $this->getPlugin(['directory' => 'dirname']); $plugin = $this->getPlugin(['directory' => 'dirname']);
$this->assertEquals('dirname', $plugin->getDirectory()); self::assertEquals('dirname', $plugin->getDirectory());
} }
public function testFilename() public function testFilename()
{ {
$plugin = $this->getPlugin(); $plugin = $this->getPlugin();
$this->assertEquals('build.phar', $plugin->getFilename()); self::assertEquals('build.phar', $plugin->getFilename());
$plugin = $this->getPlugin(['filename' => 'another.phar']); $plugin = $this->getPlugin(['filename' => 'another.phar']);
$this->assertEquals('another.phar', $plugin->getFilename()); self::assertEquals('another.phar', $plugin->getFilename());
} }
public function testRegExp() public function testRegExp()
{ {
$plugin = $this->getPlugin(); $plugin = $this->getPlugin();
$this->assertEquals('/\.php$/', $plugin->getRegExp()); self::assertEquals('/\.php$/', $plugin->getRegExp());
$plugin = $this->getPlugin(['regexp' => '/\.(php|phtml)$/']); $plugin = $this->getPlugin(['regexp' => '/\.(php|phtml)$/']);
$this->assertEquals('/\.(php|phtml)$/', $plugin->getRegExp()); self::assertEquals('/\.(php|phtml)$/', $plugin->getRegExp());
} }
public function testStub() public function testStub()
{ {
$plugin = $this->getPlugin(); $plugin = $this->getPlugin();
$this->assertNull($plugin->getStub()); self::assertNull($plugin->getStub());
$plugin = $this->getPlugin(['stub' => 'stub.php']); $plugin = $this->getPlugin(['stub' => 'stub.php']);
$this->assertEquals('stub.php', $plugin->getStub()); self::assertEquals('stub.php', $plugin->getStub());
} }
public function testExecute() public function testExecute()
@ -135,14 +135,14 @@ class PharTest extends \PHPUnit\Framework\TestCase
$path = $this->buildSource(); $path = $this->buildSource();
$plugin->getBuilder()->buildPath = $path; $plugin->getBuilder()->buildPath = $path;
$this->assertTrue($plugin->execute()); self::assertTrue($plugin->execute());
$this->assertFileExists($path . '/build.phar'); self::assertFileExists($path . '/build.phar');
PHPPhar::loadPhar($path . '/build.phar'); PHPPhar::loadPhar($path . '/build.phar');
$this->assertFileEquals($path . '/one.php', 'phar://build.phar/one.php'); self::assertFileEquals($path . '/one.php', 'phar://build.phar/one.php');
$this->assertFileEquals($path . '/two.php', 'phar://build.phar/two.php'); self::assertFileEquals($path . '/two.php', 'phar://build.phar/two.php');
$this->assertFileNotExists('phar://build.phar/config/config.ini'); self::assertFileNotExists('phar://build.phar/config/config.ini');
$this->assertFileNotExists('phar://build.phar/views/index.phtml'); self::assertFileNotExists('phar://build.phar/views/index.phtml');
} }
public function testExecuteRegExp() public function testExecuteRegExp()
@ -153,14 +153,14 @@ class PharTest extends \PHPUnit\Framework\TestCase
$path = $this->buildSource(); $path = $this->buildSource();
$plugin->getBuilder()->buildPath = $path; $plugin->getBuilder()->buildPath = $path;
$this->assertTrue($plugin->execute()); self::assertTrue($plugin->execute());
$this->assertFileExists($path . '/build.phar'); self::assertFileExists($path . '/build.phar');
PHPPhar::loadPhar($path . '/build.phar'); PHPPhar::loadPhar($path . '/build.phar');
$this->assertFileEquals($path . '/one.php', 'phar://build.phar/one.php'); self::assertFileEquals($path . '/one.php', 'phar://build.phar/one.php');
$this->assertFileEquals($path . '/two.php', 'phar://build.phar/two.php'); self::assertFileEquals($path . '/two.php', 'phar://build.phar/two.php');
$this->assertFileNotExists('phar://build.phar/config/config.ini'); self::assertFileNotExists('phar://build.phar/config/config.ini');
$this->assertFileEquals($path . '/views/index.phtml', 'phar://build.phar/views/index.phtml'); self::assertFileEquals($path . '/views/index.phtml', 'phar://build.phar/views/index.phtml');
} }
public function testExecuteStub() public function testExecuteStub()
@ -179,11 +179,11 @@ STUB;
$plugin = $this->getPlugin(['stub' => 'stub.php']); $plugin = $this->getPlugin(['stub' => 'stub.php']);
$plugin->getBuilder()->buildPath = $path; $plugin->getBuilder()->buildPath = $path;
$this->assertTrue($plugin->execute()); self::assertTrue($plugin->execute());
$this->assertFileExists($path . '/build.phar'); self::assertFileExists($path . '/build.phar');
$phar = new PHPPhar($path . '/build.phar'); $phar = new PHPPhar($path . '/build.phar');
$this->assertEquals($content, trim($phar->getStub())); // + trim because PHP adds newline char self::assertEquals($content, trim($phar->getStub())); // + trim because PHP adds newline char
} }
public function testExecuteUnknownDirectory() public function testExecuteUnknownDirectory()
@ -195,6 +195,6 @@ STUB;
$plugin = $this->getPlugin(['directory' => $directory]); $plugin = $this->getPlugin(['directory' => $directory]);
$plugin->getBuilder()->buildPath = $this->buildSource(); $plugin->getBuilder()->buildPath = $this->buildSource();
$this->assertFalse($plugin->execute()); self::assertFalse($plugin->execute());
} }
} }

View file

@ -92,14 +92,14 @@ class ExecutorTest extends \PHPUnit\Framework\TestCase
$returnValue = $this->testedExecutor->executePlugin($pluginName, $options); $returnValue = $this->testedExecutor->executePlugin($pluginName, $options);
$this->assertEquals($expectedReturnValue, $returnValue); self::assertEquals($expectedReturnValue, $returnValue);
} }
public function testExecutePlugin_LogsFailureForNonExistentClasses() public function testExecutePlugin_LogsFailureForNonExistentClasses()
{ {
$options = []; $options = [];
$pluginName = 'DOESNTEXIST'; $pluginName = 'DOESNTEXIST';
$this->mockBuildLogger->logFailure(sprintf('Plugin does not exist: %s', $pluginName))->shouldBeCalledTimes(1); $this->mockBuildLogger->logFailure(sprintf('Plugin does not exist: %s', $pluginName))->shouldBeCalledTimes(1);
$this->testedExecutor->executePlugin($pluginName, $options); $this->testedExecutor->executePlugin($pluginName, $options);
@ -162,7 +162,7 @@ class ExecutorTest extends \PHPUnit\Framework\TestCase
] ]
]; ];
$this->assertEquals([], $this->testedExecutor->getBranchSpecificConfig($config, 'branch-1')); self::assertEquals([], $this->testedExecutor->getBranchSpecificConfig($config, 'branch-1'));
$config = [ $config = [
'setup' => [ 'setup' => [
@ -173,7 +173,7 @@ class ExecutorTest extends \PHPUnit\Framework\TestCase
], ],
]; ];
$this->assertEquals(['phpunit' => []], $this->testedExecutor->getBranchSpecificConfig($config, 'branch-1')); self::assertEquals(['phpunit' => []], $this->testedExecutor->getBranchSpecificConfig($config, 'branch-1'));
$config = [ $config = [
'setup' => [ 'setup' => [
@ -184,7 +184,7 @@ class ExecutorTest extends \PHPUnit\Framework\TestCase
], ],
]; ];
$this->assertEquals([], $this->testedExecutor->getBranchSpecificConfig($config, 'branch-1')); self::assertEquals([], $this->testedExecutor->getBranchSpecificConfig($config, 'branch-1'));
$config = [ $config = [
'setup' => [ 'setup' => [
@ -197,7 +197,7 @@ class ExecutorTest extends \PHPUnit\Framework\TestCase
], ],
]; ];
$this->assertEquals(['phpunit' => []], $this->testedExecutor->getBranchSpecificConfig($config, 'branch-1')); self::assertEquals(['phpunit' => []], $this->testedExecutor->getBranchSpecificConfig($config, 'branch-1'));
$config = [ $config = [
'setup' => [ 'setup' => [
@ -210,7 +210,7 @@ class ExecutorTest extends \PHPUnit\Framework\TestCase
], ],
]; ];
$this->assertEquals(['phpunit' => []], $this->testedExecutor->getBranchSpecificConfig($config, 'branch-1')); self::assertEquals(['phpunit' => []], $this->testedExecutor->getBranchSpecificConfig($config, 'branch-1'));
$config = [ $config = [
'setup' => [ 'setup' => [
@ -223,7 +223,7 @@ class ExecutorTest extends \PHPUnit\Framework\TestCase
], ],
]; ];
$this->assertEquals([], $this->testedExecutor->getBranchSpecificConfig($config, 'branch-1')); self::assertEquals([], $this->testedExecutor->getBranchSpecificConfig($config, 'branch-1'));
} }
} }

View file

@ -48,7 +48,7 @@ class FactoryTest extends \PHPUnit\Framework\TestCase {
{ {
$pluginClass = $this->getFakePluginClassName('ExamplePluginWithSingleOptionalArg'); $pluginClass = $this->getFakePluginClassName('ExamplePluginWithSingleOptionalArg');
$plugin = $this->testedFactory->buildPlugin($pluginClass); $plugin = $this->testedFactory->buildPlugin($pluginClass);
$this->assertInstanceOf($pluginClass, $plugin); self::assertInstanceOf($pluginClass, $plugin);
} }
public function testBuildPluginThrowsExceptionIfMissingResourcesForRequiredArg() public function testBuildPluginThrowsExceptionIfMissingResourcesForRequiredArg()
@ -74,7 +74,7 @@ class FactoryTest extends \PHPUnit\Framework\TestCase {
/** @var ExamplePluginWithSingleRequiredArg $plugin */ /** @var ExamplePluginWithSingleRequiredArg $plugin */
$plugin = $this->testedFactory->buildPlugin($pluginClass); $plugin = $this->testedFactory->buildPlugin($pluginClass);
$this->assertEquals($this->expectedResource, $plugin->RequiredArgument); self::assertEquals($this->expectedResource, $plugin->RequiredArgument);
} }
public function testBuildPluginLoadsArgumentsBasedOnType() public function testBuildPluginLoadsArgumentsBasedOnType()
@ -90,7 +90,7 @@ class FactoryTest extends \PHPUnit\Framework\TestCase {
/** @var ExamplePluginWithSingleTypedRequiredArg $plugin */ /** @var ExamplePluginWithSingleTypedRequiredArg $plugin */
$plugin = $this->testedFactory->buildPlugin($pluginClass); $plugin = $this->testedFactory->buildPlugin($pluginClass);
$this->assertEquals($this->expectedResource, $plugin->RequiredArgument); self::assertEquals($this->expectedResource, $plugin->RequiredArgument);
} }
public function testBuildPluginLoadsFullExample() public function testBuildPluginLoadsFullExample()
@ -102,7 +102,7 @@ class FactoryTest extends \PHPUnit\Framework\TestCase {
/** @var ExamplePluginFull $plugin */ /** @var ExamplePluginFull $plugin */
$plugin = $this->testedFactory->buildPlugin($pluginClass); $plugin = $this->testedFactory->buildPlugin($pluginClass);
$this->assertInstanceOf($pluginClass, $plugin); self::assertInstanceOf($pluginClass, $plugin);
} }
public function testBuildPluginLoadsFullExampleWithOptions() public function testBuildPluginLoadsFullExampleWithOptions()
@ -121,8 +121,8 @@ class FactoryTest extends \PHPUnit\Framework\TestCase {
$expectedArgs $expectedArgs
); );
$this->assertInternalType('array', $plugin->options); self::assertInternalType('array', $plugin->options);
$this->assertArrayHasKey('thing', $plugin->options); self::assertArrayHasKey('thing', $plugin->options);
} }
/** /**

View file

@ -30,31 +30,31 @@ class PhpUnitResultTest extends \PHPUnit\Framework\TestCase
$output = $parser->parse()->getResults(); $output = $parser->parse()->getResults();
$errors = $parser->getErrors(); $errors = $parser->getErrors();
$this->assertEquals(7, $parser->getFailures()); self::assertEquals(7, $parser->getFailures());
$this->assertInternalType('array', $output); self::assertInternalType('array', $output);
$this->assertInternalType('array', $errors); self::assertInternalType('array', $errors);
$this->assertNotEmpty($output); self::assertNotEmpty($output);
$this->assertNotEmpty($errors); self::assertNotEmpty($errors);
// The trace elements should not include the build path // The trace elements should not include the build path
$this->assertStringStartsNotWith($buildPath, $output[3]['trace'][0]); self::assertStringStartsNotWith($buildPath, $output[3]['trace'][0]);
$this->assertStringStartsNotWith($buildPath, $output[3]['trace'][1]); self::assertStringStartsNotWith($buildPath, $output[3]['trace'][1]);
$this->assertEquals("some output\nfrom f4", $output[7]['output']); self::assertEquals("some output\nfrom f4", $output[7]['output']);
$this->assertEquals("has output\non lines", $output[15]['output']); self::assertEquals("has output\non lines", $output[15]['output']);
$this->assertEquals(PhpUnitResult::SEVERITY_SKIPPED, $output[5]['severity']); self::assertEquals(PhpUnitResult::SEVERITY_SKIPPED, $output[5]['severity']);
try { try {
$this->assertContains('Incomplete Test:', $output[5]['message']); self::assertContains('Incomplete Test:', $output[5]['message']);
} catch (\PHPUnit_Framework_ExpectationFailedException $e) { } catch (\PHPUnit_Framework_ExpectationFailedException $e) {
self::$skipped[] = ['cls' => $resultClass, 'ex' => $e]; self::$skipped[] = ['cls' => $resultClass, 'ex' => $e];
} catch (\PHPUnit\Framework\ExpectationFailedException $e) { } catch (\PHPUnit\Framework\ExpectationFailedException $e) {
self::$skipped[] = ['cls' => $resultClass, 'ex' => $e]; self::$skipped[] = ['cls' => $resultClass, 'ex' => $e];
} }
$this->assertEquals(PhpUnitResult::SEVERITY_SKIPPED, $output[11]['severity']); self::assertEquals(PhpUnitResult::SEVERITY_SKIPPED, $output[11]['severity']);
try { try {
$this->assertContains('Skipped Test:', $output[11]['message']); self::assertContains('Skipped Test:', $output[11]['message']);
} catch (\PHPUnit_Framework_ExpectationFailedException $e) { } catch (\PHPUnit_Framework_ExpectationFailedException $e) {
self::$skipped[] = ['cls' => $resultClass, 'ex' => $e]; self::$skipped[] = ['cls' => $resultClass, 'ex' => $e];
} catch (\PHPUnit\Framework\ExpectationFailedException $e) { } catch (\PHPUnit\Framework\ExpectationFailedException $e) {

View file

@ -12,6 +12,6 @@ class PosixProcessControlTest extends UnixProcessControlTest
public function testIsAvailable() public function testIsAvailable()
{ {
$this->assertEquals(function_exists('posix_kill'), PosixProcessControl::isAvailable()); self::assertEquals(function_exists('posix_kill'), PosixProcessControl::isAvailable());
} }
} }

View file

@ -33,8 +33,8 @@ abstract class ProcessControlTest extends \PHPUnit\Framework\TestCase
$this->process = proc_open($this->getTestCommand(), $desc, $this->pipes); $this->process = proc_open($this->getTestCommand(), $desc, $this->pipes);
sleep(1); sleep(1);
$this->assertTrue(is_resource($this->process)); self::assertTrue(is_resource($this->process));
$this->assertTrue($this->isRunning()); self::assertTrue($this->isRunning());
$status = proc_get_status($this->process); $status = proc_get_status($this->process);
return (integer)$status['pid']; return (integer)$status['pid'];
@ -51,7 +51,7 @@ abstract class ProcessControlTest extends \PHPUnit\Framework\TestCase
} }
array_map('fclose', $this->pipes); array_map('fclose', $this->pipes);
$exitCode = proc_close($this->process); $exitCode = proc_close($this->process);
$this->assertFalse($this->isRunning()); self::assertFalse($this->isRunning());
$this->process = null; $this->process = null;
return $exitCode; return $exitCode;
} }
@ -76,14 +76,14 @@ abstract class ProcessControlTest extends \PHPUnit\Framework\TestCase
$pid = $this->startProcess(); $pid = $this->startProcess();
$this->assertTrue($this->object->isRunning($pid)); self::assertTrue($this->object->isRunning($pid));
fwrite($this->pipes[0], PHP_EOL); fwrite($this->pipes[0], PHP_EOL);
$exitCode = $this->endProcess(); $exitCode = $this->endProcess();
$this->assertEquals(0, $exitCode); self::assertEquals(0, $exitCode);
$this->assertFalse($this->object->isRunning($pid)); self::assertFalse($this->object->isRunning($pid));
} }
public function testSoftKill() public function testSoftKill()

View file

@ -17,6 +17,6 @@ class UnixProcessControlTest extends ProcessControlTest
public function testIsAvailable() public function testIsAvailable()
{ {
$this->assertEquals(DIRECTORY_SEPARATOR === '/', UnixProcessControl::isAvailable()); self::assertEquals(DIRECTORY_SEPARATOR === '/', UnixProcessControl::isAvailable());
} }
} }

View file

@ -8,14 +8,14 @@ class ServiceTest extends \PHPUnit\Framework\TestCase
{ {
public function testGetInstance() public function testGetInstance()
{ {
$this->assertInstanceOf('\PHPCensor\Security\Authentication\Service', Service::getInstance()); self::assertInstanceOf('\PHPCensor\Security\Authentication\Service', Service::getInstance());
} }
public function testBuildBuiltinProvider() public function testBuildBuiltinProvider()
{ {
$provider = Service::buildProvider('test', ['type' => 'internal']); $provider = Service::buildProvider('test', ['type' => 'internal']);
$this->assertInstanceOf('\PHPCensor\Security\Authentication\UserProvider\Internal', $provider); self::assertInstanceOf('\PHPCensor\Security\Authentication\UserProvider\Internal', $provider);
} }
public function testBuildAnyProvider() public function testBuildAnyProvider()
@ -23,9 +23,9 @@ class ServiceTest extends \PHPUnit\Framework\TestCase
$config = ['type' => '\Tests\PHPCensor\Security\Authentication\DummyProvider']; $config = ['type' => '\Tests\PHPCensor\Security\Authentication\DummyProvider'];
$provider = Service::buildProvider("test", $config); $provider = Service::buildProvider("test", $config);
$this->assertInstanceOf('\Tests\PHPCensor\Security\Authentication\DummyProvider', $provider); self::assertInstanceOf('\Tests\PHPCensor\Security\Authentication\DummyProvider', $provider);
$this->assertEquals('test', $provider->key); self::assertEquals('test', $provider->key);
$this->assertEquals($config, $provider->config); self::assertEquals($config, $provider->config);
} }
public function testGetProviders() public function testGetProviders()
@ -36,7 +36,7 @@ class ServiceTest extends \PHPUnit\Framework\TestCase
$service = new Service($providers); $service = new Service($providers);
$this->assertEquals($providers, $service->getProviders()); self::assertEquals($providers, $service->getProviders());
} }
public function testGetLoginPasswordProviders() public function testGetLoginPasswordProviders()
@ -47,7 +47,7 @@ class ServiceTest extends \PHPUnit\Framework\TestCase
$service = new Service($providers); $service = new Service($providers);
$this->assertEquals(['b' => $b], $service->getLoginPasswordProviders()); self::assertEquals(['b' => $b], $service->getLoginPasswordProviders());
} }
} }

View file

@ -25,7 +25,7 @@ class InternalTest extends \PHPUnit\Framework\TestCase
$password = 'bla'; $password = 'bla';
$user->setHash(password_hash($password, PASSWORD_DEFAULT)); $user->setHash(password_hash($password, PASSWORD_DEFAULT));
$this->assertTrue($this->provider->verifyPassword($user, $password)); self::assertTrue($this->provider->verifyPassword($user, $password));
} }
public function testVerifyInvaldPassword() public function testVerifyInvaldPassword()
@ -34,7 +34,7 @@ class InternalTest extends \PHPUnit\Framework\TestCase
$password = 'foo'; $password = 'foo';
$user->setHash(password_hash($password, PASSWORD_DEFAULT)); $user->setHash(password_hash($password, PASSWORD_DEFAULT));
$this->assertFalse($this->provider->verifyPassword($user, 'bar')); self::assertFalse($this->provider->verifyPassword($user, 'bar'));
} }
public function testCheckRequirements() public function testCheckRequirements()
@ -44,6 +44,6 @@ class InternalTest extends \PHPUnit\Framework\TestCase
public function testProvisionUser() public function testProvisionUser()
{ {
$this->assertNull($this->provider->provisionUser('john@doe.com')); self::assertNull($this->provider->provisionUser('john@doe.com'));
} }
} }

View file

@ -8,7 +8,7 @@ use PHPCensor\Service\BuildService;
/** /**
* Unit tests for the ProjectService class. * Unit tests for the ProjectService class.
* *
* @author Dan Cryer <dan@block8.co.uk> * @author Dan Cryer <dan@block8.co.uk>
*/ */
class BuildServiceTest extends \PHPUnit\Framework\TestCase class BuildServiceTest extends \PHPUnit\Framework\TestCase
@ -60,18 +60,18 @@ class BuildServiceTest extends \PHPUnit\Framework\TestCase
$returnValue = $this->testedService->createBuild($project, null); $returnValue = $this->testedService->createBuild($project, null);
$this->assertEquals(101, $returnValue->getProjectId()); self::assertEquals(101, $returnValue->getProjectId());
$this->assertEquals(Build::STATUS_PENDING, $returnValue->getStatus()); self::assertEquals(Build::STATUS_PENDING, $returnValue->getStatus());
$this->assertNull($returnValue->getStartDate()); self::assertNull($returnValue->getStartDate());
$this->assertNull($returnValue->getFinishDate()); self::assertNull($returnValue->getFinishDate());
$this->assertNull($returnValue->getLog()); self::assertNull($returnValue->getLog());
$this->assertEquals(null, $returnValue->getCommitMessage()); self::assertEquals(null, $returnValue->getCommitMessage());
$this->assertNull($returnValue->getCommitterEmail()); self::assertNull($returnValue->getCommitterEmail());
$this->assertEquals(['branches' => []], $returnValue->getExtra()); self::assertEquals(['branches' => []], $returnValue->getExtra());
$this->assertEquals('master', $returnValue->getBranch()); self::assertEquals('master', $returnValue->getBranch());
$this->assertInstanceOf('DateTime', $returnValue->getCreateDate()); self::assertInstanceOf('DateTime', $returnValue->getCreateDate());
$this->assertEquals('', $returnValue->getCommitId()); self::assertEquals('', $returnValue->getCommitId());
$this->assertEquals(Build::SOURCE_UNKNOWN, $returnValue->getSource()); self::assertEquals(Build::SOURCE_UNKNOWN, $returnValue->getSource());
} }
public function testExecute_CreateBuildWithOptions() public function testExecute_CreateBuildWithOptions()
@ -98,10 +98,10 @@ class BuildServiceTest extends \PHPUnit\Framework\TestCase
'test' 'test'
); );
$this->assertEquals('testbranch', $returnValue->getBranch()); self::assertEquals('testbranch', $returnValue->getBranch());
$this->assertEquals('123', $returnValue->getCommitId()); self::assertEquals('123', $returnValue->getCommitId());
$this->assertEquals('test', $returnValue->getCommitMessage()); self::assertEquals('test', $returnValue->getCommitMessage());
$this->assertEquals('test@example.com', $returnValue->getCommitterEmail()); self::assertEquals('test@example.com', $returnValue->getCommitterEmail());
} }
public function testExecute_CreateBuildWithExtra() public function testExecute_CreateBuildWithExtra()
@ -131,7 +131,7 @@ class BuildServiceTest extends \PHPUnit\Framework\TestCase
['item1' => 1001] ['item1' => 1001]
); );
$this->assertEquals(1001, $returnValue->getExtra('item1')); self::assertEquals(1001, $returnValue->getExtra('item1'));
} }
public function testExecute_CreateDuplicateBuild() public function testExecute_CreateDuplicateBuild()
@ -151,19 +151,19 @@ class BuildServiceTest extends \PHPUnit\Framework\TestCase
$returnValue = $this->testedService->createDuplicateBuild($build); $returnValue = $this->testedService->createDuplicateBuild($build);
$this->assertNotEquals($build->getId(), $returnValue->getId()); self::assertNotEquals($build->getId(), $returnValue->getId());
$this->assertEquals($build->getProjectId(), $returnValue->getProjectId()); self::assertEquals($build->getProjectId(), $returnValue->getProjectId());
$this->assertEquals($build->getCommitId(), $returnValue->getCommitId()); self::assertEquals($build->getCommitId(), $returnValue->getCommitId());
$this->assertNotEquals($build->getStatus(), $returnValue->getStatus()); self::assertNotEquals($build->getStatus(), $returnValue->getStatus());
$this->assertEquals(Build::STATUS_PENDING, $returnValue->getStatus()); self::assertEquals(Build::STATUS_PENDING, $returnValue->getStatus());
$this->assertNull($returnValue->getLog()); self::assertNull($returnValue->getLog());
$this->assertEquals($build->getBranch(), $returnValue->getBranch()); self::assertEquals($build->getBranch(), $returnValue->getBranch());
$this->assertNotEquals($build->getCreateDate(), $returnValue->getCreateDate()); self::assertNotEquals($build->getCreateDate(), $returnValue->getCreateDate());
$this->assertNull($returnValue->getStartDate()); self::assertNull($returnValue->getStartDate());
$this->assertNull($returnValue->getFinishDate()); self::assertNull($returnValue->getFinishDate());
$this->assertEquals('test', $returnValue->getCommitMessage()); self::assertEquals('test', $returnValue->getCommitMessage());
$this->assertEquals('test@example.com', $returnValue->getCommitterEmail()); self::assertEquals('test@example.com', $returnValue->getCommitterEmail());
$this->assertEquals($build->getExtra('item1'), $returnValue->getExtra('item1')); self::assertEquals($build->getExtra('item1'), $returnValue->getExtra('item1'));
} }
public function testExecute_DeleteBuild() public function testExecute_DeleteBuild()
@ -176,6 +176,6 @@ class BuildServiceTest extends \PHPUnit\Framework\TestCase
$service = new BuildService($store); $service = new BuildService($store);
$build = new Build(); $build = new Build();
$this->assertEquals(true, $service->deleteBuild($build)); self::assertEquals(true, $service->deleteBuild($build));
} }
} }

View file

@ -8,7 +8,7 @@ use PHPCensor\Service\BuildStatusService;
/** /**
* Unit tests for the ProjectService class. * Unit tests for the ProjectService class.
* *
* @author Dan Cryer <dan@block8.co.uk> * @author Dan Cryer <dan@block8.co.uk>
*/ */
class BuildStatusServiceTest extends \PHPUnit\Framework\TestCase class BuildStatusServiceTest extends \PHPUnit\Framework\TestCase
@ -142,7 +142,7 @@ class BuildStatusServiceTest extends \PHPUnit\Framework\TestCase
$build = $this->getBuild($buildConfigId); $build = $this->getBuild($buildConfigId);
$service = new BuildStatusService(self::BRANCH, $this->project, $build); $service = new BuildStatusService(self::BRANCH, $this->project, $build);
$service->setUrl('http://php-censor.local/'); $service->setUrl('http://php-censor.local/');
$this->assertEquals($expectedResult, $service->toArray()); self::assertEquals($expectedResult, $service->toArray());
} }
public function finishedProvider() public function finishedProvider()
@ -205,4 +205,4 @@ class BuildStatusServiceTest extends \PHPUnit\Framework\TestCase
], ],
]; ];
} }
} }

View file

@ -7,7 +7,7 @@ use PHPCensor\Service\ProjectService;
/** /**
* Unit tests for the ProjectService class. * Unit tests for the ProjectService class.
* *
* @author Dan Cryer <dan@block8.co.uk> * @author Dan Cryer <dan@block8.co.uk>
*/ */
class ProjectServiceTest extends \PHPUnit\Framework\TestCase class ProjectServiceTest extends \PHPUnit\Framework\TestCase
@ -37,10 +37,10 @@ class ProjectServiceTest extends \PHPUnit\Framework\TestCase
{ {
$returnValue = $this->testedService->createProject('Test Project', 'github', 'block8/phpci', 0); $returnValue = $this->testedService->createProject('Test Project', 'github', 'block8/phpci', 0);
$this->assertEquals('Test Project', $returnValue->getTitle()); self::assertEquals('Test Project', $returnValue->getTitle());
$this->assertEquals('github', $returnValue->getType()); self::assertEquals('github', $returnValue->getType());
$this->assertEquals('block8/phpci', $returnValue->getReference()); self::assertEquals('block8/phpci', $returnValue->getReference());
$this->assertEquals('master', $returnValue->getBranch()); self::assertEquals('master', $returnValue->getBranch());
} }
public function testExecute_CreateProjectWithOptions() public function testExecute_CreateProjectWithOptions()
@ -55,11 +55,11 @@ class ProjectServiceTest extends \PHPUnit\Framework\TestCase
$returnValue = $this->testedService->createProject('Test Project', 'github', 'block8/phpci', 0, $options); $returnValue = $this->testedService->createProject('Test Project', 'github', 'block8/phpci', 0, $options);
$this->assertEquals('private', $returnValue->getSshPrivateKey()); self::assertEquals('private', $returnValue->getSshPrivateKey());
$this->assertEquals('public', $returnValue->getSshPublicKey()); self::assertEquals('public', $returnValue->getSshPublicKey());
$this->assertEquals('config', $returnValue->getBuildConfig()); self::assertEquals('config', $returnValue->getBuildConfig());
$this->assertEquals('testbranch', $returnValue->getBranch()); self::assertEquals('testbranch', $returnValue->getBranch());
$this->assertEquals(1, $returnValue->getAllowPublicStatus()); self::assertEquals(1, $returnValue->getAllowPublicStatus());
} }
/** /**
@ -70,9 +70,9 @@ class ProjectServiceTest extends \PHPUnit\Framework\TestCase
$reference = 'git@gitlab.block8.net:block8/phpci.git'; $reference = 'git@gitlab.block8.net:block8/phpci.git';
$returnValue = $this->testedService->createProject('Gitlab', 'gitlab', $reference, 0); $returnValue = $this->testedService->createProject('Gitlab', 'gitlab', $reference, 0);
$this->assertEquals('git', $returnValue->getAccessInformation('user')); self::assertEquals('git', $returnValue->getAccessInformation('user'));
$this->assertEquals('gitlab.block8.net', $returnValue->getAccessInformation('domain')); self::assertEquals('gitlab.block8.net', $returnValue->getAccessInformation('domain'));
$this->assertEquals('block8/phpci', $returnValue->getReference()); self::assertEquals('block8/phpci', $returnValue->getReference());
} }
public function testExecute_UpdateExistingProject() public function testExecute_UpdateExistingProject()
@ -84,9 +84,9 @@ class ProjectServiceTest extends \PHPUnit\Framework\TestCase
$returnValue = $this->testedService->updateProject($project, 'After Title', 'bitbucket', 'After Reference'); $returnValue = $this->testedService->updateProject($project, 'After Title', 'bitbucket', 'After Reference');
$this->assertEquals('After Title', $returnValue->getTitle()); self::assertEquals('After Title', $returnValue->getTitle());
$this->assertEquals('After Reference', $returnValue->getReference()); self::assertEquals('After Reference', $returnValue->getReference());
$this->assertEquals('bitbucket', $returnValue->getType()); self::assertEquals('bitbucket', $returnValue->getType());
} }
public function testExecute_EmptyPublicStatus() public function testExecute_EmptyPublicStatus()
@ -102,7 +102,7 @@ class ProjectServiceTest extends \PHPUnit\Framework\TestCase
$returnValue = $this->testedService->updateProject($project, 'Test Project', 'github', 'block8/phpci', $options); $returnValue = $this->testedService->updateProject($project, 'Test Project', 'github', 'block8/phpci', $options);
$this->assertEquals(0, $returnValue->getAllowPublicStatus()); self::assertEquals(0, $returnValue->getAllowPublicStatus());
} }
public function testExecute_DeleteProject() public function testExecute_DeleteProject()
@ -115,6 +115,6 @@ class ProjectServiceTest extends \PHPUnit\Framework\TestCase
$service = new ProjectService($store); $service = new ProjectService($store);
$project = new Project(); $project = new Project();
$this->assertEquals(true, $service->deleteProject($project)); self::assertEquals(true, $service->deleteProject($project));
} }
} }

View file

@ -7,7 +7,7 @@ use PHPCensor\Service\UserService;
/** /**
* Unit tests for the ProjectService class. * Unit tests for the ProjectService class.
* *
* @author Dan Cryer <dan@block8.co.uk> * @author Dan Cryer <dan@block8.co.uk>
*/ */
class UserServiceTest extends \PHPUnit\Framework\TestCase class UserServiceTest extends \PHPUnit\Framework\TestCase
@ -44,10 +44,10 @@ class UserServiceTest extends \PHPUnit\Framework\TestCase
false false
); );
$this->assertEquals('Test', $user->getName()); self::assertEquals('Test', $user->getName());
$this->assertEquals('test@example.com', $user->getEmail()); self::assertEquals('test@example.com', $user->getEmail());
$this->assertEquals(0, $user->getIsAdmin()); self::assertEquals(0, $user->getIsAdmin());
$this->assertTrue(password_verify('testing', $user->getHash())); self::assertTrue(password_verify('testing', $user->getHash()));
} }
public function testExecute_CreateAdminUser() public function testExecute_CreateAdminUser()
@ -61,7 +61,7 @@ class UserServiceTest extends \PHPUnit\Framework\TestCase
true true
); );
$this->assertEquals(1, $user->getIsAdmin()); self::assertEquals(1, $user->getIsAdmin());
} }
public function testExecute_RevokeAdminStatus() public function testExecute_RevokeAdminStatus()
@ -72,7 +72,7 @@ class UserServiceTest extends \PHPUnit\Framework\TestCase
$user->setIsAdmin(1); $user->setIsAdmin(1);
$user = $this->testedService->updateUser($user, 'Test', 'test@example.com', 'testing', 0); $user = $this->testedService->updateUser($user, 'Test', 'test@example.com', 'testing', 0);
$this->assertEquals(0, $user->getIsAdmin()); self::assertEquals(0, $user->getIsAdmin());
} }
public function testExecute_GrantAdminStatus() public function testExecute_GrantAdminStatus()
@ -83,7 +83,7 @@ class UserServiceTest extends \PHPUnit\Framework\TestCase
$user->setIsAdmin(0); $user->setIsAdmin(0);
$user = $this->testedService->updateUser($user, 'Test', 'test@example.com', 'testing', 1); $user = $this->testedService->updateUser($user, 'Test', 'test@example.com', 'testing', 1);
$this->assertEquals(1, $user->getIsAdmin()); self::assertEquals(1, $user->getIsAdmin());
} }
public function testExecute_ChangesPasswordIfNotEmpty() public function testExecute_ChangesPasswordIfNotEmpty()
@ -92,8 +92,8 @@ class UserServiceTest extends \PHPUnit\Framework\TestCase
$user->setHash(password_hash('testing', PASSWORD_DEFAULT)); $user->setHash(password_hash('testing', PASSWORD_DEFAULT));
$user = $this->testedService->updateUser($user, 'Test', 'test@example.com', 'newpassword', 0); $user = $this->testedService->updateUser($user, 'Test', 'test@example.com', 'newpassword', 0);
$this->assertFalse(password_verify('testing', $user->getHash())); self::assertFalse(password_verify('testing', $user->getHash()));
$this->assertTrue(password_verify('newpassword', $user->getHash())); self::assertTrue(password_verify('newpassword', $user->getHash()));
} }
public function testExecute_DoesNotChangePasswordIfEmpty() public function testExecute_DoesNotChangePasswordIfEmpty()
@ -102,6 +102,6 @@ class UserServiceTest extends \PHPUnit\Framework\TestCase
$user->setHash(password_hash('testing', PASSWORD_DEFAULT)); $user->setHash(password_hash('testing', PASSWORD_DEFAULT));
$user = $this->testedService->updateUser($user, 'Test', 'test@example.com', '', 0); $user = $this->testedService->updateUser($user, 'Test', 'test@example.com', '', 0);
$this->assertTrue(password_verify('testing', $user->getHash())); self::assertTrue(password_verify('testing', $user->getHash()));
} }
} }