Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F1167345
D540.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, Sep 23, 10:29 AM
Size
10 KB
Mime Type
text/x-diff
Expires
Wed, Sep 24, 10:29 AM (9 h, 52 m)
Engine
blob
Format
Raw Data
Handle
755333
Attached To
D540: INP-1925 - Configure PHPUnit integration with Arcanist
D540.diff
View Options
Index: branches/5.2.x/.arcconfig
===================================================================
--- branches/5.2.x/.arcconfig
+++ branches/5.2.x/.arcconfig
@@ -1,5 +1,9 @@
{
"project.name": "in-portal",
"repository.callsign": "INP",
- "phabricator.uri": "https://qa.in-portal.org/"
+ "phabricator.uri": "https://qa.in-portal.org/",
+ "unit.engine": "PhpunitTestEngine",
+ "phpunit_config": "tools/build/inc/phpunit.xml",
+ "unit.phpunit.binary": "vendor/bin/phpunit",
+ "browser": "firefox"
}
Index: branches/5.2.x/core/tests/Unit/kernel/globalsTest.php
===================================================================
--- branches/5.2.x/core/tests/Unit/kernel/globalsTest.php
+++ branches/5.2.x/core/tests/Unit/kernel/globalsTest.php
@@ -0,0 +1,63 @@
+<?php
+
+/**
+ * The class name must match the file name for Phabricator-invoked PHPUnit to run this test.
+ *
+ * TODO: Once "globals.php" file is renamed we can rename this class/filename as well.
+ */
+class globalsTest extends AbstractTestCase // phpcs:ignore Squiz.Classes.ValidClassName.NotCamelCaps
+{
+
+ /**
+ * @dataProvider netMatchDataProvider
+ */
+ public function testNetMatch($network, $ip, $expected)
+ {
+ $this->assertSame($expected, kUtil::netMatch($network, $ip));
+ }
+
+ public static function netMatchDataProvider()
+ {
+ $ip_from_host = gethostbyname('www.in-portal.org');
+
+ return array(
+ // Hosts.
+ array('www.in-portal.org', $ip_from_host, true),
+ array('www.yahoo.com', $ip_from_host, false),
+
+ // IPv4 address vs IPv4 network.
+ array('1.2.3.4', '1.2.3.4', true),
+ array('1.2.3.4', '1.2.3.5', false),
+ array('1.2.3.32-1.2.3.54', '1.2.3.40', true),
+ array('1.2.3.32-1.2.3.54', '1.2.3.64', false),
+ array('1.2.3.32/27', '1.2.3.35', true),
+ array('1.2.3.32/27', '1.2.3.64', false),
+ array('1.2.3/27', '1.2.3.5', true),
+ array('1.2.3/27', '1.2.3.33', false),
+ array('1.2.3.32/255.255.255.224', '1.2.3.35', true),
+ array('1.2.3.32/255.255.255.224', '1.2.3.64', false),
+ array('1.2.3.32/27', '1.2.3.4.6', false),
+
+ // IPv6 address vs IPv6 network.
+ array('971a:6ff4:3fe8::7085:f498:fc5a:9893', '971a:6ff4:3fe8::7085:f498:fc5a:9893', true),
+ array('971a:6ff4:3fe8::7085:f498:fc5a:9893', '971a:6ff4:3fe8::7085:f498:fc5a:9895', false),
+ array('971a:6ff4:3fe8::9893-971a:6ff4:3fe8::9895', '971a:6ff4:3fe8::9894', true),
+ array('971a:6ff4:3fe8::9893-971a:6ff4:3fe8::9895', '971a:6ff4:3fe8::9896', false),
+ array('971a:6ff4:3fe8::9893/64', '971a:6ff4:3fe8::9895', true),
+ array('971a:6ff4:3fe8::9893/64', '971a:6ff4:3fe9::9895', false),
+
+ // IPv6 address vs IPv4 network.
+ array('1.2.3.4', '971a:6ff4:3fe8::7085:f498:fc5a:9893', false),
+ array('1.2.3.32-1.2.3.54', '971a:6ff4:3fe8::7085:f498:fc5a:9893', false),
+ array('1.2.3.32/27', '971a:6ff4:3fe8::7085:f498:fc5a:9893', false),
+ array('1.2.3/27', '971a:6ff4:3fe8::7085:f498:fc5a:9893', false),
+ array('1.2.3.32/255.255.255.224', '971a:6ff4:3fe8::7085:f498:fc5a:9893', false),
+
+ // IPv4 address vs IPv6 network.
+ array('971a:6ff4:3fe8::7085:f498:fc5a:9893', '1.2.3.4', false),
+ array('971a:6ff4:3fe8::9893-971a:6ff4:3fe8::9895', '1.2.3.4', false),
+ array('971a:6ff4:3fe8::9893/64', '1.2.3.4', false),
+ );
+ }
+
+}
Index: branches/5.2.x/core/tests/Unit/kernel/kUtilTest.php
===================================================================
--- branches/5.2.x/core/tests/Unit/kernel/kUtilTest.php
+++ branches/5.2.x/core/tests/Unit/kernel/kUtilTest.php
@@ -1,59 +0,0 @@
-<?php
-
-
-class kUtilTest extends AbstractTestCase
-{
-
- /**
- * @dataProvider netMatchDataProvider
- */
- public function testNetMatch($network, $ip, $expected)
- {
- $this->assertSame($expected, kUtil::netMatch($network, $ip));
- }
-
- public static function netMatchDataProvider()
- {
- $ip_from_host = gethostbyname('www.in-portal.org');
-
- return array(
- // Hosts.
- array('www.in-portal.org', $ip_from_host, true),
- array('www.yahoo.com', $ip_from_host, false),
-
- // IPv4 address vs IPv4 network.
- array('1.2.3.4', '1.2.3.4', true),
- array('1.2.3.4', '1.2.3.5', false),
- array('1.2.3.32-1.2.3.54', '1.2.3.40', true),
- array('1.2.3.32-1.2.3.54', '1.2.3.64', false),
- array('1.2.3.32/27', '1.2.3.35', true),
- array('1.2.3.32/27', '1.2.3.64', false),
- array('1.2.3/27', '1.2.3.5', true),
- array('1.2.3/27', '1.2.3.33', false),
- array('1.2.3.32/255.255.255.224', '1.2.3.35', true),
- array('1.2.3.32/255.255.255.224', '1.2.3.64', false),
- array('1.2.3.32/27', '1.2.3.4.6', false),
-
- // IPv6 address vs IPv6 network.
- array('971a:6ff4:3fe8::7085:f498:fc5a:9893', '971a:6ff4:3fe8::7085:f498:fc5a:9893', true),
- array('971a:6ff4:3fe8::7085:f498:fc5a:9893', '971a:6ff4:3fe8::7085:f498:fc5a:9895', false),
- array('971a:6ff4:3fe8::9893-971a:6ff4:3fe8::9895', '971a:6ff4:3fe8::9894', true),
- array('971a:6ff4:3fe8::9893-971a:6ff4:3fe8::9895', '971a:6ff4:3fe8::9896', false),
- array('971a:6ff4:3fe8::9893/64', '971a:6ff4:3fe8::9895', true),
- array('971a:6ff4:3fe8::9893/64', '971a:6ff4:3fe9::9895', false),
-
- // IPv6 address vs IPv4 network.
- array('1.2.3.4', '971a:6ff4:3fe8::7085:f498:fc5a:9893', false),
- array('1.2.3.32-1.2.3.54', '971a:6ff4:3fe8::7085:f498:fc5a:9893', false),
- array('1.2.3.32/27', '971a:6ff4:3fe8::7085:f498:fc5a:9893', false),
- array('1.2.3/27', '971a:6ff4:3fe8::7085:f498:fc5a:9893', false),
- array('1.2.3.32/255.255.255.224', '971a:6ff4:3fe8::7085:f498:fc5a:9893', false),
-
- // IPv4 address vs IPv6 network.
- array('971a:6ff4:3fe8::7085:f498:fc5a:9893', '1.2.3.4', false),
- array('971a:6ff4:3fe8::9893-971a:6ff4:3fe8::9895', '1.2.3.4', false),
- array('971a:6ff4:3fe8::9893/64', '1.2.3.4', false),
- );
- }
-
-}
Index: branches/5.2.x/core/tests/Unit/kernel/utility/formatters/formatterTest.php
===================================================================
--- branches/5.2.x/core/tests/Unit/kernel/utility/formatters/formatterTest.php
+++ branches/5.2.x/core/tests/Unit/kernel/utility/formatters/formatterTest.php
@@ -0,0 +1,67 @@
+<?php
+
+/**
+ * The class name must match the file name for Phabricator-invoked PHPUnit to run this test.
+ *
+ * TODO: Once "formatter.php" file is renamed we can rename this class/filename as well.
+ */
+final class formatterTest extends AbstractTestCase // phpcs:ignore Squiz.Classes.ValidClassName.NotCamelCaps
+{
+
+ /**
+ * @dataProvider cutZerosDataProvider
+ */
+ public function testCutZeros($raw_number, $formatted_number, array $field_options)
+ {
+ $formatter = new kFormatter();
+
+ $item_prophecy = $this->prophesize('kDBItem');
+ $item_prophecy->GetFieldOptions('FieldName')->willReturn(array(
+ 'type' => 'float',
+ 'format' => '%01.6f',
+ ) + $field_options);
+ $item = $item_prophecy->reveal();
+
+ $this->assertSame($formatted_number, $formatter->Format($raw_number, 'FieldName', $item));
+ }
+
+ public function cutZerosDataProvider()
+ {
+ return array(
+ 'long' => array('12.345000', '12.345', array('cut_zeros' => 1)),
+ 'short' => array('12.300000', '12.3', array('cut_zeros' => 1)),
+ 'exact+leading_zero' => array('12.030000', '12.03', array('cut_zeros' => 1)),
+ 'very_long' => array('12.030050', '12.03005', array('cut_zeros' => 1)),
+ 'no_decimals' => array('12.000000', '12', array('cut_zeros' => 1)),
+ );
+ }
+
+ /**
+ * @dataProvider keepCentsDataProvider
+ */
+ public function testKeepCents($raw_number, $formatted_number, array $field_options)
+ {
+ $formatter = new kFormatter();
+
+ $item_prophecy = $this->prophesize('kDBItem');
+ $item_prophecy->GetFieldOptions('FieldName')->willReturn(array(
+ 'type' => 'float',
+ 'format' => '%01.6f',
+ ) + $field_options);
+ $item = $item_prophecy->reveal();
+
+ $this->assertSame($formatted_number, $formatter->Format($raw_number, 'FieldName', $item));
+ }
+
+ public function keepCentsDataProvider()
+ {
+ return array(
+ 'long' => array('12.345000', '12.345', array('keep_cents' => 2)),
+ 'short' => array('12.300000', '12.30', array('keep_cents' => 2)),
+ 'exact+leading_zero' => array('12.030000', '12.03', array('keep_cents' => 2)),
+ 'very_long' => array('12.030050', '12.03005', array('keep_cents' => 2)),
+ 'no_decimals' => array('12.000000', '12.00', array('keep_cents' => 2)),
+ );
+ }
+
+}
Index: branches/5.2.x/core/tests/Unit/kernel/utility/formatters/kFormatterTest.php
===================================================================
--- branches/5.2.x/core/tests/Unit/kernel/utility/formatters/kFormatterTest.php
+++ branches/5.2.x/core/tests/Unit/kernel/utility/formatters/kFormatterTest.php
@@ -1,63 +0,0 @@
-<?php
-
-
-final class kFormatterTest extends AbstractTestCase
-{
-
- /**
- * @dataProvider cutZerosDataProvider
- */
- public function testCutZeros($raw_number, $formatted_number, array $field_options)
- {
- $formatter = new kFormatter();
-
- $item_prophecy = $this->prophesize('kDBItem');
- $item_prophecy->GetFieldOptions('FieldName')->willReturn(array(
- 'type' => 'float',
- 'format' => '%01.6f',
- ) + $field_options);
- $item = $item_prophecy->reveal();
-
- $this->assertSame($formatted_number, $formatter->Format($raw_number, 'FieldName', $item));
- }
-
- public function cutZerosDataProvider()
- {
- return array(
- 'long' => array('12.345000', '12.345', array('cut_zeros' => 1)),
- 'short' => array('12.300000', '12.3', array('cut_zeros' => 1)),
- 'exact+leading_zero' => array('12.030000', '12.03', array('cut_zeros' => 1)),
- 'very_long' => array('12.030050', '12.03005', array('cut_zeros' => 1)),
- 'no_decimals' => array('12.000000', '12', array('cut_zeros' => 1)),
- );
- }
-
- /**
- * @dataProvider keepCentsDataProvider
- */
- public function testKeepCents($raw_number, $formatted_number, array $field_options)
- {
- $formatter = new kFormatter();
-
- $item_prophecy = $this->prophesize('kDBItem');
- $item_prophecy->GetFieldOptions('FieldName')->willReturn(array(
- 'type' => 'float',
- 'format' => '%01.6f',
- ) + $field_options);
- $item = $item_prophecy->reveal();
-
- $this->assertSame($formatted_number, $formatter->Format($raw_number, 'FieldName', $item));
- }
-
- public function keepCentsDataProvider()
- {
- return array(
- 'long' => array('12.345000', '12.345', array('keep_cents' => 2)),
- 'short' => array('12.300000', '12.30', array('keep_cents' => 2)),
- 'exact+leading_zero' => array('12.030000', '12.03', array('keep_cents' => 2)),
- 'very_long' => array('12.030050', '12.03005', array('keep_cents' => 2)),
- 'no_decimals' => array('12.000000', '12.00', array('keep_cents' => 2)),
- );
- }
-
-}
Event Timeline
Log In to Comment