laracasts / TestDummy

Easy factories for PHP integration testing.
https://laracasts.com/lessons/whats-new-in-testdummy
MIT License
456 stars 80 forks source link

Laracasts\TestDummy\TestDummyException: Could not locate a factory with the name: Larabook\Users\User #62

Closed UncleBong closed 9 years ago

UncleBong commented 9 years ago

// PoststatusCept.php <?php

$I = new FunctionalTester($scenario); $I->am('a Larabook member'); $I->wantTo('I want to post statuses to my profile.');

$I->signIn();

$I->amOnPage('statuses');

$I->postAStatus('My first post!');

$I->seeCurrentUrlEquals('/statuses');

$I->see('My first post!');

// this my functionalhelper.php

<?php namespace Codeception\Module;

use Laracasts\TestDummy\Factory as TestDummy;

// here you can define custom actions // all public methods declared in helper class will be available in $I

class FunctionalHelper extends \Codeception\Module {

  // Prepare Larabook account, and log in.
public function signIn(){
    $email = 'mrskaman64@gmail.com';
    $username = 'skaman';
    $password = 'skaman';

    $this->haveAnAccount(compact('username', 'email', 'password'));

    $I = $this->getModule('Laravel4');

    $I->amOnPage('/login');
    $I->fillField('email', $email);
    $I->fillField('password', $password);
    $I->click('Sign In');
}

 // Fill out the publish status form. @param $body
public function postAStatus($body){
    $I = $this->getModule('Laravel4');

    $I->fillField('body', $body);
    $I->click('Post Status');
}

 // Create a Larabook user account in the database.
 // @param array $overrides @return mixed 
public function haveAnAccount($overrides = []){ return $this->have('Larabook\Users\User', $overrides); }

 // Insert a dummy record into a database table.
 // @param $model @param array $overrides  @return mixed
public function have($model, $overrides = []){ return TestDummy::create($model, $overrides); }

}

LespiletteMaxime commented 9 years ago

Did you declare your Larabook\Users\User in your tests/factories/factories.php

Look here