From e15d144e27db134cb71507539133855d692de1cf Mon Sep 17 00:00:00 2001 From: Fonata Date: Sat, 3 Apr 2021 00:07:44 +0200 Subject: [PATCH] Adjust call to static function --- tests/methods/DataRowCountTest.php | 2 +- tests/methods/ParseTest.php | 48 +++++----- .../DefaultValuesPropertiesTest.php | 94 +++++++++---------- 3 files changed, 72 insertions(+), 72 deletions(-) diff --git a/tests/methods/DataRowCountTest.php b/tests/methods/DataRowCountTest.php index 78faefc..8f35dbc 100644 --- a/tests/methods/DataRowCountTest.php +++ b/tests/methods/DataRowCountTest.php @@ -47,7 +47,7 @@ class DataRowCountTest extends TestCase { public function testGetTotalRowCountFromFile($file, $expectedRows) { $this->csv->heading = true; $this->csv->load_data(__DIR__ . '/fixtures/' . $file); - $this->assertEquals($expectedRows, $this->csv->getTotalDataRowCount()); + self::assertEquals($expectedRows, $this->csv->getTotalDataRowCount()); } public function testGetTotalRowCountMissingEndingLineBreak() { diff --git a/tests/methods/ParseTest.php b/tests/methods/ParseTest.php index 0cf8a6c..67c69c6 100644 --- a/tests/methods/ParseTest.php +++ b/tests/methods/ParseTest.php @@ -36,12 +36,12 @@ class ParseTest extends TestCase { $this->csv->delimiter = ';'; $this->csv->heading = false; $success = $this->csv->parse(str_repeat($content . ';', 500)); - $this->assertEquals(true, $success); + self::assertEquals(true, $success); $row = array_pop($this->csv->data); $expected_data = array_fill(0, 500, $content); $expected_data[] = ''; - $this->assertEquals($expected_data, $row); + self::assertEquals($expected_data, $row); } /** @@ -57,7 +57,7 @@ class ParseTest extends TestCase { $this->csv->output_encoding = 'UTF-8'; $this->csv->auto($file); - $this->assertEquals($this->_get_magazines_data(), $this->csv->data); + self::assertEquals($this->_get_magazines_data(), $this->csv->data); } /** @@ -78,17 +78,17 @@ class ParseTest extends TestCase { ); $row = array_pop($this->csv->data); $expected_data = ['URL' => 'http://www.amazon.com/ROX-Ice-Ball-Maker-Original/dp/B00MX59NMQ/ref=sr_1_1?ie=UTF8&qid=1435604374&sr=8-1&keywords=rox,+ice+molds']; - $this->assertEquals($expected_data, $row); + self::assertEquals($expected_data, $row); } public function testAllNumericalCsv() { $this->csv->heading = false; $sInput = "86545235689\r\n34365587654\r\n13469874576"; - $this->assertEquals(false, $this->csv->auto($sInput)); - $this->assertEquals(null, $this->csv->delimiter); + self::assertEquals(false, $this->csv->autoDetectionForDataString($sInput)); + self::assertEquals(null, $this->csv->delimiter); $expected_data = explode("\r\n", $sInput); $actual_data = array_map('reset', $this->csv->data); - $this->assertEquals($expected_data, $actual_data); + self::assertEquals($expected_data, $actual_data); } public function testMissingEndingLineBreak() { @@ -99,8 +99,8 @@ class ParseTest extends TestCase { $actual_data = $this->invokeMethod($this->csv, '_parse_string', [$sInput]); $actual_column = array_map('reset', $actual_data); - $this->assertEquals($expected_data, $actual_column); - $this->assertEquals( + self::assertEquals($expected_data, $actual_column); + self::assertEquals( [ 'a', 'b', @@ -118,7 +118,7 @@ class ParseTest extends TestCase { ['SMS' => '6606'], ['SMS' => '7777'], ]; - $this->assertEquals($expected, $this->csv->data); + self::assertEquals($expected, $this->csv->data); } public function testMatomoData() { @@ -127,7 +127,7 @@ class ParseTest extends TestCase { $this->csv->output_encoding = 'UTF-8'; $this->csv->auto(__DIR__ . '/../example_files/Piwik_API_download.csv'); $aAction27 = array_column($this->csv->data, 'url (actionDetails 27)'); - $this->assertEquals( + self::assertEquals( [ 'http://application/_Main/_GraphicMeanSTD_MDI/btnConfBandOptions', '', @@ -137,7 +137,7 @@ class ParseTest extends TestCase { ); $aCity = array_column($this->csv->data, 'city'); - $this->assertEquals( + self::assertEquals( [ 'São Paulo', 'Johannesburg', @@ -161,7 +161,7 @@ class ParseTest extends TestCase { $this->csv->output_encoding = 'UTF-8'; $this->csv->delimiter = ';'; - self::assertTrue($this->csv->load_data($string_with_bom)); + self::assertTrue($this->csv->loadDataString($string_with_bom)); self::assertTrue($this->csv->parse($this->csv->file_data)); // This also tests if ::load_data removed the BOM from the data; @@ -214,7 +214,7 @@ class ParseTest extends TestCase { 'price' => 'float', ]; - $this->assertEquals($expected, $this->csv->data_types); + self::assertEquals($expected, $this->csv->data_types); } /** @@ -222,21 +222,21 @@ class ParseTest extends TestCase { */ public function testAutoDetectFileHasHeading() { $this->csv->auto(__DIR__ . '/fixtures/datatype.csv'); - $this->assertTrue($this->csv->autoDetectFileHasHeading()); + self::assertTrue($this->csv->autoDetectFileHasHeading()); $this->csv->heading = false; $this->csv->auto(__DIR__ . '/fixtures/datatype.csv'); - $this->assertTrue($this->csv->autoDetectFileHasHeading()); + self::assertTrue($this->csv->autoDetectFileHasHeading()); $this->csv->heading = false; $sInput = "86545235689\r\n34365587654\r\n13469874576"; - $this->csv->auto($sInput); - $this->assertFalse($this->csv->autoDetectFileHasHeading()); + $this->csv->autoDetectionForDataString($sInput); + self::assertFalse($this->csv->autoDetectFileHasHeading()); $this->csv->heading = true; $sInput = "86545235689\r\n34365587654\r\n13469874576"; - $this->csv->auto($sInput); - $this->assertFalse($this->csv->autoDetectFileHasHeading()); + $this->csv->autoDetectionForDataString($sInput); + self::assertFalse($this->csv->autoDetectFileHasHeading()); } /** @@ -291,8 +291,8 @@ class ParseTest extends TestCase { public function testAutoQuotes($file, $enclosure) { $csv = new Csv(); $csv->auto(__DIR__ . '/fixtures/' . $file, true, null, null, $enclosure); - $this->assertArrayHasKey('column1', $csv->data[0], 'Data parsed incorrectly with enclosure ' . $enclosure); - $this->assertEquals('value1', $csv->data[0]['column1'], 'Data parsed incorrectly with enclosure ' . $enclosure); + self::assertArrayHasKey('column1', $csv->data[0], 'Data parsed incorrectly with enclosure ' . $enclosure); + self::assertEquals('value1', $csv->data[0]['column1'], 'Data parsed incorrectly with enclosure ' . $enclosure); } /** @@ -313,7 +313,7 @@ class ParseTest extends TestCase { } public function testWaiverFieldSeparator() { - $this->assertFalse($this->csv->auto(__DIR__ . '/../example_files/waiver_field_separator.csv')); + self::assertFalse($this->csv->auto(__DIR__ . '/../example_files/waiver_field_separator.csv')); $expected = [ 'liability waiver', 'release of liability form', @@ -322,6 +322,6 @@ class ParseTest extends TestCase { 'sample waiver form', ]; $actual = array_column($this->csv->data, 'keyword'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } } diff --git a/tests/properties/DefaultValuesPropertiesTest.php b/tests/properties/DefaultValuesPropertiesTest.php index d60adab..9638a06 100644 --- a/tests/properties/DefaultValuesPropertiesTest.php +++ b/tests/properties/DefaultValuesPropertiesTest.php @@ -22,130 +22,130 @@ class DefaultValuesPropertiesTest extends TestCase { } public function test_heading_default() { - $this->assertTrue(is_bool($this->csv->heading)); - $this->assertTrue($this->csv->heading); + self::assertTrue(is_bool($this->csv->heading)); + self::assertTrue($this->csv->heading); } public function test_fields_default() { - $this->assertTrue(is_array($this->csv->fields)); - $this->assertCount(0, $this->csv->fields); + self::assertTrue(is_array($this->csv->fields)); + self::assertCount(0, $this->csv->fields); } public function test_sort_by_default() { - $this->assertNull($this->csv->sort_by); + self::assertNull($this->csv->sort_by); } public function test_sort_reverse_default() { - $this->assertTrue(is_bool($this->csv->sort_reverse)); - $this->assertFalse($this->csv->sort_reverse); + self::assertTrue(is_bool($this->csv->sort_reverse)); + self::assertFalse($this->csv->sort_reverse); } public function test_sort_type_default() { - $this->assertEquals('regular', $this->csv->sort_type); + self::assertEquals('regular', $this->csv->sort_type); } public function test_delimiter_default() { - $this->assertTrue(is_string($this->csv->delimiter)); - $this->assertEquals(',', $this->csv->delimiter); + self::assertTrue(is_string($this->csv->delimiter)); + self::assertEquals(',', $this->csv->delimiter); } public function test_enclosure_default() { - $this->assertTrue(is_string($this->csv->enclosure)); - $this->assertEquals('"', $this->csv->enclosure); + self::assertTrue(is_string($this->csv->enclosure)); + self::assertEquals('"', $this->csv->enclosure); } public function test_enclose_all_default() { - $this->assertTrue(is_bool($this->csv->enclose_all)); - $this->assertFalse($this->csv->enclose_all); + self::assertTrue(is_bool($this->csv->enclose_all)); + self::assertFalse($this->csv->enclose_all); } public function test_conditions_default() { - $this->assertNull($this->csv->conditions); + self::assertNull($this->csv->conditions); } public function test_offset_default() { - $this->assertNull($this->csv->offset); + self::assertNull($this->csv->offset); } public function test_limit_default() { - $this->assertNull($this->csv->limit); + self::assertNull($this->csv->limit); } public function test_auto_depth_default() { - $this->assertTrue(is_numeric($this->csv->auto_depth)); - $this->assertEquals(15, $this->csv->auto_depth); + self::assertTrue(is_numeric($this->csv->auto_depth)); + self::assertEquals(15, $this->csv->auto_depth); } public function test_auto_non_chars_default() { - $this->assertTrue(is_string($this->csv->auto_non_chars)); - $this->assertEquals("a-zA-Z0-9\n\r", $this->csv->auto_non_chars); + self::assertTrue(is_string($this->csv->auto_non_chars)); + self::assertEquals("a-zA-Z0-9\n\r", $this->csv->auto_non_chars); } public function test_auto_preferred_default() { - $this->assertTrue(is_string($this->csv->auto_preferred)); - $this->assertEquals(",;\t.:|", $this->csv->auto_preferred); + self::assertTrue(is_string($this->csv->auto_preferred)); + self::assertEquals(",;\t.:|", $this->csv->auto_preferred); } public function test_convert_encoding_default() { - $this->assertTrue(is_bool($this->csv->convert_encoding)); - $this->assertFalse($this->csv->convert_encoding); + self::assertTrue(is_bool($this->csv->convert_encoding)); + self::assertFalse($this->csv->convert_encoding); } public function test_input_encoding_default() { - $this->assertTrue(is_string($this->csv->input_encoding)); - $this->assertEquals('ISO-8859-1', $this->csv->input_encoding); + self::assertTrue(is_string($this->csv->input_encoding)); + self::assertEquals('ISO-8859-1', $this->csv->input_encoding); } public function test_output_encoding_default() { - $this->assertTrue(is_string($this->csv->output_encoding)); - $this->assertEquals('ISO-8859-1', $this->csv->output_encoding); + self::assertTrue(is_string($this->csv->output_encoding)); + self::assertEquals('ISO-8859-1', $this->csv->output_encoding); } public function test_linefeed_default() { - $this->assertTrue(is_string($this->csv->linefeed)); - $this->assertEquals("\r", $this->csv->linefeed); + self::assertTrue(is_string($this->csv->linefeed)); + self::assertEquals("\r", $this->csv->linefeed); } public function test_output_delimiter_default() { - $this->assertTrue(is_string($this->csv->output_delimiter)); - $this->assertEquals(',', $this->csv->output_delimiter); + self::assertTrue(is_string($this->csv->output_delimiter)); + self::assertEquals(',', $this->csv->output_delimiter); } public function test_output_filename_default() { - $this->assertTrue(is_string($this->csv->output_filename)); - $this->assertEquals('data.csv', $this->csv->output_filename); + self::assertTrue(is_string($this->csv->output_filename)); + self::assertEquals('data.csv', $this->csv->output_filename); } public function test_keep_file_data_default() { - $this->assertTrue(is_bool($this->csv->keep_file_data)); - $this->assertFalse($this->csv->keep_file_data); + self::assertTrue(is_bool($this->csv->keep_file_data)); + self::assertFalse($this->csv->keep_file_data); } public function test_file_default() { - $this->assertNull($this->csv->file); + self::assertNull($this->csv->file); } public function test_file_data_default() { - $this->assertNull($this->csv->file_data); + self::assertNull($this->csv->file_data); } public function test_error_default() { - $this->assertTrue(is_numeric($this->csv->error)); - $this->assertEquals(0, $this->csv->error); + self::assertTrue(is_numeric($this->csv->error)); + self::assertEquals(0, $this->csv->error); } public function test_error_info_default() { - $this->assertTrue(is_array($this->csv->error_info)); - $this->assertCount(0, $this->csv->error_info); + self::assertTrue(is_array($this->csv->error_info)); + self::assertCount(0, $this->csv->error_info); } public function test_titles_default() { - $this->assertTrue(is_array($this->csv->titles)); - $this->assertCount(0, $this->csv->titles); + self::assertTrue(is_array($this->csv->titles)); + self::assertCount(0, $this->csv->titles); } public function test_data_default() { - $this->assertTrue(is_array($this->csv->data)); - $this->assertCount(0, $this->csv->data); + self::assertTrue(is_array($this->csv->data)); + self::assertCount(0, $this->csv->data); } }