Permalink
Browse files

added factories for posts

  • Loading branch information...
DavertMik committed Oct 23, 2014
1 parent 94b90f0 commit 7057518d41eaff6bbba2d4bea7aee400cf504492
View

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -21,7 +21,7 @@ public function __construct(Post $post)
*/
public function index()
{
$posts = $this->post->all();
$posts = $this->post->all()->take(20);
return View::make('posts.index', compact('posts'));
}
@@ -17,7 +17,7 @@
<tbody>
@foreach ($posts as $post)
<tr>
<tr class="post">
<td>{{ $post->title }}</td>
<td>{{ $post->body }}</td>
<td>{{ link_to_route('posts.edit', 'Edit', array($post->id), array('class' => 'btn btn-info')) }}</td>
@@ -0,0 +1,43 @@
<?php
namespace Codeception\Module;
// here you can define custom actions
// all public methods declared in helper class will be available in $I
class FactoryHelper extends \Codeception\Module
{
/**
* @var \League\FactoryMuffin\Factory
*/
protected $factory;
public function _initialize()
{
$this->factory = new \League\FactoryMuffin\Factory;
$this->factory->define('Post', array(
'title' => 'sentence|5',
'body' => 'text',
));
$this->factory->define('User', array(
'email' => 'unique:email',
'password' => \Hash::make('password')
));
}
public function havePosts($num)
{
$this->factory->seed($num, 'Post');
}
public function haveUsers($num)
{
$this->factory->seed($num, 'Post');
}
public function _after()
{
$this->factory->deleteSaved();
}
}
View
@@ -1,4 +1,4 @@
<?php //[STAMP] 86732c39a1f5f6ad40ab78d66f06c158
<?php //[STAMP] 01124157c18c91e57aa55ea8569f5f14
// This class was automatically generated by build task
// You should not change it manually as it will be overwritten on next build
@@ -541,14 +541,6 @@ public function amHttpAuthenticated($username, $password) {
* ?>
* ```
*
* Unless you are using one of framework modules, absolute URL can be specified as well:
*
* ``` php
* <?php
* $I->amOnPage('http://codeception.com');
* ?>
* ```
*
* @param $page
* @see \Codeception\Lib\InnerBrowser::amOnPage()
*/
View
@@ -1,4 +1,4 @@
<?php //[STAMP] 61a18e27419fe43620cb2875cd12bea3
<?php //[STAMP] b56fea7d1921670066ad2fef1617feb2
// This class was automatically generated by build task
// You should not change it manually as it will be overwritten on next build
@@ -8,4 +8,4 @@
class_name: FunctionalTester
modules:
enabled: [Laravel4, FunctionalHelper]
enabled: [Laravel4, FactoryHelper, FunctionalHelper]
@@ -1,11 +1,12 @@
<?php //[STAMP] e5edac636a03c29b241aa235de26a976
<?php //[STAMP] ab1f093cefdb5f81677d84d2637eaf22
// This class was automatically generated by build task
// You should not change it manually as it will be overwritten on next build
// @codingStandardsIgnoreFile
use Codeception\Module\Laravel4;
use Codeception\Module\FactoryHelper;
use Codeception\Module\FunctionalHelper;
/**
@@ -539,14 +540,6 @@ public function amHttpAuthenticated($username, $password) {
* ?>
* ```
*
* Unless you are using one of framework modules, absolute URL can be specified as well:
*
* ``` php
* <?php
* $I->amOnPage('http://codeception.com');
* ?>
* ```
*
* @param $page
* @see \Codeception\Lib\InnerBrowser::amOnPage()
*/
@@ -2008,4 +2001,26 @@ public function cantSeeInTitle($title) {
public function dontSeeInTitle($title) {
return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSeeInTitle', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
*
* @see \Codeception\Module\FactoryHelper::havePosts()
*/
public function havePosts($num) {
return $this->scenario->runStep(new \Codeception\Step\Action('havePosts', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
*
* @see \Codeception\Module\FactoryHelper::haveUsers()
*/
public function haveUsers($num) {
return $this->scenario->runStep(new \Codeception\Step\Action('haveUsers', func_get_args()));
}
}
@@ -0,0 +1,6 @@
<?php
$I = new FunctionalTester($scenario);
$I->wantTo('check posts are limited to 20 on page');
$I->havePosts(40);
$I->amOnPage('/posts');
$I->seeNumberOfElements('.post', 20);
@@ -1,4 +1,4 @@
<?php //[STAMP] 9fb4cdd4ba6baa8a10c0a97bdc18e11a
<?php //[STAMP] 980277657b08a402c07b4bc88e82a1df
// This class was automatically generated by build task
// You should not change it manually as it will be overwritten on next build

0 comments on commit 7057518

Please sign in to comment.