Added Yiistrap
This commit is contained in:
14
www/protected/extensions/bootstrap/tests/_bootstrap.php
Normal file
14
www/protected/extensions/bootstrap/tests/_bootstrap.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
// This is global bootstrap for autoloading
|
||||
|
||||
// disable Yii error handling logic
|
||||
defined('YII_ENABLE_EXCEPTION_HANDLER') or define('YII_ENABLE_EXCEPTION_HANDLER', false);
|
||||
defined('YII_ENABLE_ERROR_HANDLER') or define('YII_ENABLE_ERROR_HANDLER', false);
|
||||
defined('YII_DEBUG') or define('YII_DEBUG', true);
|
||||
$_SERVER['SCRIPT_NAME'] = '/' . __DIR__;
|
||||
$_SERVER['SCRIPT_FILENAME'] = __FILE__;
|
||||
|
||||
require(__DIR__ . '/../vendor/yiisoft/yii/framework/yii.php');
|
||||
require(__DIR__ . '/unit/TbTestCase.php');
|
||||
|
||||
Yii::$enableIncludePath = false;
|
||||
1
www/protected/extensions/bootstrap/tests/_data/dump.sql
Normal file
1
www/protected/extensions/bootstrap/tests/_data/dump.sql
Normal file
@@ -0,0 +1 @@
|
||||
/* Replace this file with actual dump of your database */
|
||||
217
www/protected/extensions/bootstrap/tests/_helpers/CodeHelper.php
Normal file
217
www/protected/extensions/bootstrap/tests/_helpers/CodeHelper.php
Normal file
@@ -0,0 +1,217 @@
|
||||
<?php
|
||||
namespace Codeception\Module;
|
||||
|
||||
class CodeHelper extends \Codeception\Module
|
||||
{
|
||||
/**
|
||||
* @param \Symfony\Component\DomCrawler\Crawler $node
|
||||
* @param string $text
|
||||
*/
|
||||
public function seeNodeText($node, $text)
|
||||
{
|
||||
$this->assertTrue(strpos($node->text(), $text) !== false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Symfony\Component\DomCrawler\Crawler $node
|
||||
* @param $pattern $text
|
||||
*/
|
||||
public function seeNodePattern($node, $pattern)
|
||||
{
|
||||
$this->assertEquals(1, preg_match($pattern, $node->html()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Symfony\Component\DomCrawler\Crawler $node
|
||||
*/
|
||||
public function seeNodeEmpty($node)
|
||||
{
|
||||
$this->assertEquals('', $node->text());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Symfony\Component\DomCrawler\Crawler $node
|
||||
* @param mixed $cssClass
|
||||
*/
|
||||
public function seeNodeCssClass($node, $cssClass)
|
||||
{
|
||||
if (is_string($cssClass)) {
|
||||
$cssClass = explode(' ', $cssClass);
|
||||
}
|
||||
foreach ($cssClass as $className) {
|
||||
$this->assertTrue(in_array($className, explode(' ', $node->attr('class'))));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Symfony\Component\DomCrawler\Crawler $node
|
||||
* @param mixed $cssClass
|
||||
*/
|
||||
public function dontSeeNodeCssClass($node, $cssClass)
|
||||
{
|
||||
if (is_string($cssClass)) {
|
||||
$cssClass = explode(' ', $cssClass);
|
||||
}
|
||||
foreach ($cssClass as $className) {
|
||||
$this->assertFalse(in_array($className, explode(' ', $node->attr('class'))));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Symfony\Component\DomCrawler\Crawler $node
|
||||
* @param string $cssStyle
|
||||
*/
|
||||
public function seeNodeCssStyle($node, $cssStyle)
|
||||
{
|
||||
if (is_string($cssStyle)) {
|
||||
$cssStyle = explode(';', rtrim($cssStyle, ';'));
|
||||
}
|
||||
$cssStyle = $this->normalizeCssStyle($cssStyle);
|
||||
foreach ($cssStyle as $style) {
|
||||
$this->assertTrue(strpos($node->attr('style'), $style) !== false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $cssStyle
|
||||
* @return array
|
||||
*/
|
||||
protected function normalizeCssStyle(array $cssStyle)
|
||||
{
|
||||
array_walk(
|
||||
$cssStyle,
|
||||
function (&$value) {
|
||||
$value = trim($value);
|
||||
}
|
||||
);
|
||||
return $cssStyle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Symfony\Component\DomCrawler\Crawler $node
|
||||
* @param string $cssStyle
|
||||
*/
|
||||
public function dontSeeNodeCssStyle($node, $cssStyle)
|
||||
{
|
||||
if (is_string($cssStyle)) {
|
||||
$cssStyle = explode(';', rtrim($cssStyle, ';'));
|
||||
}
|
||||
$cssStyle = $this->normalizeCssStyle($cssStyle);
|
||||
foreach ($cssStyle as $style) {
|
||||
$this->assertFalse(strpos($node->attr('style'), $style));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Symfony\Component\DomCrawler\Crawler $node
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
*/
|
||||
public function seeNodeAttribute($node, $name, $value = null)
|
||||
{
|
||||
$attr = $node->attr($name);
|
||||
$this->assertTrue($attr !== null);
|
||||
if ($value !== null) {
|
||||
$this->assertEquals($value, $attr);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Symfony\Component\DomCrawler\Crawler $node
|
||||
* @param array $name
|
||||
*/
|
||||
public function dontSeeNodeAttribute($node, $name)
|
||||
{
|
||||
$this->assertEquals('', $node->attr($name));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Symfony\Component\DomCrawler\Crawler $node
|
||||
* @param array $attributes
|
||||
*/
|
||||
public function seeNodeAttributes($node, array $attributes)
|
||||
{
|
||||
foreach ($attributes as $name => $value) {
|
||||
$this->seeNodeAttribute($node, $name, $value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Symfony\Component\DomCrawler\Crawler $node
|
||||
* @param array $attributes
|
||||
*/
|
||||
public function dontSeeNodeAttributes($node, array $attributes)
|
||||
{
|
||||
foreach ($attributes as $name) {
|
||||
$this->dontSeeNodeAttribute($node, $name);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Symfony\Component\DomCrawler\Crawler $node
|
||||
* @param array $elements
|
||||
*/
|
||||
public function seeNodeChildren($node, array $elements)
|
||||
{
|
||||
/** @var \DomElement $child */
|
||||
foreach ($node->children() as $i => $child) {
|
||||
if (isset($elements[$i])) {
|
||||
$this->assertTrue($this->nodeMatchesCssSelector($child, $elements[$i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Symfony\Component\DomCrawler\Crawler $node
|
||||
* @param array $elements
|
||||
*/
|
||||
public function dontSeeNodeChildren($node, array $elements)
|
||||
{
|
||||
/** @var \DomElement $child */
|
||||
foreach ($node->children() as $i => $child) {
|
||||
if (isset($elements[$i])) {
|
||||
$this->assertFalse($this->nodeMatchesCssSelector($child, $elements[$i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Symfony\Component\DomCrawler\Crawler $node
|
||||
* @param integer $amount
|
||||
*/
|
||||
public function seeNodeNumChildren($node, $amount, $filter = null)
|
||||
{
|
||||
$count = $filter !== null ? $node->filter($filter)->count() : $node->children()->count();
|
||||
$this->assertEquals($amount, $count);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DomElement $node
|
||||
* @param string $selector
|
||||
* @return boolean
|
||||
*/
|
||||
protected function nodeMatchesCssSelector($node, $selector)
|
||||
{
|
||||
if ($node->parentNode === null) {
|
||||
return false;
|
||||
}
|
||||
$crawler = $this->createNode($node->parentNode);
|
||||
return count($crawler->filter($selector)) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $content
|
||||
* @param string $filter
|
||||
* @return \Symfony\Component\DomCrawler\Crawler
|
||||
*/
|
||||
public function createNode($content, $filter = null)
|
||||
{
|
||||
$crawler = new \Symfony\Component\DomCrawler\Crawler($content);
|
||||
if ($filter !== null) {
|
||||
$node = $crawler->filter($filter);
|
||||
$this->assertNotEquals(null, $node);
|
||||
return $node;
|
||||
}
|
||||
return $crawler;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
namespace Codeception\Module;
|
||||
|
||||
// here you can define custom functions for TestGuy
|
||||
|
||||
class TestHelper extends \Codeception\Module
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
namespace Codeception\Module;
|
||||
|
||||
// here you can define custom functions for WebGuy
|
||||
|
||||
class WebHelper extends \Codeception\Module
|
||||
{
|
||||
}
|
||||
8
www/protected/extensions/bootstrap/tests/unit.suite.yml
Normal file
8
www/protected/extensions/bootstrap/tests/unit.suite.yml
Normal file
@@ -0,0 +1,8 @@
|
||||
# Codeception Test Suite Configuration
|
||||
|
||||
# suite for unit (internal) tests.
|
||||
# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES.
|
||||
|
||||
class_name: CodeGuy
|
||||
modules:
|
||||
enabled: [CodeHelper]
|
||||
595
www/protected/extensions/bootstrap/tests/unit/CodeGuy.php
Normal file
595
www/protected/extensions/bootstrap/tests/unit/CodeGuy.php
Normal file
@@ -0,0 +1,595 @@
|
||||
<?php
|
||||
// This class was automatically generated by build task
|
||||
// You should not change it manually as it will be overwritten on next build
|
||||
// @codingStandardsIgnoreFile
|
||||
|
||||
|
||||
use \Codeception\Maybe;
|
||||
use Codeception\Module\CodeHelper;
|
||||
|
||||
/**
|
||||
* Inherited methods
|
||||
* @method void execute($callable)
|
||||
* @method void wantToTest($text)
|
||||
* @method void wantTo($text)
|
||||
* @method void expectTo($prediction)
|
||||
* @method void expect($prediction)
|
||||
* @method void amGoingTo($argumentation)
|
||||
* @method void am($role)
|
||||
* @method void lookForwardTo($achieveValue)
|
||||
* @method void offsetGet($offset)
|
||||
* @method void offsetSet($offset, $value)
|
||||
* @method void offsetExists($offset)
|
||||
* @method void offsetUnset($offset)
|
||||
*/
|
||||
|
||||
class CodeGuy extends \Codeception\AbstractGuy
|
||||
{
|
||||
|
||||
/**
|
||||
* This method is generated.
|
||||
* Documentation taken from corresponding module.
|
||||
* ----------------------------------------------
|
||||
*
|
||||
* @param \Symfony\Component\DomCrawler\Crawler $node
|
||||
* @param string $text
|
||||
* Conditional Assertion: Test won't be stopped on fail
|
||||
* @see Codeception\Module\CodeHelper::seeNodeText()
|
||||
* @return \Codeception\Maybe
|
||||
*/
|
||||
public function canSeeNodeText($node, $text) {
|
||||
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('seeNodeText', func_get_args()));
|
||||
if ($this->scenario->running()) {
|
||||
$result = $this->scenario->runStep();
|
||||
return new Maybe($result);
|
||||
}
|
||||
return new Maybe();
|
||||
}
|
||||
/**
|
||||
* This method is generated.
|
||||
* Documentation taken from corresponding module.
|
||||
* ----------------------------------------------
|
||||
*
|
||||
* @param \Symfony\Component\DomCrawler\Crawler $node
|
||||
* @param string $text
|
||||
* @see Codeception\Module\CodeHelper::seeNodeText()
|
||||
* @return \Codeception\Maybe
|
||||
*/
|
||||
public function seeNodeText($node, $text) {
|
||||
$this->scenario->addStep(new \Codeception\Step\Assertion('seeNodeText', func_get_args()));
|
||||
if ($this->scenario->running()) {
|
||||
$result = $this->scenario->runStep();
|
||||
return new Maybe($result);
|
||||
}
|
||||
return new Maybe();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method is generated.
|
||||
* Documentation taken from corresponding module.
|
||||
* ----------------------------------------------
|
||||
*
|
||||
* @param \Symfony\Component\DomCrawler\Crawler $node
|
||||
* @param $pattern $text
|
||||
* Conditional Assertion: Test won't be stopped on fail
|
||||
* @see Codeception\Module\CodeHelper::seeNodePattern()
|
||||
* @return \Codeception\Maybe
|
||||
*/
|
||||
public function canSeeNodePattern($node, $pattern) {
|
||||
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('seeNodePattern', func_get_args()));
|
||||
if ($this->scenario->running()) {
|
||||
$result = $this->scenario->runStep();
|
||||
return new Maybe($result);
|
||||
}
|
||||
return new Maybe();
|
||||
}
|
||||
/**
|
||||
* This method is generated.
|
||||
* Documentation taken from corresponding module.
|
||||
* ----------------------------------------------
|
||||
*
|
||||
* @param \Symfony\Component\DomCrawler\Crawler $node
|
||||
* @param $pattern $text
|
||||
* @see Codeception\Module\CodeHelper::seeNodePattern()
|
||||
* @return \Codeception\Maybe
|
||||
*/
|
||||
public function seeNodePattern($node, $pattern) {
|
||||
$this->scenario->addStep(new \Codeception\Step\Assertion('seeNodePattern', func_get_args()));
|
||||
if ($this->scenario->running()) {
|
||||
$result = $this->scenario->runStep();
|
||||
return new Maybe($result);
|
||||
}
|
||||
return new Maybe();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method is generated.
|
||||
* Documentation taken from corresponding module.
|
||||
* ----------------------------------------------
|
||||
*
|
||||
* @param \Symfony\Component\DomCrawler\Crawler $node
|
||||
* Conditional Assertion: Test won't be stopped on fail
|
||||
* @see Codeception\Module\CodeHelper::seeNodeEmpty()
|
||||
* @return \Codeception\Maybe
|
||||
*/
|
||||
public function canSeeNodeEmpty($node) {
|
||||
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('seeNodeEmpty', func_get_args()));
|
||||
if ($this->scenario->running()) {
|
||||
$result = $this->scenario->runStep();
|
||||
return new Maybe($result);
|
||||
}
|
||||
return new Maybe();
|
||||
}
|
||||
/**
|
||||
* This method is generated.
|
||||
* Documentation taken from corresponding module.
|
||||
* ----------------------------------------------
|
||||
*
|
||||
* @param \Symfony\Component\DomCrawler\Crawler $node
|
||||
* @see Codeception\Module\CodeHelper::seeNodeEmpty()
|
||||
* @return \Codeception\Maybe
|
||||
*/
|
||||
public function seeNodeEmpty($node) {
|
||||
$this->scenario->addStep(new \Codeception\Step\Assertion('seeNodeEmpty', func_get_args()));
|
||||
if ($this->scenario->running()) {
|
||||
$result = $this->scenario->runStep();
|
||||
return new Maybe($result);
|
||||
}
|
||||
return new Maybe();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method is generated.
|
||||
* Documentation taken from corresponding module.
|
||||
* ----------------------------------------------
|
||||
*
|
||||
* @param \Symfony\Component\DomCrawler\Crawler $node
|
||||
* @param mixed $cssClass
|
||||
* Conditional Assertion: Test won't be stopped on fail
|
||||
* @see Codeception\Module\CodeHelper::seeNodeCssClass()
|
||||
* @return \Codeception\Maybe
|
||||
*/
|
||||
public function canSeeNodeCssClass($node, $cssClass) {
|
||||
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('seeNodeCssClass', func_get_args()));
|
||||
if ($this->scenario->running()) {
|
||||
$result = $this->scenario->runStep();
|
||||
return new Maybe($result);
|
||||
}
|
||||
return new Maybe();
|
||||
}
|
||||
/**
|
||||
* This method is generated.
|
||||
* Documentation taken from corresponding module.
|
||||
* ----------------------------------------------
|
||||
*
|
||||
* @param \Symfony\Component\DomCrawler\Crawler $node
|
||||
* @param mixed $cssClass
|
||||
* @see Codeception\Module\CodeHelper::seeNodeCssClass()
|
||||
* @return \Codeception\Maybe
|
||||
*/
|
||||
public function seeNodeCssClass($node, $cssClass) {
|
||||
$this->scenario->addStep(new \Codeception\Step\Assertion('seeNodeCssClass', func_get_args()));
|
||||
if ($this->scenario->running()) {
|
||||
$result = $this->scenario->runStep();
|
||||
return new Maybe($result);
|
||||
}
|
||||
return new Maybe();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method is generated.
|
||||
* Documentation taken from corresponding module.
|
||||
* ----------------------------------------------
|
||||
*
|
||||
* @param \Symfony\Component\DomCrawler\Crawler $node
|
||||
* @param mixed $cssClass
|
||||
* Conditional Assertion: Test won't be stopped on fail
|
||||
* @see Codeception\Module\CodeHelper::dontSeeNodeCssClass()
|
||||
* @return \Codeception\Maybe
|
||||
*/
|
||||
public function cantSeeNodeCssClass($node, $cssClass) {
|
||||
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('dontSeeNodeCssClass', func_get_args()));
|
||||
if ($this->scenario->running()) {
|
||||
$result = $this->scenario->runStep();
|
||||
return new Maybe($result);
|
||||
}
|
||||
return new Maybe();
|
||||
}
|
||||
/**
|
||||
* This method is generated.
|
||||
* Documentation taken from corresponding module.
|
||||
* ----------------------------------------------
|
||||
*
|
||||
* @param \Symfony\Component\DomCrawler\Crawler $node
|
||||
* @param mixed $cssClass
|
||||
* @see Codeception\Module\CodeHelper::dontSeeNodeCssClass()
|
||||
* @return \Codeception\Maybe
|
||||
*/
|
||||
public function dontSeeNodeCssClass($node, $cssClass) {
|
||||
$this->scenario->addStep(new \Codeception\Step\Assertion('dontSeeNodeCssClass', func_get_args()));
|
||||
if ($this->scenario->running()) {
|
||||
$result = $this->scenario->runStep();
|
||||
return new Maybe($result);
|
||||
}
|
||||
return new Maybe();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method is generated.
|
||||
* Documentation taken from corresponding module.
|
||||
* ----------------------------------------------
|
||||
*
|
||||
* @param \Symfony\Component\DomCrawler\Crawler $node
|
||||
* @param string $cssStyle
|
||||
* Conditional Assertion: Test won't be stopped on fail
|
||||
* @see Codeception\Module\CodeHelper::seeNodeCssStyle()
|
||||
* @return \Codeception\Maybe
|
||||
*/
|
||||
public function canSeeNodeCssStyle($node, $cssStyle) {
|
||||
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('seeNodeCssStyle', func_get_args()));
|
||||
if ($this->scenario->running()) {
|
||||
$result = $this->scenario->runStep();
|
||||
return new Maybe($result);
|
||||
}
|
||||
return new Maybe();
|
||||
}
|
||||
/**
|
||||
* This method is generated.
|
||||
* Documentation taken from corresponding module.
|
||||
* ----------------------------------------------
|
||||
*
|
||||
* @param \Symfony\Component\DomCrawler\Crawler $node
|
||||
* @param string $cssStyle
|
||||
* @see Codeception\Module\CodeHelper::seeNodeCssStyle()
|
||||
* @return \Codeception\Maybe
|
||||
*/
|
||||
public function seeNodeCssStyle($node, $cssStyle) {
|
||||
$this->scenario->addStep(new \Codeception\Step\Assertion('seeNodeCssStyle', func_get_args()));
|
||||
if ($this->scenario->running()) {
|
||||
$result = $this->scenario->runStep();
|
||||
return new Maybe($result);
|
||||
}
|
||||
return new Maybe();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method is generated.
|
||||
* Documentation taken from corresponding module.
|
||||
* ----------------------------------------------
|
||||
*
|
||||
* @param \Symfony\Component\DomCrawler\Crawler $node
|
||||
* @param string $cssStyle
|
||||
* Conditional Assertion: Test won't be stopped on fail
|
||||
* @see Codeception\Module\CodeHelper::dontSeeNodeCssStyle()
|
||||
* @return \Codeception\Maybe
|
||||
*/
|
||||
public function cantSeeNodeCssStyle($node, $cssStyle) {
|
||||
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('dontSeeNodeCssStyle', func_get_args()));
|
||||
if ($this->scenario->running()) {
|
||||
$result = $this->scenario->runStep();
|
||||
return new Maybe($result);
|
||||
}
|
||||
return new Maybe();
|
||||
}
|
||||
/**
|
||||
* This method is generated.
|
||||
* Documentation taken from corresponding module.
|
||||
* ----------------------------------------------
|
||||
*
|
||||
* @param \Symfony\Component\DomCrawler\Crawler $node
|
||||
* @param string $cssStyle
|
||||
* @see Codeception\Module\CodeHelper::dontSeeNodeCssStyle()
|
||||
* @return \Codeception\Maybe
|
||||
*/
|
||||
public function dontSeeNodeCssStyle($node, $cssStyle) {
|
||||
$this->scenario->addStep(new \Codeception\Step\Assertion('dontSeeNodeCssStyle', func_get_args()));
|
||||
if ($this->scenario->running()) {
|
||||
$result = $this->scenario->runStep();
|
||||
return new Maybe($result);
|
||||
}
|
||||
return new Maybe();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method is generated.
|
||||
* Documentation taken from corresponding module.
|
||||
* ----------------------------------------------
|
||||
*
|
||||
* @param \Symfony\Component\DomCrawler\Crawler $node
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
* Conditional Assertion: Test won't be stopped on fail
|
||||
* @see Codeception\Module\CodeHelper::seeNodeAttribute()
|
||||
* @return \Codeception\Maybe
|
||||
*/
|
||||
public function canSeeNodeAttribute($node, $name, $value = null) {
|
||||
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('seeNodeAttribute', func_get_args()));
|
||||
if ($this->scenario->running()) {
|
||||
$result = $this->scenario->runStep();
|
||||
return new Maybe($result);
|
||||
}
|
||||
return new Maybe();
|
||||
}
|
||||
/**
|
||||
* This method is generated.
|
||||
* Documentation taken from corresponding module.
|
||||
* ----------------------------------------------
|
||||
*
|
||||
* @param \Symfony\Component\DomCrawler\Crawler $node
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
* @see Codeception\Module\CodeHelper::seeNodeAttribute()
|
||||
* @return \Codeception\Maybe
|
||||
*/
|
||||
public function seeNodeAttribute($node, $name, $value = null) {
|
||||
$this->scenario->addStep(new \Codeception\Step\Assertion('seeNodeAttribute', func_get_args()));
|
||||
if ($this->scenario->running()) {
|
||||
$result = $this->scenario->runStep();
|
||||
return new Maybe($result);
|
||||
}
|
||||
return new Maybe();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method is generated.
|
||||
* Documentation taken from corresponding module.
|
||||
* ----------------------------------------------
|
||||
*
|
||||
* @param \Symfony\Component\DomCrawler\Crawler $node
|
||||
* @param array $name
|
||||
* Conditional Assertion: Test won't be stopped on fail
|
||||
* @see Codeception\Module\CodeHelper::dontSeeNodeAttribute()
|
||||
* @return \Codeception\Maybe
|
||||
*/
|
||||
public function cantSeeNodeAttribute($node, $name) {
|
||||
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('dontSeeNodeAttribute', func_get_args()));
|
||||
if ($this->scenario->running()) {
|
||||
$result = $this->scenario->runStep();
|
||||
return new Maybe($result);
|
||||
}
|
||||
return new Maybe();
|
||||
}
|
||||
/**
|
||||
* This method is generated.
|
||||
* Documentation taken from corresponding module.
|
||||
* ----------------------------------------------
|
||||
*
|
||||
* @param \Symfony\Component\DomCrawler\Crawler $node
|
||||
* @param array $name
|
||||
* @see Codeception\Module\CodeHelper::dontSeeNodeAttribute()
|
||||
* @return \Codeception\Maybe
|
||||
*/
|
||||
public function dontSeeNodeAttribute($node, $name) {
|
||||
$this->scenario->addStep(new \Codeception\Step\Assertion('dontSeeNodeAttribute', func_get_args()));
|
||||
if ($this->scenario->running()) {
|
||||
$result = $this->scenario->runStep();
|
||||
return new Maybe($result);
|
||||
}
|
||||
return new Maybe();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method is generated.
|
||||
* Documentation taken from corresponding module.
|
||||
* ----------------------------------------------
|
||||
*
|
||||
* @param \Symfony\Component\DomCrawler\Crawler $node
|
||||
* @param array $attributes
|
||||
* Conditional Assertion: Test won't be stopped on fail
|
||||
* @see Codeception\Module\CodeHelper::seeNodeAttributes()
|
||||
* @return \Codeception\Maybe
|
||||
*/
|
||||
public function canSeeNodeAttributes($node, $attributes) {
|
||||
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('seeNodeAttributes', func_get_args()));
|
||||
if ($this->scenario->running()) {
|
||||
$result = $this->scenario->runStep();
|
||||
return new Maybe($result);
|
||||
}
|
||||
return new Maybe();
|
||||
}
|
||||
/**
|
||||
* This method is generated.
|
||||
* Documentation taken from corresponding module.
|
||||
* ----------------------------------------------
|
||||
*
|
||||
* @param \Symfony\Component\DomCrawler\Crawler $node
|
||||
* @param array $attributes
|
||||
* @see Codeception\Module\CodeHelper::seeNodeAttributes()
|
||||
* @return \Codeception\Maybe
|
||||
*/
|
||||
public function seeNodeAttributes($node, $attributes) {
|
||||
$this->scenario->addStep(new \Codeception\Step\Assertion('seeNodeAttributes', func_get_args()));
|
||||
if ($this->scenario->running()) {
|
||||
$result = $this->scenario->runStep();
|
||||
return new Maybe($result);
|
||||
}
|
||||
return new Maybe();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method is generated.
|
||||
* Documentation taken from corresponding module.
|
||||
* ----------------------------------------------
|
||||
*
|
||||
* @param \Symfony\Component\DomCrawler\Crawler $node
|
||||
* @param array $attributes
|
||||
* Conditional Assertion: Test won't be stopped on fail
|
||||
* @see Codeception\Module\CodeHelper::dontSeeNodeAttributes()
|
||||
* @return \Codeception\Maybe
|
||||
*/
|
||||
public function cantSeeNodeAttributes($node, $attributes) {
|
||||
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('dontSeeNodeAttributes', func_get_args()));
|
||||
if ($this->scenario->running()) {
|
||||
$result = $this->scenario->runStep();
|
||||
return new Maybe($result);
|
||||
}
|
||||
return new Maybe();
|
||||
}
|
||||
/**
|
||||
* This method is generated.
|
||||
* Documentation taken from corresponding module.
|
||||
* ----------------------------------------------
|
||||
*
|
||||
* @param \Symfony\Component\DomCrawler\Crawler $node
|
||||
* @param array $attributes
|
||||
* @see Codeception\Module\CodeHelper::dontSeeNodeAttributes()
|
||||
* @return \Codeception\Maybe
|
||||
*/
|
||||
public function dontSeeNodeAttributes($node, $attributes) {
|
||||
$this->scenario->addStep(new \Codeception\Step\Assertion('dontSeeNodeAttributes', func_get_args()));
|
||||
if ($this->scenario->running()) {
|
||||
$result = $this->scenario->runStep();
|
||||
return new Maybe($result);
|
||||
}
|
||||
return new Maybe();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method is generated.
|
||||
* Documentation taken from corresponding module.
|
||||
* ----------------------------------------------
|
||||
*
|
||||
* @param \Symfony\Component\DomCrawler\Crawler $node
|
||||
* @param array $elements
|
||||
* Conditional Assertion: Test won't be stopped on fail
|
||||
* @see Codeception\Module\CodeHelper::seeNodeChildren()
|
||||
* @return \Codeception\Maybe
|
||||
*/
|
||||
public function canSeeNodeChildren($node, $elements) {
|
||||
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('seeNodeChildren', func_get_args()));
|
||||
if ($this->scenario->running()) {
|
||||
$result = $this->scenario->runStep();
|
||||
return new Maybe($result);
|
||||
}
|
||||
return new Maybe();
|
||||
}
|
||||
/**
|
||||
* This method is generated.
|
||||
* Documentation taken from corresponding module.
|
||||
* ----------------------------------------------
|
||||
*
|
||||
* @param \Symfony\Component\DomCrawler\Crawler $node
|
||||
* @param array $elements
|
||||
* @see Codeception\Module\CodeHelper::seeNodeChildren()
|
||||
* @return \Codeception\Maybe
|
||||
*/
|
||||
public function seeNodeChildren($node, $elements) {
|
||||
$this->scenario->addStep(new \Codeception\Step\Assertion('seeNodeChildren', func_get_args()));
|
||||
if ($this->scenario->running()) {
|
||||
$result = $this->scenario->runStep();
|
||||
return new Maybe($result);
|
||||
}
|
||||
return new Maybe();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method is generated.
|
||||
* Documentation taken from corresponding module.
|
||||
* ----------------------------------------------
|
||||
*
|
||||
* @param \Symfony\Component\DomCrawler\Crawler $node
|
||||
* @param array $elements
|
||||
* Conditional Assertion: Test won't be stopped on fail
|
||||
* @see Codeception\Module\CodeHelper::dontSeeNodeChildren()
|
||||
* @return \Codeception\Maybe
|
||||
*/
|
||||
public function cantSeeNodeChildren($node, $elements) {
|
||||
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('dontSeeNodeChildren', func_get_args()));
|
||||
if ($this->scenario->running()) {
|
||||
$result = $this->scenario->runStep();
|
||||
return new Maybe($result);
|
||||
}
|
||||
return new Maybe();
|
||||
}
|
||||
/**
|
||||
* This method is generated.
|
||||
* Documentation taken from corresponding module.
|
||||
* ----------------------------------------------
|
||||
*
|
||||
* @param \Symfony\Component\DomCrawler\Crawler $node
|
||||
* @param array $elements
|
||||
* @see Codeception\Module\CodeHelper::dontSeeNodeChildren()
|
||||
* @return \Codeception\Maybe
|
||||
*/
|
||||
public function dontSeeNodeChildren($node, $elements) {
|
||||
$this->scenario->addStep(new \Codeception\Step\Assertion('dontSeeNodeChildren', func_get_args()));
|
||||
if ($this->scenario->running()) {
|
||||
$result = $this->scenario->runStep();
|
||||
return new Maybe($result);
|
||||
}
|
||||
return new Maybe();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method is generated.
|
||||
* Documentation taken from corresponding module.
|
||||
* ----------------------------------------------
|
||||
*
|
||||
* @param \Symfony\Component\DomCrawler\Crawler $node
|
||||
* @param integer $amount
|
||||
* Conditional Assertion: Test won't be stopped on fail
|
||||
* @see Codeception\Module\CodeHelper::seeNodeNumChildren()
|
||||
* @return \Codeception\Maybe
|
||||
*/
|
||||
public function canSeeNodeNumChildren($node, $amount) {
|
||||
$this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('seeNodeNumChildren', func_get_args()));
|
||||
if ($this->scenario->running()) {
|
||||
$result = $this->scenario->runStep();
|
||||
return new Maybe($result);
|
||||
}
|
||||
return new Maybe();
|
||||
}
|
||||
/**
|
||||
* This method is generated.
|
||||
* Documentation taken from corresponding module.
|
||||
* ----------------------------------------------
|
||||
*
|
||||
* @param \Symfony\Component\DomCrawler\Crawler $node
|
||||
* @param integer $amount
|
||||
* @see Codeception\Module\CodeHelper::seeNodeNumChildren()
|
||||
* @return \Codeception\Maybe
|
||||
*/
|
||||
public function seeNodeNumChildren($node, $amount) {
|
||||
$this->scenario->addStep(new \Codeception\Step\Assertion('seeNodeNumChildren', func_get_args()));
|
||||
if ($this->scenario->running()) {
|
||||
$result = $this->scenario->runStep();
|
||||
return new Maybe($result);
|
||||
}
|
||||
return new Maybe();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method is generated.
|
||||
* Documentation taken from corresponding module.
|
||||
* ----------------------------------------------
|
||||
*
|
||||
* @param mixed $content
|
||||
* @param string $filter
|
||||
* @return \Symfony\Component\DomCrawler\Crawler
|
||||
* @see Codeception\Module\CodeHelper::createNode()
|
||||
* @return \Codeception\Maybe
|
||||
*/
|
||||
public function createNode($content, $filter = null) {
|
||||
$this->scenario->addStep(new \Codeception\Step\Action('createNode', func_get_args()));
|
||||
if ($this->scenario->running()) {
|
||||
$result = $this->scenario->runStep();
|
||||
return new Maybe($result);
|
||||
}
|
||||
return new Maybe();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
use Codeception\Util\Stub;
|
||||
|
||||
require(__DIR__ . '/../../helpers/TbArray.php');
|
||||
|
||||
class TbArrayTest extends TbTestCase
|
||||
{
|
||||
/**
|
||||
* @var \CodeGuy
|
||||
*/
|
||||
protected $codeGuy;
|
||||
|
||||
public function testGetValue()
|
||||
{
|
||||
$array = array('key' => 'value');
|
||||
$this->assertEquals('value', TbArray::getValue('key', $array));
|
||||
}
|
||||
|
||||
public function testPopValue()
|
||||
{
|
||||
$array = array('key' => 'value');
|
||||
$this->assertEquals('value', TbArray::popValue('key', $array));
|
||||
$this->assertArrayNotHasKey('key', $array);
|
||||
}
|
||||
|
||||
public function testDefaultValue()
|
||||
{
|
||||
$array = array();
|
||||
TbArray::defaultValue('key', 'default', $array);
|
||||
$this->assertEquals('default', TbArray::getValue('key', $array));
|
||||
TbArray::defaultValue('key', 'value', $array);
|
||||
$this->assertEquals('default', TbArray::getValue('key', $array));
|
||||
}
|
||||
|
||||
public function testDefaultValues()
|
||||
{
|
||||
$array = array('my' => 'value');
|
||||
TbArray::defaultValues(array('these' => 'are', 'my' => 'defaults'), $array);
|
||||
$this->assertEquals('are', TbArray::getValue('these', $array));
|
||||
$this->assertEquals('value', TbArray::getValue('my', $array));
|
||||
}
|
||||
|
||||
public function testRemoveValue()
|
||||
{
|
||||
$array = array('key' => 'value');
|
||||
TbArray::removeValue('key', $array);
|
||||
$this->assertArrayNotHasKey('key', $array);
|
||||
}
|
||||
|
||||
public function testRemoveValues()
|
||||
{
|
||||
$array = array('these' => 'are', 'my' => 'values');
|
||||
TbArray::removeValues(array('these', 'my'), $array);
|
||||
$this->assertArrayNotHasKey('these', $array);
|
||||
$this->assertArrayNotHasKey('my', $array);
|
||||
}
|
||||
|
||||
public function testCopyValues()
|
||||
{
|
||||
$a = array('key' => 'value');
|
||||
$b = array();
|
||||
$array = TbArray::copyValues(array('key'), $a, $b);
|
||||
$this->assertEquals($a, $array);
|
||||
$a = array('key' => 'value');
|
||||
$b = array('key' => 'other');
|
||||
$array = TbArray::copyValues(array('key'), $a, $b, true);
|
||||
$this->assertEquals($a, $array);
|
||||
}
|
||||
|
||||
public function testMoveValues()
|
||||
{
|
||||
$a = array('key' => 'value');
|
||||
$b = array();
|
||||
$array = TbArray::moveValues(array('key'), $a, $b);
|
||||
$this->assertArrayNotHasKey('key', $a);
|
||||
$this->assertEquals('value', TbArray::getValue('key', $array));
|
||||
$a = array('key' => 'value');
|
||||
$b = array('key' => 'other');
|
||||
$array = TbArray::moveValues(array('key'), $a, $b, true);
|
||||
$this->assertEquals('value', TbArray::getValue('key', $array));
|
||||
}
|
||||
|
||||
public function testMerge()
|
||||
{
|
||||
$a = array('this' => 'is', 'array' => 'a');
|
||||
$b = array('is' => 'this', 'b' => 'array');
|
||||
$array = TbArray::merge($a, $b);
|
||||
$this->assertEquals('is', TbArray::getValue('this', $array));
|
||||
$this->assertEquals('a', TbArray::getValue('array', $array));
|
||||
$this->assertEquals('this', TbArray::getValue('is', $array));
|
||||
$this->assertEquals('array', TbArray::getValue('b', $array));
|
||||
}
|
||||
}
|
||||
3934
www/protected/extensions/bootstrap/tests/unit/TbHtmlTest.php
Normal file
3934
www/protected/extensions/bootstrap/tests/unit/TbHtmlTest.php
Normal file
File diff suppressed because it is too large
Load Diff
69
www/protected/extensions/bootstrap/tests/unit/TbTestCase.php
Normal file
69
www/protected/extensions/bootstrap/tests/unit/TbTestCase.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
require(__DIR__ . '/../../vendor/yiisoft/yii/tests/TestApplication.php');
|
||||
require(__DIR__ . '/../../vendor/yiisoft/yii/framework/collections/CMap.php');
|
||||
|
||||
class TbTestCase extends \Codeception\TestCase\Test
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function _after()
|
||||
{
|
||||
$this->destroyApplication();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $config
|
||||
* @param string $appClass
|
||||
*/
|
||||
protected function mockApplication($config = array(), $appClass = 'TestApplication')
|
||||
{
|
||||
$defaultConfig = array(
|
||||
'basePath' => __DIR__,
|
||||
'aliases' => array(
|
||||
'bootstrap' => __DIR__ . '/../..',
|
||||
),
|
||||
);
|
||||
Yii::createApplication(
|
||||
$appClass,
|
||||
CMap::mergeArray($defaultConfig, $config)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function destroyApplication()
|
||||
{
|
||||
Yii::setApplication(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $widgetClass
|
||||
* @param array $properties
|
||||
* @return string
|
||||
*/
|
||||
protected function runWidget($widgetClass, $properties = array())
|
||||
{
|
||||
return $this->mockController()->widget($widgetClass, $properties, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $widgetClass
|
||||
* @param array $properties
|
||||
* @return CWidget
|
||||
*/
|
||||
protected function beginWidget($widgetClass, $properties = array())
|
||||
{
|
||||
return $this->mockController()->beginWidget($widgetClass, $properties);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return CController
|
||||
*/
|
||||
private function mockController()
|
||||
{
|
||||
return new CController('dummy');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
<?php
|
||||
// Here you can initialize variables that will for your tests
|
||||
Reference in New Issue
Block a user