-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Igor Chepurnoy
committed
Jul 4, 2016
1 parent
3d1b6f3
commit 37eb490
Showing
9 changed files
with
211 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Ignore all test and documentation for archive | ||
/.gitattributes export-ignore | ||
/.gitignore export-ignore | ||
/.scrutinizer.yml export-ignore | ||
/.travis.yml export-ignore | ||
/phpunit.xml.dist export-ignore | ||
/tests export-ignore | ||
/docs export-ignore |
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,35 @@ | ||
# phpstorm project files | ||
.idea | ||
|
||
# netbeans project files | ||
nbproject | ||
|
||
# zend studio for eclipse project files | ||
.buildpath | ||
.project | ||
.settings | ||
|
||
# windows thumbnail cache | ||
Thumbs.db | ||
|
||
# composer vendor dir | ||
/vendor | ||
|
||
/composer.lock | ||
|
||
# composer itself is not needed | ||
composer.phar | ||
|
||
# Mac DS_Store Files | ||
.DS_Store | ||
|
||
# phpunit itself is not needed | ||
phpunit.phar | ||
# local phpunit config | ||
/phpunit.xml | ||
|
||
# local tests configuration | ||
/tests/data/config.local.php | ||
|
||
# runtime cache | ||
/tests/runtime |
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,32 @@ | ||
language: php | ||
|
||
php: | ||
- 5.4 | ||
- 5.5 | ||
- 5.6 | ||
- 7.0 | ||
- hhvm | ||
|
||
# run build against hhvm but allow them to fail | ||
# http://docs.travis-ci.com/user/build-configuration/#Rows-That-are-Allowed-To-Fail | ||
matrix: | ||
fast_finish: true | ||
allow_failures: | ||
- php: hhvm | ||
|
||
# faster builds on new travis setup not using sudo | ||
sudo: false | ||
|
||
# cache vendor dirs | ||
cache: | ||
directories: | ||
- $HOME/.composer/cache | ||
|
||
install: | ||
- travis_retry composer self-update && composer --version | ||
- travis_retry composer global require "fxp/composer-asset-plugin:~1.1.1" | ||
- export PATH="$HOME/.composer/vendor/bin:$PATH" | ||
- travis_retry composer install --prefer-dist --no-interaction | ||
|
||
script: | ||
- phpunit --verbose $PHPUNIT_FLAGS |
This file was deleted.
Oops, something went wrong.
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,13 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<phpunit bootstrap="./tests/bootstrap.php" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
stopOnFailure="false"> | ||
<testsuites> | ||
<testsuite name="Yii2tech Test Suite"> | ||
<directory>./tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |
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 | ||
|
||
namespace yii2mod\enum\tests; | ||
|
||
use yii2mod\enum\tests\data\BooleanEnum; | ||
|
||
/** | ||
* Class EnumTest | ||
* @package yii2mod\enum\tests | ||
*/ | ||
class EnumTest extends TestCase | ||
{ | ||
public function testEnumMethods() | ||
{ | ||
$this->assertEquals([1 => 'YES', 0 => 'NO'], BooleanEnum::getConstantsByValue()); | ||
$this->assertEquals(['YES' => 1, 'NO' => 0], BooleanEnum::getConstantsByName()); | ||
$this->assertEquals([1 => 'Yes', 0 => 'No'], BooleanEnum::listData()); | ||
$this->assertEquals('Yes', BooleanEnum::getLabel(1)); | ||
$this->assertEquals('1', BooleanEnum::getValueByName('Yes')); | ||
} | ||
|
||
public function testValidation() | ||
{ | ||
$this->assertFalse(BooleanEnum::isValidName(1)); | ||
$this->assertTrue(BooleanEnum::isValidName('YES')); | ||
$this->assertTrue(BooleanEnum::isValidValue(1)); | ||
$this->assertFalse(BooleanEnum::isValidValue('YES')); | ||
} | ||
} |
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,54 @@ | ||
<?php | ||
|
||
namespace yii2mod\enum\tests; | ||
|
||
use yii\helpers\ArrayHelper; | ||
use Yii; | ||
|
||
/** | ||
* This is the base class for all yii framework unit tests. | ||
*/ | ||
class TestCase extends \PHPUnit_Framework_TestCase | ||
{ | ||
protected function setUp() | ||
{ | ||
parent::setUp(); | ||
$this->mockApplication(); | ||
} | ||
|
||
protected function tearDown() | ||
{ | ||
$this->destroyApplication(); | ||
} | ||
|
||
/** | ||
* Populates Yii::$app with a new application | ||
* The application will be destroyed on tearDown() automatically. | ||
* @param array $config The application configuration, if needed | ||
* @param string $appClass name of the application class to create | ||
*/ | ||
protected function mockApplication($config = [], $appClass = '\yii\console\Application') | ||
{ | ||
new $appClass(ArrayHelper::merge([ | ||
'id' => 'testapp', | ||
'basePath' => __DIR__, | ||
'vendorPath' => $this->getVendorPath(), | ||
], $config)); | ||
} | ||
|
||
/** | ||
* @return string vendor path | ||
*/ | ||
protected function getVendorPath() | ||
{ | ||
return dirname(__DIR__) . '/vendor'; | ||
} | ||
|
||
/** | ||
* Destroys application in Yii::$app by setting it to null. | ||
*/ | ||
protected function destroyApplication() | ||
{ | ||
Yii::$app = null; | ||
} | ||
} |
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,13 @@ | ||
<?php | ||
|
||
// ensure we get report on all possible php errors | ||
error_reporting(-1); | ||
|
||
define('YII_ENABLE_ERROR_HANDLER', false); | ||
define('YII_DEBUG', true); | ||
|
||
$_SERVER['SCRIPT_NAME'] = '/' . __DIR__; | ||
$_SERVER['SCRIPT_FILENAME'] = __FILE__; | ||
|
||
require_once(__DIR__ . '/../vendor/autoload.php'); | ||
require_once(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php'); |
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,27 @@ | ||
<?php | ||
|
||
namespace yii2mod\enum\tests\data; | ||
|
||
use yii2mod\enum\helpers\BaseEnum; | ||
|
||
/** | ||
* Class BooleanEnum | ||
* @package yii2mod\enum\tests\data | ||
*/ | ||
class BooleanEnum extends BaseEnum | ||
{ | ||
const YES = 1; | ||
const NO = 0; | ||
|
||
/** | ||
* @var string message category | ||
* You can set your own message category for translate the values in the $list property | ||
* Values in the $list property will be automatically translated in the function `listData()` | ||
*/ | ||
public static $messageCategory = 'app'; | ||
|
||
public static $list = [ | ||
self::YES => 'Yes', | ||
self::NO => 'No' | ||
]; | ||
} |