Skip to content

Commit

Permalink
phalcon#13655 - Assets/Collection - Tests finished - Just 2 errors in…
Browse files Browse the repository at this point in the history
… Phalcon to fix
  • Loading branch information
jenovateurs committed Feb 15, 2020
1 parent 2337275 commit 6920c17
Show file tree
Hide file tree
Showing 51 changed files with 761 additions and 842 deletions.
24 changes: 21 additions & 3 deletions tests/unit/Assets/Collection/AddCssCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,38 @@

namespace Phalcon\Test\Unit\Assets\Collection;

use Phalcon\Assets\Collection;
use UnitTester;

class AddCssCest
{
/**
* Tests Phalcon\Assets\Collection :: addCss()
*
* @author Phalcon Team <team@phalcon.io>
* @since 2018-11-13
* @author Jeremy PASTOURET <https://github.com/jenovateurs>
* @since 2020-02-06
*/
public function assetsCollectionAddCss(UnitTester $I)
{
$I->wantToTest('Assets\Collection - addCss()');

$I->skipTest('Need implementation');
$collection = new Collection();

$collection->addCss(
'css/docs.css'
);

$collection->addCss(
'https://assets.phalcon.io/phalcon/css/core.css'
);

foreach ($collection as $asset) {
$I->assertEquals(
'css',
$asset->getType()
);
}

$I->assertCount(2, $collection);
}
}
27 changes: 24 additions & 3 deletions tests/unit/Assets/Collection/AddFilterCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,41 @@

namespace Phalcon\Test\Unit\Assets\Collection;

use Phalcon\Assets\Collection;
use Phalcon\Assets\Filters\None;
use UnitTester;

class AddFilterCest
{
/**
* Tests Phalcon\Assets\Collection :: addFilter()
*
* @author Phalcon Team <team@phalcon.io>
* @since 2018-11-13
* @author Jeremy PASTOURET <https://github.com/jenovateurs>
* @since 2020-02-06
*/
public function assetsCollectionAddFilter(UnitTester $I)
{
$I->wantToTest('Assets\Collection - addFilter()');

$I->skipTest('Need implementation');
$collection = new Collection();

$collection->addFilter(
new None()
);

$collection->addFilter(
new None()
);

$filters = $collection->getFilters();

foreach ($filters as $filter) {
$I->assertInstanceOf(
None::class,
$filter
);
}

$I->assertCount(2, $filters);
}
}
23 changes: 20 additions & 3 deletions tests/unit/Assets/Collection/AddInlineCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,37 @@

namespace Phalcon\Test\Unit\Assets\Collection;

use Phalcon\Assets\Collection;
use Phalcon\Assets\Inline;
use UnitTester;

class AddInlineCest
{
/**
* Tests Phalcon\Assets\Collection :: addInline()
*
* @author Phalcon Team <team@phalcon.io>
* @since 2018-11-13
* @author Jeremy PASTOURET <https://github.com/jenovateurs>
* @since 2020-02-06
*/
public function assetsCollectionAddInline(UnitTester $I)
{
$I->wantToTest('Assets\Collection - addInline()');

$I->skipTest('Need implementation');
$collection = new Collection();

$inline = new Inline("js", "alert('an amazing test');");

$collection->addInline(
$inline
);

$codes = $collection->getCodes();

$I->assertCount(1, $collection->getCodes());

$I->assertEquals(
end($codes),
$inline
);
}
}
23 changes: 20 additions & 3 deletions tests/unit/Assets/Collection/AddInlineCssCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,37 @@

namespace Phalcon\Test\Unit\Assets\Collection;

use Phalcon\Assets\Collection;
use Phalcon\Assets\Inline\Css;
use UnitTester;

class AddInlineCssCest
{
/**
* Tests Phalcon\Assets\Collection :: addInlineCss()
*
* @author Phalcon Team <team@phalcon.io>
* @since 2018-11-13
* @author Jeremy PASTOURET <https://github.com/jenovateurs>
* @since 2020-02-06
*/
public function assetsCollectionAddInlineCss(UnitTester $I)
{
$I->wantToTest('Assets\Collection - addInlineCss()');

$I->skipTest('Need implementation');
$collection = new Collection();

$inline = new Css(".awesome{color: #8fc6bc}");

$collection->addInline(
$inline
);

$codes = $collection->getCodes();

$I->assertCount(1, $collection->getCodes());

$I->assertEquals(
end($codes),
$inline
);
}
}
23 changes: 20 additions & 3 deletions tests/unit/Assets/Collection/AddInlineJsCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,37 @@

namespace Phalcon\Test\Unit\Assets\Collection;

use Phalcon\Assets\Collection;
use Phalcon\Assets\Inline\Js;
use UnitTester;

