Samsui is a factory library for building PHP objects useful for setting up test data in your applications.

Related tags

Miscellaneous samsui
Overview

#Samsui

Build Status Latest Stable Version Total Downloads Scrutinizer Code Quality Code Coverage

Samsui is a factory library for building PHP objects useful for setting up test data in your applications. It is mainly inspired by Rosie for JavaScript and factory_girl for Ruby.

Samsui women refers to a group of Chinese immigrants who came to Singapore to work in construction and industries. Their hardwork contributed to Singapore's development as a colony and young nation.

With Samsui, you can quickly build prototype application and generate as many data as you need for testing your prototype.

  • Samsui was created by and maintained by Sam Yong.
  • Samsui uses Travis CI to check that the code works.
  • Samsui uses [Scrutinizer CI] to check code quality and test coverage.
  • Samsui uses Composer to load and manage its dependencies.
  • Samsui is licensed under the BSD 3-Clause license.

##Installation

Samsui is a PHP library that manages its dependencies using Composer. You can directly use Samsui in your application through Composer:

{
    "require": {
      "mauris/samsui": "1.0.*"
    }
}

Then just run Composer:

$ php composer.phar install

##Usage

You can provide definition of your objects to Samsui:

use Samsui\Factory;

$factory = new Factory();

// define an object quickly
$factory->define('person')
	->sequence('personId')
	->attr('firstName', 'James')
    ->attr('lastName', 'Clark')
    ->attr('email', function ($i, $o) {
        return strtolower($o->firstName . '.' . $o->lastName . '@example.com');
    })
	->attr('createdTime', function () {
		return time();
	});

You can build one at a time, or hundreds of them on the go!

// build them on the go!
$person = $factory->build('person');

// or build many!~
$people = $factory->build('person', 500);

The output of a person object would be (well, after JSON encoding):

{
    "personId": "1",
    "firstName": "James",
    "lastName": "Clark",
    "email": "[email protected]",
    "createdTime": "1383465074"
}

You can also use Samsui's fake data generator to fill your objects with real variety and randomity:

use Samsui\Factory;
use Samsui\Generator\Generator;

$factory = new Factory();

// define an object quickly
$factory->define('person')
    ->sequence('personId')
    ->attr('firstName', Generator::person()->firstName)
    ->attr('lastName', Generator::person()->lastName)
    ->attr('email', function ($i, $o) {
        return Generator::email()->emailAddress(
            array(
                'firstName' => $o->firstName,
                'lastName' => $o->lastName,
                'domains' => array(
                    'hotmail.com',
                    'gmail.com',
                    'example.com'
                )
            )
        );
    })
    ->attr('createdTime', function () {
        return time();
    });

##Upcoming

  • Generation of data based on locale (location+language)
  • Implementation of Data Generators for use with attributes
    • Names (different locale)
    • Email addresses
    • Addresses and Postal Codes
    • Age (based on age groups defined)
    • Gender (with Natural Birth Ratio)
    • IP Address v4 and v6
    • URLs
    • Lorem Ipsum text
    • Date/Times (based on range or sequence)
    • Hash functions output (SHA-1, SHA-256 etc.)
    • GPS latitude / longitude, land coordiates
    • Handphone numbers
    • Colors (RGB array, Hexadecimal)
    • Images (Avatar, Sized)
  • Improved JSON reader
  • Generation of Factory definitions to PHP classes directly
You might also like...
Adds factory functions for WooCommerce to be used with wp-browser integration tests.

wp-browser-woocommerce This library simplifies testing of WooCommerce themes and plugins with wp-browser. Several Unit Test Factories are added that a

A wrapper around faker for factory muffin

Factory Muffin Faker 2.3 The goal of this package is to wrap Faker to make it super easy to use with Factory Muffin. Note that this library does not a

Versi dinamis dari spk fuzzy sebelumnya, kini support setting jumlah sub kriteria

spk-fuzzy-dynamic Versi dinamis dari spk fuzzy sebelumnya, kini support setting jumlah sub kriteria SPK-Pariwisata-Fuzzy Implementasi Fuzzy Tahani Pad

A text-based, persistent browser-based strategy game (PBBG) in a fantasy war setting
A text-based, persistent browser-based strategy game (PBBG) in a fantasy war setting

Note: OpenDominion is still in development. Some features of the game have not been implemented yet. Introduction OpenDominion is a free and open-sour

PHP with PDO (PHP Data Objects) Quickstart
PHP with PDO (PHP Data Objects) Quickstart

PHP with PDO (PHP Data Objects) Quickstart This repository contains a simple web application that demonstrates how to quickly connect to and communica

