Developer Guide

Install With Modman

$ cd /path/to/root/magento/install
$ modman clone https://github.com/vehiclefits/Vehicle-Fits-Magento
$ cd .modman/Vehicle-Fits-Magento/app/code/local/Elite
$ composer install
After installation, log into Magento's admin panel and go to system -> configuration -> developer -> template settings -> Allow Symlinks: Yes

Automated Tests

The Vehicle Fits software is a complex software. Some users want "year,make,model", others may want "foo,bar". Due to this, the number of interactions between features is difficult to manage. In order to ensure all interactions of these features work after making code changes, we run an automated test suite. This is comprised of phpunit tests for PHP & qunit tests for javascript.

Running the phpunit tests

cd to the app/code/local/Elite directory and run `phpunit`. The configuration is read from phpunit.xml.dist

The tests are each wrapped in a transaciton that gets rolled back. In each test case, in the doSetUp() method the schema should be specified (year,make,model for example). If the schema differs from the current database's schema, a reset of the tables is forced. If a unit test fails at an unfortunate time, the tables could not all be created. To force a database reset run `php tasks/schema.php`.

There are some conventions with the way unit tests are written. Generally speaking, we usually group the test case files by the schema levels. For a feature we will have one test case that tests with the levels set to "year,make,model".. in another test case we will have the levels set to "make,model,year" with a similar set of test methods. All test cases extend a base test case class which provides common functionality such as database transaction/rollback mechanism to reset the state of the database after each test, and utility methods that facilitate common operations such as creating a vehicle, or asserting that a vehicle exists

Since the base test case class defines a setUp() method for wrapping test methods in transactions, all setup logic for your test case must go in a template method doSetUp(). In this method the first line of code should use the utility method switchSchema() to define what schema should be initialized for your tests

function doSetUp()
{
    $this->switchSchema('make,model,year');
}

For performance reasons, switchSchema() will drop the old tables & create new tables, but only if the schema being asked for differs from the current state of the database. Data is reset on every test method with a transaction rollback. The schema need only be reset if the schema is changing.

Running the Qunit tests

Open your browser to http://localhost/vafAjaxTests/ replacing localhost with wherever you have Magento installed. The tests should run and their results will be displayed in your browser.

Command Line Utilities

In app/code/local/Elite are various utilities.

Schema

To reset the schema to a new schema do this:

php tasks/schema.php --force --levels="make,model,year"
To add a new schema do this:
php tasks/schema.php --add --levels="foo,bar"
You must create the first schema before creating an additional one with the --add flag.

Import/Export

//todo

Coding Standards

We use the coding standards called psr-2, for all PHP files, with the following exceptions:

  • There is to be no visibility declared for any methods. All methods are implicitly public.
For javascript, curly braces always go 'on the same line'.

Contributions

Contributions are more than welcome, however please read the above notes about automated tests. The more code we accept, the more code we have to maintain. Your code must be well unit tested to be accepted, even a bug fix is not officially incorporated in most cases, without accompanying unit tests.