Giter VIP home page Giter VIP logo

eloquent-external-storage's People

Contributors

inakianduaga avatar

Stargazers

 avatar  avatar  avatar

eloquent-external-storage's Issues

Refactor configuration variables

Drivers should have API for configurable properties (basePath for file/AwsS3, S3 bucket/credentials for AwsS3, etc.

That way each model can configure the driver instance it uses in whatever way it wants. The alternative is to provide a config key on the model that is passed to the driver and the driver uses that for configuring itself

Update:

  • Remove Model reference from the drivers (single-responsability, the driver shouldn't have to give a crap about what the model is).
    • Move the storage setPath update to the actual boot observer method.
  • Add abstract driver implementation
    • Extract the generateStoragePath method which is always the same
  • Add storageDriverConfigKey property on the trait, that's the only property we will need to set on the model so the driver/adaptor can be integrated.
  • Add a setConfigKey() method to the driver interface (& abstract implementation)
  • On boot method of trait, add after parent::boot() a
$storageDriver = app(StorageDriver::class)->setConfigKey($this->storageDriverConfigKey); 
Use this on the creating/deleting methods (remember to pass the variable to the lambda function)  
  • Move the $binaryPathDBField from the trait to a config property, that way we use only a single key to reference to the config, and everything else is read from there.

Add tests

  • Write test for the extensionGuesser

Setup model database

  • For the model tests, we need to setup an in-memory database, with some field, and then run the package example migration on top that adds the package content fields

Setup configuration mocker

We need to be able to mock the package configuration

  • Set model configuration key path
  • Set the configuration key values such as the proper path for file storage for example

Run the basic store method

  • Write tests for the model
    • Right now the file driver can't write to the storage path, so we need to fix that
  • Model tests
    • Add tests for update & remove operations using the file driver
  • Add aws mock tests where possible

Bug:

Tests seem to be coupled, in particular testModelUpdateWithContentChanges fails if there is any previous call to the $this->createModel test method.

  • Try changing the order to see if always the same test breaks
  • See if there is a mock or something not being reset between tests
    • Seems if we move testModelUpdateWithContentChanges before testCreateWithContent, now testCreateWithContent fails, so we need to figure out what's remaining of the mock spies.

Update: The test testCreateWithContent fails if we run it twice (same test under a different name). So we need to fix that
Solution!
http://stackoverflow.com/questions/17428050/laravel-4-model-events-dont-work-with-phpunit?rq=1

Setup tests

  • Add laravel/framework as a dev dependency so we can use IoC to test
  • Setup phpunit.xml bootstrapping
  • Add mockery

Get package to run under hhvm

Unit tests are failing when run against hhvm, hhvm-nightly with error

`

  1. InakiAnduaga\EloquentExternalStorage\Tests\Drivers\AwsS3Test::testStoreAndFetch
    Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException: The file "" does not exist
    /home/travis/build/inakianduaga/eloquent-external-storage/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeGuesser.php:115
    /home/travis/build/inakianduaga/eloquent-external-storage/src/Services/ExtensionGuesser.php:30
    /home/travis/build/inakianduaga/eloquent-external-storage/src/Drivers/AbstractDriver.php:54
    /home/travis/build/inakianduaga/eloquent-external-storage/src/Drivers/AwsS3.php:82
    /home/travis/build/inakianduaga/eloquent-external-storage/tests/src/Drivers/AwsS3Test.php:46
    `

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.