Completed
Push — master ( b0c181...752129 )
by Aimeos
03:48
created
lib/custom/setup/EzuserAddAddress.php 1 patch
Indentation   +116 added lines, -116 removed lines patch added patch discarded remove patch
@@ -14,120 +14,120 @@
 block discarded – undo
14 14
  */
15 15
 class EzuserAddAddress extends \Aimeos\MW\Setup\Task\TablesCreateMShop
16 16
 {
17
-	/**
18
-	 * Returns the list of task names which depends on this task.
19
-	 *
20
-	 * @return array List of task names
21
-	 */
22
-	public function getPreDependencies()
23
-	{
24
-		return array( 'TablesCreateEzpublish' );
25
-	}
26
-
27
-
28
-	/**
29
-	 * Migrate database schema
30
-	 */
31
-	public function migrate()
32
-	{
33
-		$this->msg( 'Adding address fields to ezuser table', 0 );
34
-
35
-		$dbal = $this->getConnection( 'db-customer' )->getRawObject();
36
-
37
-		if( !( $dbal instanceof \Doctrine\DBAL\Connection ) ) {
38
-			throw new \Aimeos\MW\Setup\Exception( 'Not a DBAL connection' );
39
-		}
40
-
41
-
42
-		$fromSchema = $dbal->getSchemaManager()->createSchema();
43
-		$toSchema = clone $fromSchema;
44
-
45
-		$this->addIndexes( $this->addColumns( $toSchema->getTable( 'ezuser' ) ) );
46
-		$sql = $fromSchema->getMigrateToSql( $toSchema, $dbal->getDatabasePlatform() );
47
-
48
-		if( $sql !== array() )
49
-		{
50
-			$this->executeList( $sql, 'db-customer' );
51
-			$this->status( 'done' );
52
-		}
53
-		else
54
-		{
55
-			$this->status( 'OK' );
56
-		}
57
-	}
58
-
59
-
60
-	/**
61
-	 * Adds the missing columns to the table
62
-	 *
63
-	 * @param \Doctrine\DBAL\Schema\Table $table Table object
64
-	 * @return \Doctrine\DBAL\Schema\Table Updated table object
65
-	 */
66
-	protected function addColumns( \Doctrine\DBAL\Schema\Table $table )
67
-	{
68
-		$columns = array(
69
-			'company' => array( 'string', array( 'length' => 100 ) ),
70
-			'vatid' => array( 'string', array( 'length' => 32 ) ),
71
-			'salutation' => array( 'string', array( 'length' => 8 ) ),
72
-			'title' => array( 'string', array( 'length' => 64 ) ),
73
-			'firstname' => array( 'string', array( 'length' => 64 ) ),
74
-			'lastname' => array( 'string', array( 'length' => 64 ) ),
75
-			'address1' => array( 'string', array( 'length' => 255 ) ),
76
-			'address2' => array( 'string', array( 'length' => 255 ) ),
77
-			'address3' => array( 'string', array( 'length' => 255 ) ),
78
-			'postal' => array( 'string', array( 'length' => 16 ) ),
79
-			'city' => array( 'string', array( 'length' => 255 ) ),
80
-			'state' => array( 'string', array( 'length' => 255 ) ),
81
-			'langid' => array( 'string', array( 'length' => 5, 'notnull' => false ) ),
82
-			'countryid' => array( 'string', array( 'length' => 2, 'notnull' => false, 'fixed' => true ) ),
83
-			'telephone' => array( 'string', array( 'length' => 32 ) ),
84
-			'telefax' => array( 'string', array( 'length' => 32 ) ),
85
-			'website' => array( 'string', array( 'length' => 255 ) ),
86
-			'birthday' => array( 'date', array( 'notnull' => false ) ),
87
-			'vdate' => array( 'date', array( 'notnull' => false ) ),
88
-			'status' => array( 'smallint', array() ),
89
-			'mtime' => array( 'datetime', array() ),
90
-			'ctime' => array( 'datetime', array() ),
91
-			'editor' => array( 'string', array( 'length' => 255 ) ),
92
-		);
93
-
94
-		foreach( $columns as $name => $def )
95
-		{
96
-			if( $table->hasColumn( $name ) === false ) {
97
-				$table->addColumn( $name, $def[0], $def[1] );
98
-			}
99
-		}
100
-
101
-		return $table;
102
-	}
103
-
104
-
105
-	/**
106
-	 * Adds the missing indexes to the table
107
-	 *
108
-	 * @param \Doctrine\DBAL\Schema\Table $table Table object
109
-	 * @return \Doctrine\DBAL\Schema\Table Updated table object
110
-	 */
111
-	protected function addIndexes( \Doctrine\DBAL\Schema\Table $table )
112
-	{
113
-		$indexes = array(
114
-			'idx_ezpus_langid' => array( 'langid' ),
115
-			'idx_ezpus_status_ln_fn' => array( 'status', 'lastname', 'firstname' ),
116
-			'idx_ezpus_status_ad1_ad2' => array( 'status', 'address1', 'address2' ),
117
-			'idx_ezpus_status_postal_city' => array( 'status', 'postal', 'city' ),
118
-			'idx_ezpus_lastname' => array( 'lastname' ),
119
-			'idx_ezpus_address1' => array( 'address1' ),
120
-			'idx_ezpus_postal' => array( 'postal' ),
121
-			'idx_ezpus_city' => array( 'city' ),
122
-		);
123
-
124
-		foreach( $indexes as $name => $def )
125
-		{
126
-			if( $table->hasIndex( $name ) === false ) {
127
-				$table->addIndex( $def, $name );
128
-			}
129
-		}
130
-
131
-		return $table;
132
-	}
17
+    /**
18
+     * Returns the list of task names which depends on this task.
19
+     *
20
+     * @return array List of task names
21
+     */
22
+    public function getPreDependencies()
23
+    {
24
+        return array( 'TablesCreateEzpublish' );
25
+    }
26
+
27
+
28
+    /**
29
+     * Migrate database schema
30
+     */
31
+    public function migrate()
32
+    {
33
+        $this->msg( 'Adding address fields to ezuser table', 0 );
34
+
35
+        $dbal = $this->getConnection( 'db-customer' )->getRawObject();
36
+
37
+        if( !( $dbal instanceof \Doctrine\DBAL\Connection ) ) {
38
+            throw new \Aimeos\MW\Setup\Exception( 'Not a DBAL connection' );
39
+        }
40
+
41
+
42
+        $fromSchema = $dbal->getSchemaManager()->createSchema();
43
+        $toSchema = clone $fromSchema;
44
+
45
+        $this->addIndexes( $this->addColumns( $toSchema->getTable( 'ezuser' ) ) );
46
+        $sql = $fromSchema->getMigrateToSql( $toSchema, $dbal->getDatabasePlatform() );
47
+
48
+        if( $sql !== array() )
49
+        {
50
+            $this->executeList( $sql, 'db-customer' );
51
+            $this->status( 'done' );
52
+        }
53
+        else
54
+        {
55
+            $this->status( 'OK' );
56
+        }
57
+    }
58
+
59
+
60
+    /**
61
+     * Adds the missing columns to the table
62
+     *
63
+     * @param \Doctrine\DBAL\Schema\Table $table Table object
64
+     * @return \Doctrine\DBAL\Schema\Table Updated table object
65
+     */
66
+    protected function addColumns( \Doctrine\DBAL\Schema\Table $table )
67
+    {
68
+        $columns = array(
69
+            'company' => array( 'string', array( 'length' => 100 ) ),
70
+            'vatid' => array( 'string', array( 'length' => 32 ) ),
71
+            'salutation' => array( 'string', array( 'length' => 8 ) ),
72
+            'title' => array( 'string', array( 'length' => 64 ) ),
73
+            'firstname' => array( 'string', array( 'length' => 64 ) ),
74
+            'lastname' => array( 'string', array( 'length' => 64 ) ),
75
+            'address1' => array( 'string', array( 'length' => 255 ) ),
76
+            'address2' => array( 'string', array( 'length' => 255 ) ),
77
+            'address3' => array( 'string', array( 'length' => 255 ) ),
78
+            'postal' => array( 'string', array( 'length' => 16 ) ),
79
+            'city' => array( 'string', array( 'length' => 255 ) ),
80
+            'state' => array( 'string', array( 'length' => 255 ) ),
81
+            'langid' => array( 'string', array( 'length' => 5, 'notnull' => false ) ),
82
+            'countryid' => array( 'string', array( 'length' => 2, 'notnull' => false, 'fixed' => true ) ),
83
+            'telephone' => array( 'string', array( 'length' => 32 ) ),
84
+            'telefax' => array( 'string', array( 'length' => 32 ) ),
85
+            'website' => array( 'string', array( 'length' => 255 ) ),
86
+            'birthday' => array( 'date', array( 'notnull' => false ) ),
87
+            'vdate' => array( 'date', array( 'notnull' => false ) ),
88
+            'status' => array( 'smallint', array() ),
89
+            'mtime' => array( 'datetime', array() ),
90
+            'ctime' => array( 'datetime', array() ),
91
+            'editor' => array( 'string', array( 'length' => 255 ) ),
92
+        );
93
+
94
+        foreach( $columns as $name => $def )
95
+        {
96
+            if( $table->hasColumn( $name ) === false ) {
97
+                $table->addColumn( $name, $def[0], $def[1] );
98
+            }
99
+        }
100
+
101
+        return $table;
102
+    }
103
+
104
+
105
+    /**
106
+     * Adds the missing indexes to the table
107
+     *
108
+     * @param \Doctrine\DBAL\Schema\Table $table Table object
109
+     * @return \Doctrine\DBAL\Schema\Table Updated table object
110
+     */
111
+    protected function addIndexes( \Doctrine\DBAL\Schema\Table $table )
112
+    {
113
+        $indexes = array(
114
+            'idx_ezpus_langid' => array( 'langid' ),
115
+            'idx_ezpus_status_ln_fn' => array( 'status', 'lastname', 'firstname' ),
116
+            'idx_ezpus_status_ad1_ad2' => array( 'status', 'address1', 'address2' ),
117
+            'idx_ezpus_status_postal_city' => array( 'status', 'postal', 'city' ),
118
+            'idx_ezpus_lastname' => array( 'lastname' ),
119
+            'idx_ezpus_address1' => array( 'address1' ),
120
+            'idx_ezpus_postal' => array( 'postal' ),
121
+            'idx_ezpus_city' => array( 'city' ),
122
+        );
123
+
124
+        foreach( $indexes as $name => $def )
125
+        {
126
+            if( $table->hasIndex( $name ) === false ) {
127
+                $table->addIndex( $def, $name );
128
+            }
129
+        }
130
+
131
+        return $table;
132
+    }
133 133
 }
