Imbo is an image "server" that can be used to add/get/delete images using a RESTful interface.
PHP Gherkin Shell
Latest commit c8f2103 Jul 28, 2017 @christeredvartsen christeredvartsen committed on GitHub Test multiple database / storage adapters using Behat (#550)
* Enable autoloading of Behat context classes

Instead of adding the path of the Behat feature context classes to the
Behat configuration file, and manually including the files in the
bootstrap for the unit tests the directory is added to autoload-dev in
composer.json

* Add interface for Behat feature context classes

The interface must be implemented by all feature context classes so they
can provide an instance of a database and storage adapter to be used in
the different suites for Behat.

* Use PSR-4 instead of PSR-0 for context classes

To make the name of the Behat context feature classes more clear, we
should use PSR-4 instead of PSR-0. This allows for the usage of
underscores in the classname without having the autoloader automatically
assuming the _ in the classname matches a / in the path.

Because of this we can now match:

Database_Storage => %path%/Database_Storage.php

and not

Database_Storage => %path%/Database/Storage.php

* Enable Behat testing of all adapters

This commit introduces different suites in the Behat test suite, which
enables testing of all the different database and storage adapters, and
combinations of these.

Currently only the MongoDB database adapter and the GridFS storage
adapter is tested, which has been the case since Imbo first started
using Behat for integration tests.

Each suite, which is a combination of a database adapter and a storage
adapter should be added to behat.yml.dist, and should follow the
following naming convention:

<database adapter>_<storage adapter>, for instance "mongodb_gridfs" and
must refer to a context class which follows the same convention, only
that the names should match the specific names of the adapters:

mongodb_gridfs => MongoDB_GridFS which in turn refers to the following
adapters:

- Imbo\Database\MongoDB
- Imbo\Storage\GridFS

Each new context class must implement the ImboFeatureContext interface,
which introduces the two methods that is required to return the database
and storage adapters. Each feature context can also have one or more
Behat hooks that can be used to setup / tear down the specific suites.
Each suite is expected to clear up all resources it generates in the
test run.

Resolves #279

* Add a namespace for Behat feature context classes

This commits adds ImboBehatFeatureContext as a namespace to all classes
related to the feature context classes used in Behat tests. Some classes
have also been renamed to better suit their purpose.

* Add traits for database and storage adapters

To more easily test combinations of database and storage adapters in the
Behat test suites we can use traits for the different adapters. Each
adapter should be responsible of setup / teardown functionality related
to the different adapters. Each suite could then simply use two traits
in combination to test them.

* Skip traits and use configuration for suites

Instead of having traits for the different adapters we want to test, and
a class for each combination this commit will use configuration from the
suites in the behat.yml[.dist] file instead. We also need to exchange
configuration between the context triggered by Behat (which runs ::setUp() /
::tearDown()), and the context from when Imbo gets a request from the test
(::getAdapter). This is done with a request header. The main feature
context has been renamed back to FeatureContext as we no longer need the
previously added FeatureContext interface. The interface added two
methods that is no longer needed.

* Add suite for MongoDB and Filesystem adapters

* Provide sane default values for the Images model

This gives the Imbo\Model\Images model sane deafult values for hits,
limit and page.

Resolves #553

* Add test-suite for Doctrine/SQLite and filesystem

Adds a separate suite for testing the combination of the
Imbo\Database\Doctrine database adapter (with a SQLite database) and the
Imbo\Storage\Filesystem storage adapter.

* Add database setup for Doctrine/SQLite test

The doctrine_sqlite_filesystem suite uses a SQLite database for testing,
and this class is responsible for setting up / clearing the database
used for testing.

* Adjust comparison to work for non-type databases

As the Doctrine database does not handle types in the same way as MySQL
/ MongoDB we need to adjust the tests as the Behat API Extension is
type-sensitive on comparisons such as theses.

* Order by the update flag for correct results

To get the lastest value from the updated column the adapter must add
ordering.

Resolves #556.

* Add method for fetching users in the database

This is a helper method for fetching the unique user names currently
found in the database. If no users-filter is used with the global images
endpoint we need to fetch the list of all users currently in the
database to be sure that the public key has access to all of them.

* Clean up tests for database adapters

Some missing tests have been added, and a generic clean-up has been done
as well, as will be done to all test cases. Add test for the newly added
getAllUsers-method.

* Fix getImages and getLastModified

Implement the new behaviour for getImages, where images from all users
will be returned if the users-parameter is empty. The
getLastModified-methods are also updated and implements the behaviour as
specified in the method documentation found in the interface.

* Update docs to reflect new behaviour of /images

* Remove is_array check

The Request::getUsers() method always returns an array, so no need for
the check.

* Clean up test case annotations

* Fetch all users for auth when query param is empty

When the client does not specify the users-filter when requesting the
global images endpoint Imbo should use all users found in the current
database to use for authentication. Also added test case to verify new
behaviour.

* Rename test class

* Use setup file for SQL

Instead of duplicating the SQL for creating the tables in the database
the test classes now use the contents of the file found in the setup dir,
which is also included in the documentation.

* Supply suite settings for the setUp method

Some suites needs extra settings that can be used in the set up, so this
commit adds a parameter to the setUp method that holds all settings for
the  current suite.

* Add suite for Doctrine (MySQL) and Filesystem

This commit adds a Behat suite for testing the Doctrine adapter with a
MySQL database in combination with the Filesystem storage adapter. For
this to work we need to enable the mysql service in Travis-CI.

* Update README to reflect new Behat suites

* Fix issues raised in code review of #550

As we can't define constants through the Behat configuration file I
decided to simply add a config entry in each suite for the path to the
project root. The suites don't inherit configuration from some default
place, so the same key => value has to be defined in every suite. For
PHPUnit a project root constant has been set in the bootstrap script.
Permalink
Failed to load latest commit information.
bin Use PSR-4 autoloading instead of PSR-0 (#497) Sep 16, 2016
config Image transformation chain reimplementation (#417) May 30, 2017
docs Test multiple database / storage adapters using Behat (#550) Jul 28, 2017
public Check rethrowFinalException and throw the exception if set Nov 15, 2016
setup Remove doctrine storage adapters, resolves #538 (#540) Apr 26, 2017
src Test multiple database / storage adapters using Behat (#550) Jul 28, 2017
tests Test multiple database / storage adapters using Behat (#550) Jul 28, 2017
.editorconfig Remove executable flag for files that does not need it. Nov 20, 2013
.gitignore Update and improve Behat tests Apr 2, 2017
.travis.yml Test multiple database / storage adapters using Behat (#550) Jul 28, 2017
CONTRIBUTING.md Update and improve Behat tests Apr 2, 2017
ChangeLog.markdown Pulled in change from imbo-2.x branch (7079550) Dec 1, 2016
LICENSE Update changelog + copyright year Mar 17, 2016
README.markdown Update changelog + copyright year Mar 17, 2016
behat.yml.dist Test multiple database / storage adapters using Behat (#550) Jul 28, 2017
composer.json Test multiple database / storage adapters using Behat (#550) Jul 28, 2017
composer.lock Image transformation chain reimplementation (#417) May 30, 2017
phpmd.xml Ignore some composer-related files and renamed the phpmd configuration Jun 19, 2012
phpunit.xml.dist Update and improve Behat tests Apr 2, 2017
phpunit.xml.travis Update and improve Behat tests Apr 2, 2017

README.markdown

Imbo

Imbo is an image "server" that can be used to add/get/delete images using a REST interface. There is also support for adding meta data to an image. The main idea behind Imbo is to have a place to store high quality original images and to use the REST interface to fetch variations of those images. Imbo will resize, rotate, crop (amongst other features) on the fly so you won't have to store all the different variations.

Current build Status

Installation / Configuration / Documentation

End-user docs can be found here.

License

Copyright (c) 2011-2016, Christer Edvartsen cogo@starzinger.net

Licensed under the MIT License

Community

If you have any questions feel free to join #imbo on the Freenode IRC network (chat.freenode.net), or ask them on the forum.