-
Notifications
You must be signed in to change notification settings - Fork 312
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
#79 - Tests implementation
- Loading branch information
Showing
34 changed files
with
473 additions
and
11 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
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,43 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Invo\Tests\Functional\Forms; | ||
|
||
use Codeception\Test\Unit; | ||
use Invo\Forms\ProductTypesForm; | ||
use Phalcon\Di; | ||
use Phalcon\Filter; | ||
|
||
final class ProductTypesFormTest extends Unit | ||
{ | ||
public function inputDataProvider(): array | ||
{ | ||
$key = 'name'; | ||
|
||
return [ | ||
[[$key => 'string'], true], | ||
[[$key => '<h1>Title</h1>'], true], | ||
[[$key => 1], true], | ||
[[], false], | ||
]; | ||
} | ||
|
||
/** | ||
* @dataProvider inputDataProvider | ||
* | ||
* @param array $data | ||
* @param bool $expected | ||
*/ | ||
public function testValidation(array $data, bool $expected): void | ||
{ | ||
$di = new Di(); | ||
$di['filter'] = function () { | ||
return new Filter(); | ||
}; | ||
|
||
$form = new ProductTypesForm(); | ||
$form->setDI($di); | ||
|
||
$this->assertSame($expected, $form->isValid($data)); | ||
} | ||
} |
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,30 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Invo\Tests\Functional\Models; | ||
|
||
use Codeception\Test\Unit; | ||
use Invo\Models\Contact; | ||
use Phalcon\Db\RawValue; | ||
use Phalcon\Di; | ||
use Phalcon\Mvc\Model\Manager; | ||
|
||
final class ContactTest extends Unit | ||
{ | ||
public function testBeforeCreate(): void | ||
{ | ||
$di = new Di(); | ||
$di['modelsManager'] = function () { | ||
return new Manager(); | ||
}; | ||
|
||
$class = new Contact(); | ||
$class->setDI($di); | ||
$class->beforeCreate(); | ||
|
||
/** @var RawValue $raw */ | ||
$raw = $class->created_at; | ||
|
||
$this->assertSame('now()', $raw->__toString()); | ||
} | ||
} |
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,29 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Invo\Tests\Unit\Forms; | ||
|
||
use Codeception\Test\Unit; | ||
use Invo\Forms\CompaniesForm; | ||
use Phalcon\Forms\Element\Hidden; | ||
use Phalcon\Forms\Element\Text; | ||
use Phalcon\Forms\Form; | ||
|
||
final class CompaniesFormTest extends Unit | ||
{ | ||
public function testImplementation(): void | ||
{ | ||
$class = $this->createMock(CompaniesForm::class); | ||
|
||
$this->assertInstanceOf(Form::class, $class); | ||
} | ||
|
||
public function testIdElementType(): void | ||
{ | ||
$createForm = new CompaniesForm(); | ||
$editForm = new CompaniesForm(null, ['edit' => true]); | ||
|
||
$this->assertInstanceOf(Text::class, $createForm->getElements()['id']); | ||
$this->assertInstanceOf(Hidden::class, $editForm->getElements()['id']); | ||
} | ||
} |
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,18 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Invo\Tests\Unit\Forms; | ||
|
||
use Codeception\Test\Unit; | ||
use Invo\Forms\ContactForm; | ||
use Phalcon\Forms\Form; | ||
|
||
final class ContactFormTest extends Unit | ||
{ | ||
public function testImplementation(): void | ||
{ | ||
$class = $this->createMock(ContactForm::class); | ||
|
||
$this->assertInstanceOf(Form::class, $class); | ||
} | ||
} |
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,18 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Invo\Tests\Unit\Forms; | ||
|
||
use Codeception\Test\Unit; | ||
use Invo\Forms\ProductTypesForm; | ||
use Phalcon\Forms\Form; | ||
|
||
final class ProductTypesFormTest extends Unit | ||
{ | ||
public function testImplementation(): void | ||
{ | ||
$class = $this->createMock(ProductTypesForm::class); | ||
|
||
$this->assertInstanceOf(Form::class, $class); | ||
} | ||
} |
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,18 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Invo\Tests\Unit\Forms; | ||
|
||
use Codeception\Test\Unit; | ||
use Invo\Forms\ProductsForm; | ||
use Phalcon\Forms\Form; | ||
|
||
final class ProductsFormTest extends Unit | ||
{ | ||
public function testImplementation(): void | ||
{ | ||
$class = $this->createMock(ProductsForm::class); | ||
|
||
$this->assertInstanceOf(Form::class, $class); | ||
} | ||
} |
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,18 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Invo\Tests\Unit\Forms; | ||
|
||
use Codeception\Test\Unit; | ||
use Invo\Forms\RegisterForm; | ||
use Phalcon\Forms\Form; | ||
|
||
final class RegisterFormTest extends Unit | ||
{ | ||
public function testImplementation(): void | ||
{ | ||
$class = $this->createMock(RegisterForm::class); | ||
|
||
$this->assertInstanceOf(Form::class, $class); | ||
} | ||
} |
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,18 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Invo\Tests\Unit\Models; | ||
|
||
use Codeception\Test\Unit; | ||
use Invo\Models\Companies; | ||
use Phalcon\Mvc\Model; | ||
|
||
final class CompaniesTest extends Unit | ||
{ | ||
public function testImplementation(): void | ||
{ | ||
$class = $this->createMock(Companies::class); | ||
|
||
$this->assertInstanceOf(Model::class, $class); | ||
} | ||
} |
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,18 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Invo\Tests\Unit\Models; | ||
|
||
use Codeception\Test\Unit; | ||
use Invo\Models\Contact; | ||
use Phalcon\Mvc\Model; | ||
|
||
final class ContactTest extends Unit | ||
{ | ||
public function testImplementation(): void | ||
{ | ||
$class = $this->createMock(Contact::class); | ||
|
||
$this->assertInstanceOf(Model::class, $class); | ||
} | ||
} |
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,18 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Invo\Tests\Unit\Models; | ||
|
||
use Codeception\Test\Unit; | ||
use Invo\Models\ProductTypes; | ||
use Phalcon\Mvc\Model; | ||
|
||
final class ProductTypesTest extends Unit | ||
{ | ||
public function testImplementation(): void | ||
{ | ||
$class = $this->createMock(ProductTypes::class); | ||
|
||
$this->assertInstanceOf(Model::class, $class); | ||
} | ||
} |
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,18 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Invo\Tests\Unit\Models; | ||
|
||
use Codeception\Test\Unit; | ||
use Invo\Models\Products; | ||
use Phalcon\Mvc\Model; | ||
|
||
final class ProductsTest extends Unit | ||
{ | ||
public function testImplementation(): void | ||
{ | ||
$class = $this->createMock(Products::class); | ||
|
||
$this->assertInstanceOf(Model::class, $class); | ||
} | ||
} |
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,18 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Invo\Tests\Unit\Models; | ||
|
||
use Codeception\Test\Unit; | ||
use Invo\Models\Users; | ||
use Phalcon\Mvc\Model; | ||
|
||
final class UsersTest extends Unit | ||
{ | ||
public function testImplementation(): void | ||
{ | ||
$class = $this->createMock(Users::class); | ||
|
||
$this->assertInstanceOf(Model::class, $class); | ||
} | ||
} |
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,18 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Invo\Tests\Unit\Plugins; | ||
|
||
use Codeception\Test\Unit; | ||
use Invo\Plugins\NotFoundPlugin; | ||
use Phalcon\Di\Injectable; | ||
|
||
final class NotFoundPluginTest extends Unit | ||
{ | ||
public function testImplementation(): void | ||
{ | ||
$class = $this->createMock(NotFoundPlugin::class); | ||
|
||
$this->assertInstanceOf(Injectable::class, $class); | ||
} | ||
} |
Oops, something went wrong.