Secure the data of your sites by encrypting them. They will be decrypted only in your applications

PHP Crypter Secure the data of your sites by encrypting them. They will be decrypted only in your applications How to use ? You just have to include t

Silverstripe-searchable - Adds to the default Silverstripe search by adding a custom results controller and allowing properly adding custom data objects and custom fields for searching

SilverStripe Searchable Module UPDATE - Full Text Search This module now uses Full Text Support for MySQL/MariaDB databases in version 3.* Adds more c

Melek Berita Backend is a service for crawling data from various websites and processing the data to be used for news data needs.

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

Comments
  • Scrutinizer Auto-Fixes

    Scrutinizer Auto-Fixes

    @thephpdeveloper requested this pull request.

    This patch was automatically generated as part of the following inspection: https://scrutinizer-ci.com/g/mauris/samsui/inspections/44927420-5268-45f6-9074-424ca9ba7abb

    Enabled analysis tools:

    • PHP Analyzer
    • PHP Code Coverage
    • PHP PDepend
    • PHP Similarity Analyzer
    • PHP Change Tracking Analyzer
    opened by scrutinizer-auto-fixer 0
  • Scrutinizer Auto-Fixes

    Scrutinizer Auto-Fixes

    @thephpdeveloper requested this pull request.

    This patch was automatically generated as part of the following inspection: https://scrutinizer-ci.com/g/mauris/samsui/inspections/a2b9a0e0-b6bc-42f1-b487-76fab007be88

    Enabled analysis tools:

    • PHP Analyzer
    • PHP Code Coverage
    • PHP PDepend
    • PHP Similarity Analyzer
    • PHP Change Tracking Analyzer
    opened by scrutinizer-auto-fixer 0
Releases(1.0.0)
  • 1.0.0(Nov 3, 2013)

    At this stage, implemented functionality should work as expected (defining and building objects).

    It is a preview of what the basic functionality of Samsui should look like.

    Source code(tar.gz)
    Source code(zip)
Owner
Sam Yong
DevSecOps (Web & Networks), Logic and AI, ML, Databases, Software Engineering.
Sam Yong
YCOM Impersonate. Login as selected YCOM user 🧙‍♂️in frontend.

YCOM Impersonate Login as selected YCOM user in frontend. Features: Backend users with admin rights or YCOM[] rights, can be automatically logged in v

Friends Of REDAXO 17 Sep 12, 2022
Creating data transfer objects with the power of php objects. No php attributes, no reflection api, and no other under the hook work.

Super Simple DTO Creating data transfer objects with the power of php objects. No php attributes, no reflection api, and no other under the hook work.

Mohammed Manssour 8 Jun 8, 2023
PHP package to make your objects strict and throw exception when you try to access or set some undefined property in your objects.

?? Yell PHP package to make your objects strict and throw exception when you try to access or set some undefined property in your objects. Requirement

Zeeshan Ahmad 20 Dec 8, 2018
Deeper is a easy way to compare if 2 objects is equal based on values in these objects. This library is heavily inspired in Golang's reflect.DeepEqual().

Deeper Deeper is a easy way to compare if 2 objects is equal based on values in these objects. This library is heavily inspired in Golang's reflect.De

Joubert RedRat 4 Feb 12, 2022
Test and enforce architectural rules in your Laravel applications. Keep your app's architecture clean and consistent!

Laravel Arkitect Laravel Arkitect lets you test and enforce your architectural rules in your Laravel applications, and it's a PHPArkitect wrapper for

SMorteza Ebadi 55 Dec 17, 2022
Dobren Dragojević 6 Jun 11, 2023
Guide to setting up a lazy loader with the Lozad library in WordPress.

Install WordPress LazyLoader with LOZAD Guide to setting up a lazy loader with the Lozad library in WordPress. Installation Step 1: Refer to the foote

Peyman Naderi 4 Dec 21, 2022
Guide to setting up a lazy loader with the jQuery Lazy library in WordPress.

Run jQuery Lazy in Wordpress Guide to setting up a lazy loader with the jQuery Lazy library in WordPress. Installation Step 1: Refer to the footer.php

Peyman Naderi 5 Nov 28, 2022
Guide to setting up a lazy loader with the Lozad library in WordPress.

Install WordPress LazyLoader with LOZAD Guide to setting up a lazy loader with the Lozad library in WordPress. Installation Step 1: Refer to the foote

Peyman Naderi 7 Aug 28, 2022
Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.

php-cs-fixer-config Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer. Installation Run $ composer require --dev e

null 37 Jan 2, 2023