示例#1
0
 describe("::reset()", function () {
     it("reset the inflector rules", function () {
         Inflector::reset();
         expect(Inflector::singularize('posts'))->toBe('post');
         expect(Inflector::pluralize('post'))->toBe('posts');
     });
     it("clears all the inflector rules", function () {
         Inflector::reset(true);
         expect(Inflector::singularize('posts'))->toBe('posts');
         expect(Inflector::pluralize('post'))->toBe('post');
     });
 });
 context("using a custom language", function () {
     describe("::singularize/pluralize()", function () {
         it("can manages several languages", function () {
             Inflector::reset();
             require 'spec/fixture/fr.php';
             require 'spec/fixture/es.php';
             expect(Inflector::singularize('taxes'))->toBe('tax');
             expect(Inflector::pluralize('tax'))->toBe('taxes');
             expect(Inflector::singularize('bateaux', 'fr'))->toBe('bateau');
             expect(Inflector::pluralize('bateau', 'fr'))->toBe('bateaux');
             expect(Inflector::singularize('ediciones', 'es'))->toBe('edición');
             expect(Inflector::pluralize('edición', 'es'))->toBe('ediciones');
             Inflector::singular('/x$/i', '', 'zz');
             Inflector::plural('/([^x])$/i', '\\1x', 'zz');
             expect(Inflector::singularize('abcdefx', 'zz'))->toBe('abcdef');
             expect(Inflector::pluralize('abcdef', 'zz'))->toBe('abcdefx');
         });
     });
 });