Files
parsecsv-for-php/tests/properties/worthless_test.php
Christian Bläul 387a0f5761 Renamed class to follow the PHP community guidelines such as:
- https://svn.apache.org/repos/asf/shindig/attic/php/docs/style-guide.html:
  "Acryonyms are treated as normal words."

- https://softwareengineering.stackexchange.com/a/149321/80632
  Overview of class naming conventions of PHP frameworks

- https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader.md
  No .lib allowed: "The class name corresponds to a file name ending in .php"

See issue #50
2018-02-02 13:22:58 +01:00

142 lines
3.5 KiB
PHP

<?php
class worthless_properties_Test extends PHPUnit\Framework\TestCase {
/**
* CSV
* The parseCSV object
*
* @access protected
* @var ParseCsvForPhp
*/
protected $csv = null;
/**
* Reflection Object
* The reflection class object
*
* @access protected
* @var ReflectionClass
*/
protected $reflection = null;
/**
* Reflection Properties
* The reflected class properties
*
* @access protected
* @var ReflectionProperty[]
*/
protected $properties = null;
/**
* Setup
* Setup our test environment objects
*
* @access public
*/
public function setUp() {
//setup parse CSV
$this->csv = new ParseCsvForPhp();
//setup the reflection class
$this->reflection = new ReflectionClass($this->csv);
//setup the reflected class properties
$this->properties = $this->reflection->getProperties();
}
/**
* Tear down
* Tear down our test environment objects
*
* @access public
*/
public function tearDown() {
$this->csv = null;
$this->reflection = null;
$this->properties = null;
}
/**
* test_propertiesCount
* Counts the number of properties to make sure we didn't add or
* subtract any without thinking
*
* @access public
*/
public function test_propertiesCount() {
$this->assertCount(28, $this->properties);
}
/**
* test_property_names
* We have an expected set of properties that should exists
* Make sure our expected number of properties matches the real
* count of properties and also check to make sure our expected
* properties exists within the class
*
* @access public
*/
public function test_property_names() {
//set our expected properties name(s)
$expected_names = array(
'heading',
'fields',
'sort_by',
'sort_reverse',
'sort_type',
'delimiter',
'enclosure',
'enclose_all',
'conditions',
'offset',
'limit',
'auto_depth',
'auto_non_chars',
'auto_preferred',
'convert_encoding',
'input_encoding',
'output_encoding',
'use_mb_convert_encoding',
'linefeed',
'output_delimiter',
'output_filename',
'keep_file_data',
'file',
'file_data',
'error',
'error_info',
'titles',
'data',
);
// Find our real properties
$real_properties = array_map(function (ReflectionProperty $property) {
return $property->getName();
}, $this->properties);
// Lets make sure our expected matches the number of real properties
$this->assertEquals($expected_names, $real_properties);
}
/**
* test_count_public_properties
* We at this point only have public properties so
* lets verify all properties are public
*
* @access public
*/
public function test_count_public_properties() {
$counter = 0;
for ($a = count($this->properties) - 1; $a >= 0; $a--) {
if ($this->properties[$a]->isPublic() === true) {
$counter++;
}
}
$this->assertCount($counter, $this->properties);
}
}