sger I'm Spiros Gerokostas:a programmer and music enthusiast.

Unit Testing with Database migrations

In this post i’m going to show you how to enable database migrations with Laravel and PHPUnit. First add two elements to phpunit.xml which the the XML Configuration File for PHPUnit.

<env name="DB_CONNECTION" value="sqlite"/>
<env name="DB_DATABASE" value=":memory:"/>

We are using sqlite for the connection and a memory database.Let’s add some methods in TestCase.php file


use App\Exceptions\Handler;
use Psr\Log\LoggerInterface;

class TestCase extends Illuminate\Foundation\Testing\TestCase
     * The base URL to use while testing the application.
     * @var string
    protected $baseUrl = '';

     * Default preparation for each test
    public function setUp()

    public function tearDown()

    * Migrates the database and run the seeder.
    private function prepareForTests()

     * Creates the application.
     * @return \Illuminate\Foundation\Application
    public function createApplication()
        $app = require __DIR__.'/../bootstrap/app.php';


        return $app;

Let’s write our first test


use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;

class UserTest extends TestCase
    use DatabaseMigrations;
    /** @test */
    public function a_user_has_a_name()
        $user = factory(\App\User::class)->create([
            'name' => 'Spiros',
            'surname' => 'Gerokostas']);

        $this->assertEquals('Spiros', $user->name);

Enable database migrations with DatabaseMigrations trait:

use DatabaseMigrations;

Run the test:

$ phpunit --filter a_user_has_a_name

The Top 20 Albums Of 2015

  1. Periphery - “Juggernaut:Alpha/Omega”
  2. Tesseract - “Polaris”
  3. Steven Wilson - “Hand. Cannot. Erase”
  4. Lamb Of God - “VII: Sturm Und Drang”
  5. Ghost - “Meliora”
  6. Leprous - “The Congregation”
  7. The Aristocrats - “Tres Caballeros”
  8. Faith No More - “Sol Invictus”
  9. Between The Buried And Me - “Coma Ecliptic”
  10. Sylosis - “Dormant Heart”
  11. Sumac - “The Deal”
  12. Fear Factory - “Genexus”
  13. Baroness - “Purple”
  14. Komara - “Komara”
  15. Intronaut - “The Direction Of Last Things”
  16. Napalm Death - “Apex Predator Easy Meat”
  17. Clutch - “Psychic Warfare”
  18. Refused - “Freedom”
  19. Enslaved - “In Times”
  20. Killing Joke - “Pylon”

Xcode with Swift 2.2

Simple steps how to use Swift 2.2 with latest Xcode.First of all install swift 2.2 there’s a package installer on the website or build it from terminal instructions here

after the installation process make sure the proper version is installed from the terminal run:

$ swift
$ Welcome to Apple Swift version 2.2-dev (LLVM 46be9ff861, Clang 4deb154edc, Swift 778f82939c). Type :help for assistance.

we have 2 toolchains installed the default location is:

$ cd /Library/Developer/Toolchains
$ ls
$ swift-2.2-SNAPSHOT-2015-12-01-a.xctoolchain swift-latest.xctoolchain

quit Xcode and run from the terminal

$ xcrun launch-with-toolchain /Library/Developer/Toolchains/swift-2.2-SNAPSHOT-2015-12-01-a.xctoolchain

Tinylog 1.0.5

Version 1.0.5 Updates

  • Support for 3D touch quick touch to create a new list
  • Added new font San Francisco
  • Various bug fixes


Pretty Xcode unit tests

Sometimes we want to execute Xcode unit tests from the command line and format xcodebuild’s output make it pretty and readable, the perfect ruby gem for this job is xcpretty.

$ gem install xcpretty

create shell script:

$ touch test
$ sudo nano test

add the following script:

#!/usr/bin/env bash

set -o pipefail

xcodebuild test -workspace MyProject.xcworkspace -scheme MyProject -sdk iphonesimulator BUILD_ACTIVE_ARCH=NO | xcpretty -t -c

make it executable:

$ chmod +x test

run the tests

$ test

or you can run tests from the command line:

$ set -o pipefail && xcodebuild test -workspace MyProject.xcworkspace -scheme MyProject -sdk iphonesimulator BUILD_ACTIVE_ARCH=NO | xcpretty -t -c

ReactiveCocoa for Xcode 7

Xcode 7 requires swift 2.0 but current version of ReactiveCocoa uses 1.2 checkout the ‘swift2’ branch and build the framework.

$ git submodule add
$ cd ReactiveCocoa
$ checkout swift2
$ script/bootstrap