Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
framework
Stdlib
Test
Unit
BooleanUtilsTest.php
Go to the documentation of this file.
1
<?php
6
namespace
Magento\Framework\Stdlib\Test\Unit
;
7
8
use \Magento\Framework\Stdlib\BooleanUtils;
9
10
class
BooleanUtilsTest
extends
\PHPUnit\Framework\TestCase
11
{
15
protected
$object
;
16
17
protected
function
setUp
()
18
{
19
$this->
object
=
new
BooleanUtils
();
20
}
21
22
public
function
testConstructor
()
23
{
24
$object
=
new
BooleanUtils
([
'yep'
], [
'nope'
]);
25
$this->assertTrue(
$object
->toBoolean(
'yep'
));
26
$this->assertFalse(
$object
->toBoolean(
'nope'
));
27
}
28
35
public
function
testToBoolean
($input, $expected)
36
{
37
$actual = $this->
object
->toBoolean($input);
38
$this->assertSame($expected, $actual);
39
}
40
44
public
function
toBooleanDataProvider
()
45
{
46
return
[
47
'boolean "true"'
=> [
true
,
true
],
48
'boolean "false"'
=> [
false
,
false
],
49
'boolean string "true"'
=> [
'true'
,
true
],
50
'boolean string "false"'
=> [
'false'
,
false
],
51
'boolean numeric "1"'
=> [1,
true
],
52
'boolean numeric "0"'
=> [0,
false
],
53
'boolean string "1"'
=> [
'1'
,
true
],
54
'boolean string "0"'
=> [
'0'
,
false
]
55
];
56
}
57
65
public
function
testToBooleanException
($input)
66
{
67
$this->
object
->toBoolean($input);
68
}
69
73
public
function
toBooleanExceptionDataProvider
()
74
{
75
return
[
76
'boolean string "on"'
=> [
'on'
],
77
'boolean string "off"'
=> [
'off'
],
78
'boolean string "yes"'
=> [
'yes'
],
79
'boolean string "no"'
=> [
'no'
],
80
'boolean string "TRUE"'
=> [
'TRUE'
],
81
'boolean string "FALSE"'
=> [
'FALSE'
],
82
'empty string'
=> [
''
],
83
'null'
=> [
null
]
84
];
85
}
86
}
Magento\Framework\Stdlib\Test\Unit\BooleanUtilsTest\testConstructor
testConstructor()
Definition:
BooleanUtilsTest.php:22
Magento\Framework\Stdlib\Test\Unit\BooleanUtilsTest\setUp
setUp()
Definition:
BooleanUtilsTest.php:17
Magento\Framework\Stdlib\Test\Unit\BooleanUtilsTest\testToBooleanException
testToBooleanException($input)
Definition:
BooleanUtilsTest.php:65
Magento\Framework\Stdlib\Test\Unit\BooleanUtilsTest\$object
$object
Definition:
BooleanUtilsTest.php:15
Magento\Framework\Stdlib\Test\Unit\BooleanUtilsTest\testToBoolean
testToBoolean($input, $expected)
Definition:
BooleanUtilsTest.php:35
Magento\Framework\Stdlib\Test\Unit
Definition:
ArrayManagerTest.php:6
Magento\Framework\Stdlib\BooleanUtils
Definition:
BooleanUtils.php:14
Magento\Framework\Stdlib\Test\Unit\BooleanUtilsTest\toBooleanDataProvider
toBooleanDataProvider()
Definition:
BooleanUtilsTest.php:44
Magento\Framework\Stdlib\Test\Unit\BooleanUtilsTest
Definition:
BooleanUtilsTest.php:10
Magento\Framework\Stdlib\Test\Unit\BooleanUtilsTest\toBooleanExceptionDataProvider
toBooleanExceptionDataProvider()
Definition:
BooleanUtilsTest.php:73