class AddInlineJsCest
{
/**
* Tests Phalcon\Assets\Collection :: addInlineJs()
*
* @author Phalcon Team <team@phalcon.io>
* @since 2018-11-13
* @author Jeremy PASTOURET <https://github.com/jenovateurs>
* @since 2020-02-06
*/
public function assetsCollectionAddInlineJs(UnitTester $I)
{
$I->wantToTest('Assets\Collection - addInlineJs()');

$I->skipTest('Need implementation');
$collection = new Collection();

$inline = new Js("alert('an amazing test');");

$collection->addInline(
$inline
);

$codes = $collection->getCodes();

$I->assertCount(1, $collection->getCodes());

$I->assertEquals(
end($codes),
$inline
);
}
}
24 changes: 21 additions & 3 deletions tests/unit/Assets/Collection/AddJsCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,38 @@

namespace Phalcon\Test\Unit\Assets\Collection;

use Phalcon\Assets\Collection;
use UnitTester;

class AddJsCest
{
/**
* Tests Phalcon\Assets\Collection :: addJs()
*
* @author Phalcon Team <team@phalcon.io>
* @since 2018-11-13
* @author Jeremy PASTOURET <https://github.com/jenovateurs>
* @since 2020-02-06
*/
public function assetsCollectionAddJs(UnitTester $I)
{
$I->wantToTest('Assets\Collection - addJs()');

$I->skipTest('Need implementation');
$collection = new Collection();

$collection->addJs(
'js/jquery.css'
);

$collection->addJs(
'https://assets.phalcon.io/phalcon/js/core.js'
);

foreach ($collection as $asset) {
$I->assertEquals(
'js',
$asset->getType()
);
}

$I->assertCount(2, $collection);
}
}
12 changes: 9 additions & 3 deletions tests/unit/Assets/Collection/ConstructCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,26 @@

namespace Phalcon\Test\Unit\Assets\Collection;

use Phalcon\Assets\Collection;
use UnitTester;

class ConstructCest
{
/**
* Tests Phalcon\Assets\Collection :: __construct()
*
* @author Phalcon Team <team@phalcon.io>
* @since 2018-11-13
* @author Jeremy PASTOURET <https://github.com/jenovateurs>
* @since 2020-02-06
*/
public function assetsCollectionConstruct(UnitTester $I)
{
$I->wantToTest('Assets\Collection - __construct()');

$I->skipTest('Need implementation');
$collection = new Collection();

$I->assertInstanceOf(
Collection::class,
$collection
);
}
}
28 changes: 25 additions & 3 deletions tests/unit/Assets/Collection/CountCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,42 @@

namespace Phalcon\Test\Unit\Assets\Collection;

use Phalcon\Assets\Collection;
use UnitTester;

class CountCest
{
/**
* Tests Phalcon\Assets\Collection :: count()
*
* @author Phalcon Team <team@phalcon.io>
* @since 2018-11-13
* @author Jeremy PASTOURET <https://github.com/jenovateurs>
* @since 2020-02-06
*/
public function assetsCollectionCount(UnitTester $I)
{
$I->wantToTest('Assets\Collection - count()');

$I->skipTest('Need implementation');
$collection = new Collection();

$collection->addCss(
'css/docs.css'
);

$collection->addCss(
'https://assets.phalcon.io/phalcon/css/core.css'
);

$collection->addJs(
'js/jquery.css'
);

$collection->addJs(
'https://assets.phalcon.io/phalcon/js/core.js'
);

$I->assertEquals(
4,
$collection->count()
);
}
}
27 changes: 24 additions & 3 deletions tests/unit/Assets/Collection/CurrentCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,41 @@

namespace Phalcon\Test\Unit\Assets\Collection;

use Phalcon\Assets\Asset;
use Phalcon\Assets\Collection;
use UnitTester;

class CurrentCest
{
/**
* Tests Phalcon\Assets\Collection :: current()
*
* @author Phalcon Team <team@phalcon.io>
* @since 2018-11-13
* @author Jeremy PASTOURET <https://github.com/jenovateurs>
* @since 2020-02-06
*/
public function assetsCollectionCurrent(UnitTester $I)
{
$I->wantToTest('Assets\Collection - current()');

$I->skipTest('Need implementation');
$collection = new Collection();

$asset = new Asset('js', 'js/jquery.js');

$collection->add(
$asset
);

$asset1 = new Asset('js', 'js/jquery-ui.js');

$collection->add(
$asset1
);

// ERROR TO FIX IN PHALCON Undefined index: in phalcon/Assets/Collection.zep on line 261
$I->assertEquals($asset, $collection->current());

$collection->next();

$I->assertEquals($asset1, $collection->current());
}
}
Loading

0 comments on commit 6920c17

Please sign in to comment.