Please login to merge, or discard this patch.
lib/custom/setup/unittest/CustomerAddEzpublishTestData.php 1 patch
Indentation   +105 added lines, -105 removed lines patch added patch discarded remove patch
@@ -14,119 +14,119 @@
 block discarded – undo
14 14
  */
15 15
 class CustomerAddEzpublishTestData extends \Aimeos\MW\Setup\Task\CustomerAddTestData
16 16
 {
17
-	/**
18
-	 * Returns the list of task names which this task depends on.
19
-	 *
20
-	 * @return string[] List of task names
21
-	 */
22
-	public function getPreDependencies()
23
-	{
24
-		return array( 'TablesCreateEzpublish', 'EzuserAddAddress', 'MShopSetLocale', 'MediaAddTestData' );
25
-	}
26
-
27
-
28
-	/**
29
-	 * Adds attribute test data.
30
-	 */
31
-	public function migrate()
32
-	{
33
-		$iface = '\\Aimeos\\MShop\\Context\\Item\\Iface';
34
-		if( !( $this->additional instanceof $iface ) ) {
35
-			throw new \Aimeos\MW\Setup\Exception( sprintf( 'Additionally provided object is not of type "%1$s"', $iface ) );
36
-		}
37
-
38
-		$context = $this->getEzContext( $this->additional );
39
-
40
-		$this->msg( 'Adding ezPublish customer test data', 0 );
41
-
42
-		$parentIds = array();
43
-		$ds = DIRECTORY_SEPARATOR;
44
-		$context->setEditor( 'ai-ezpublish:unittest' );
45
-		$path = __DIR__ . $ds . 'data' . $ds . 'customer.php';
46
-
47
-		if( ( $testdata = include( $path ) ) === false ){
48
-			throw new \Aimeos\MShop\Exception( sprintf( 'No file "%1$s" found for customer domain', $path ) );
49
-		}
50
-
51
-
52
-		$customerManager = \Aimeos\MShop\Customer\Manager\Factory::createManager( $context, 'Ezpublish' );
53
-		$customerAddressManager = $customerManager->getSubManager( 'address', 'Ezpublish' );
54
-
55
-		$search = $customerManager->createSearch();
56
-		$search->setConditions( $search->compare( '==', 'customer.code', array( 'UTC001', 'UTC002', 'UTC003' ) ) );
57
-		$items = $customerManager->searchItems( $search );
58
-
59
-		$this->conn->begin();
60
-
61
-		$customerManager->deleteItems( array_keys( $items ) );
62
-		$parentIds = $this->addCustomerData( $testdata, $customerManager, $customerAddressManager->createItem() );
63
-		$this->addCustomerAddressData( $testdata, $customerAddressManager, $parentIds );
64
-
65
-		$this->conn->commit();
66
-
67
-
68
-		$this->status( 'done' );
69
-	}
70
-
71
-
72
-	/**
73
-	 * Returns the Ezpublish context
74
-	 *
75
-	 * @param \Aimeos\MShop\Context\Item\Iface $context Context object
76
-	 * @return \Aimeos\MShop\Context\Item\Ezpublish Ezpublish context object
77
-	 */
78
-	protected function getEzContext( \Aimeos\MShop\Context\Item\Iface $context )
79
-	{
80
-		$class = '\Aimeos\MShop\Context\Item\Ezpublish';
81
-		if( is_a( $context, $class ) ) {
82
-			return $context;
83
-		}
84
-
85
-		$ezContext = new \Aimeos\MShop\Context\Item\Ezpublish();
86
-		$ezContext->setDatabaseManager( clone $context->getDatabaseManager() );
87
-		$ezContext->setSession( clone $context->getSession() );
88
-		$ezContext->setLogger( clone $context->getLogger() );
89
-		$ezContext->setLocale( clone $context->getLocale() );
90
-		$ezContext->setConfig( clone $context->getConfig() );
91
-		$ezContext->setCache( clone $context->getCache() );
92
-
93
-
94
-		$ezContext->setEzUser( function( $code, $email, $password ) use ( $context ) {
95
-
96
-			$id = mt_rand( -0x7fffffff,-1 );
97
-			$dbm = $context->getDatabaseManager();
98
-			$dbconf = $context->getConfig()->get( 'resource/db-customer' );
99
-			$dbname = ( $dbconf ? 'db-customer' : 'db' );
100
-			$conn = $dbm->acquire( $dbname );
101
-
102
-			try
103
-			{
104
-				$stmt = $conn->create( 'INSERT INTO "ezuser" (
17
+    /**
18
+     * Returns the list of task names which this task depends on.
19
+     *
20
+     * @return string[] List of task names
21
+     */
22
+    public function getPreDependencies()
23
+    {
24
+        return array( 'TablesCreateEzpublish', 'EzuserAddAddress', 'MShopSetLocale', 'MediaAddTestData' );
25
+    }
26
+
27
+
28
+    /**
29
+     * Adds attribute test data.
30
+     */
31
+    public function migrate()
32
+    {
33
+        $iface = '\\Aimeos\\MShop\\Context\\Item\\Iface';
34
+        if( !( $this->additional instanceof $iface ) ) {
35
+            throw new \Aimeos\MW\Setup\Exception( sprintf( 'Additionally provided object is not of type "%1$s"', $iface ) );
36
+        }
37
+
38
+        $context = $this->getEzContext( $this->additional );
39
+
40
+        $this->msg( 'Adding ezPublish customer test data', 0 );
41
+
42
+        $parentIds = array();
43
+        $ds = DIRECTORY_SEPARATOR;
44
+        $context->setEditor( 'ai-ezpublish:unittest' );
45
+        $path = __DIR__ . $ds . 'data' . $ds . 'customer.php';
46
+
47
+        if( ( $testdata = include( $path ) ) === false ){
48
+            throw new \Aimeos\MShop\Exception( sprintf( 'No file "%1$s" found for customer domain', $path ) );
49
+        }
50
+
51
+
52
+        $customerManager = \Aimeos\MShop\Customer\Manager\Factory::createManager( $context, 'Ezpublish' );
53
+        $customerAddressManager = $customerManager->getSubManager( 'address', 'Ezpublish' );
54
+
55
+        $search = $customerManager->createSearch();
56
+        $search->setConditions( $search->compare( '==', 'customer.code', array( 'UTC001', 'UTC002', 'UTC003' ) ) );
57
+        $items = $customerManager->searchItems( $search );
58
+
59
+        $this->conn->begin();
60
+
61
+        $customerManager->deleteItems( array_keys( $items ) );
62
+        $parentIds = $this->addCustomerData( $testdata, $customerManager, $customerAddressManager->createItem() );
63
+        $this->addCustomerAddressData( $testdata, $customerAddressManager, $parentIds );
64
+
65
+        $this->conn->commit();
66
+
67
+
68
+        $this->status( 'done' );
69
+    }
70
+
71
+
72
+    /**
73
+     * Returns the Ezpublish context
74
+     *
75
+     * @param \Aimeos\MShop\Context\Item\Iface $context Context object
76
+     * @return \Aimeos\MShop\Context\Item\Ezpublish Ezpublish context object
77
+     */
78
+    protected function getEzContext( \Aimeos\MShop\Context\Item\Iface $context )
79
+    {
80
+        $class = '\Aimeos\MShop\Context\Item\Ezpublish';
81
+        if( is_a( $context, $class ) ) {
82
+            return $context;
83
+        }
84
+
85
+        $ezContext = new \Aimeos\MShop\Context\Item\Ezpublish();
86
+        $ezContext->setDatabaseManager( clone $context->getDatabaseManager() );
87
+        $ezContext->setSession( clone $context->getSession() );
88
+        $ezContext->setLogger( clone $context->getLogger() );
89
+        $ezContext->setLocale( clone $context->getLocale() );
90
+        $ezContext->setConfig( clone $context->getConfig() );
91
+        $ezContext->setCache( clone $context->getCache() );
92
+
93
+
94
+        $ezContext->setEzUser( function( $code, $email, $password ) use ( $context ) {
95
+
96
+            $id = mt_rand( -0x7fffffff,-1 );
97
+            $dbm = $context->getDatabaseManager();
98
+            $dbconf = $context->getConfig()->get( 'resource/db-customer' );
99
+            $dbname = ( $dbconf ? 'db-customer' : 'db' );
100
+            $conn = $dbm->acquire( $dbname );
101
+
102
+            try
103
+            {
104
+                $stmt = $conn->create( 'INSERT INTO "ezuser" (
105 105
 					"contentobject_id", "email", "login", "login_normalized", "password_hash", "password_hash_type"
106 106
 				) VALUES (
107 107
 					?, ?, ?, ?, ?, 5
108 108
 				)' );
109 109
 
110
-				$stmt->bind( 1, $id, \Aimeos\MW\DB\Statement\Base::PARAM_INT );
111
-				$stmt->bind( 2, $email );
112
-				$stmt->bind( 3, $code );
113
-				$stmt->bind( 4, $code );
114
-				$stmt->bind( 5, $password );
110
+                $stmt->bind( 1, $id, \Aimeos\MW\DB\Statement\Base::PARAM_INT );
111
+                $stmt->bind( 2, $email );
112
+                $stmt->bind( 3, $code );
113
+                $stmt->bind( 4, $code );
114
+                $stmt->bind( 5, $password );
115 115
 
116
-				$stmt->execute()->finish();
116
+                $stmt->execute()->finish();
117 117
 
118
-				$dbm->release( $conn, $dbname );
119
-			}
120
-			catch( \Exception $e )
121
-			{
122
-				$dbm->release( $conn, $dbname );
123
-				throw $e;
124
-			}
118
+                $dbm->release( $conn, $dbname );
119
+            }
120
+            catch( \Exception $e )
121
+            {
122
+                $dbm->release( $conn, $dbname );
123
+                throw $e;
124
+            }
125 125
 
126
-			return $id;
127
-		} );
126
+            return $id;
127
+        } );
128 128
 
129 129
 
130
-		return $ezContext;
131
-	}
130
+        return $ezContext;
131
+    }
132 132
 }
Please login to merge, or discard this patch.